第12章クラウドネイティブアプリケーション開発
KubernetesKubernetes
Kubernetes is an open-source orchestration platform used for automating deployment, scaling, and management of container-based workloads. An example of a Kubernetes platform is shown in Figure 12.19.
Kubernetesは、コンテナーを基にしたワークロードの配置、拡張、管理を自動化するための、オープンソースのオーケストレーションプラットフォームである。図12.19に、そのプラットフォームの一例を示す。

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典
Figure 12.19 A cloud-native application is deployed in a Kubernetes environment. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図12.19 Kubernetes環境に配置されたクラウドネイティブアプリケーション。(出典:Copyright Rice University, OpenStax、CC BY 4.0ライセンス)
The workload refers to an application being run on Kubernetes. The Kubernetes master node includes the control plane, which has several important components, including a service controller, node controller, endpoint controller, replication controller, and scheduler. These components are responsible for features such as load balancing by distributing network requests across containers efficiently; self-healing containers by regularly checking them for good health and where failed containers are replaced or restarted automatically; auto-scaling containers by adding or removing them in accordance with demand; automated deployment to handle setting up and deploying containers to the cloud; storage management to handle the storage needs of all the containers; and handling networking between containers.
英語のヒント
ワークロードは、Kubernetesで実行されるアプリケーションを指す。Kubernetesのマスターノードには、コントロールプレーンがある。ここには、サービスコントローラー、ノードコントローラー、エンドポイントコントローラー、レプリケーションコントローラー、スケジューラーなど、重要な構成要素が含まれる。これらは、次のような機能を担当する。ネットワークの要求をコンテナー間に効率よく振り分ける負荷分散、コンテナーの状態を定期的に確認して故障したものを自動的に置き換えたり再起動したりする自己修復、需要に応じてコンテナーを追加・削除する自動拡張、クラウドへの設定と配置を行う自動デプロイメント、すべてのコンテナーの記憶領域の必要に対応するストレージ管理、そしてコンテナー間のネットワークの管理である。
The Kubernetes master node comprises several components, including the Kubernetes API server, which plays a crucial role in managing container-based workloads. Additionally, the Kubernetes cluster consists of worker nodes, each containing a kubelet. Working in tandem with the master node, the kubelet handles tasks like scheduling and ensuring the smooth operation of applications deployed within the worker nodes. Kubernetes has evolved into the preferred platform for deploying cloud-native applications. In this ecosystem, the microservices of a cloud-native application interact over the network, deployed and scaled within a Kubernetes cluster.
英語のヒント
Kubernetesのマスターノードは、いくつかの構成要素からなる。コンテナーを基にしたワークロードの管理に重要な役割を果たす、Kubernetes APIサーバーもその1つである。また、クラスターはワーカーノードからなり、各ノードにはkubeletがある。kubeletはマスターノードと連携し、スケジューリングや、ワーカーノード内へ配置したアプリケーションの円滑な動作の確保などを担当する。Kubernetesは、クラウドネイティブアプリケーションを配置するために優先されるプラットフォームへと発展してきた。この環境では、アプリケーションのマイクロサービスはネットワークを通じてやり取りし、Kubernetesクラスター内で配置・拡張される。
To deploy a cloud-native application in a Kubernetes environment, microservice containers, pulled from a registry, are deployed in pods. A pod is a small logical unit that runs a container within a worker node in the Kubernetes cluster. A cluster is a set of one or more nodes. Pods are a group of one or more containers with shared storage network resources and a specification for how the containers are run. Containers should only be scheduled together in a single pod if they are tightly coupled and need to share resources. Pods are ephemeral, meaning they are nonpermanent resources. Kubernetes manages the pods rather than the containers directly. The API server on the Kubernetes master node communicates with the worker node to deploy the container in a pod and start it up. Replicas of pods can be increased to scale the containerized microservice within it. If a pod fails, a new one is created. Kubernetes manages these deployments for the length of the deployment until the pod is deleted. In other words, it ensures that all pods and replicas are running.
英語のヒント
Kubernetes環境へクラウドネイティブアプリケーションを配置するには、レジストリから取得したマイクロサービスのコンテナーを、ポッドへ配置する。ポッドは、Kubernetesクラスターのワーカーノード内でコンテナーを実行する、小さな論理単位である。クラスターは、1つ以上のノードの集合である。ポッドは、記憶領域とネットワーク資源を共有する1つ以上のコンテナーと、その実行方法の仕様をまとめたものである。コンテナー同士が密結合で、資源を共有する必要がある場合に限って、同じ1つのポッド内へ一緒に配置すべきである。ポッドは一時的なものであり、恒久的な資源ではない。Kubernetesは、コンテナーを直接管理するのではなく、ポッドを管理する。マスターノードのAPIサーバーがワーカーノードと通信し、ポッド内へコンテナーを配置して起動する。ポッドの複製を増やせば、その中のコンテナー化されたマイクロサービスを拡張できる。ポッドが故障すると、新しいものが作られる。Kubernetesは、ポッドが削除されるまで、配置の期間を通じて管理を行う。つまり、すべてのポッドと複製が動作していることを保証する。
Service discovery is another important service provided by the Kubernetes platform. As pods are added and replicated, an internal IP address is provided for the pod, making the container accessible. Pods are ephemeral so IP addresses can change as new pods are created. Service registry and service discovery capabilities address this issue by creating Kubernetes services. A Kubernetes service is an abstraction, which defines a logical set of pods and a policy by which to access them in a reliable way.
英語のヒント
サービスディスカバリーも、Kubernetesプラットフォームが提供する重要なサービスである。ポッドを追加したり複製したりすると、内部IPアドレスが与えられ、コンテナーへアクセスできるようになる。ポッドは一時的なので、新しいポッドが作られると、IPアドレスが変わる場合がある。サービスレジストリとサービスディスカバリーの機能は、Kubernetesサービスを作ることで、この問題に対応する。Kubernetesサービスは、ポッドの論理的な集合と、その集合へ確実にアクセスするための方針を定義する抽象化である。
THINK IT THROUGH考えてみよう
Are Docker and Kubernetes Too Broad?DockerとKubernetesは広がりすぎているのか
Given the fact that many tools are available for containerization and container orchestration, what justifies the broad acceptance of Docker and Kubernetes to handle these respective functions?
英語のヒント
コンテナー化とコンテナーオーケストレーションに使えるツールが多数ある中で、それぞれの機能を担うDockerとKubernetesが広く受け入れられていることを、何が正当化するだろうか。
TerraformTerraform
Terraform is an open-source IaC tool used to build, update, and version cloud and on-premises resources. Some use cases for Terraform include managing Kubernetes clusters and provisioning resources in the cloud, among many others.
Terraformは、クラウドとオンプレミスの資源を構築・更新・バージョン管理する、オープンソースのIaCツールである。数多くの用途があり、Kubernetesクラスターの管理や、クラウド内の資源の準備などに使う。
GitLab and GitHub CI/CDGitLabとGitHubのCI/CD
GitLab is a cloud-based DevOps platform used to monitor, test, and deploy application code. GitLab includes a cloud-based Git repository as well as several DevOps features such as CI/CD, security, and application development tools. The CI/CD tool can be used to automate testing, deployment, and monitoring applications. GitLab can also be used for security analysis, static analysis, and unit testing. GitHub is a cloud-based developer platform used for software development, collaboration, and security. GitHub also includes a cloud-based Git repository and several DevOps features similar to GitLab.
英語のヒント
GitLabは、アプリケーションコードの監視・テスト・配置に使う、クラウドベースのDevOpsプラットフォームである。クラウド上のGitリポジトリに加え、CI/CD、セキュリティ、アプリケーション開発ツールなどのDevOps機能を含む。CI/CDツールは、テスト、配置、監視の自動化に使える。GitLabは、セキュリティ分析、静的解析、単体テストにも使える。GitHubは、ソフトウェアの開発、協同作業、セキュリティに使う、クラウドベースの開発者向けプラットフォームである。GitHubも、クラウド上のGitリポジトリと、GitLabに似たDevOps機能を持つ。