プリンキピア

第12章クラウドネイティブアプリケーション開発

PaaS Deployment of a Sample Cloud-Native Application Using VMWare TanzuVMWare Tanzuを使い、サンプルのクラウドネイティブアプリケーションをPaaSへ配置する

This section demonstrates how to use VMWare Tanzu deployment technology to launch a dashboard on AWS monitoring application metrics exposed by the Kuard (Kubernetes Up and Running Demo) application. Amazon Web Service (AWS) is an Amazon cloud computing platform that offers a wide range of services that allow customers to build, deploy, and manage applications and services in the cloud, and will be used in this example.
英語のヒント
ここでは、VMWare Tanzuの配置技術を使い、Kuard(Kubernetes Up and Running Demo)アプリケーションが公開する指標を監視するダッシュボードを、AWS上で起動する方法を示す。この例で使うAmazon Web Service(AWS)は、Amazonのクラウドコンピューティングのプラットフォームである。クラウド上のアプリケーションやサービスを、顧客が構築、配置、管理できる、幅広いサービスを提供する。
Set Up an Environment for VMWare TanzuVMWare Tanzuの環境を設定する
The first step is to create an AWS EC2 instance. This is a VM hosted in the cloud. Once the EC2 instance is provisioned, a set of tools need to be installed, including Docker, Kubernetes CLI tool, and other relevant package managers.
最初にAWS EC2インスタンスを作成する。クラウド上のVMである。用意できたら、Docker、KubernetesのCLIツール、関連するパッケージマネージャーなど、一連のツールをインストールする必要がある。
Create the EC2 Instance
EC2インスタンスを作成する
1. AWS Portal is a web-based console that allows customers to manage their cloud services and AWS subscriptions. In the AWS Portal, search for EC2 and click Launch Instance. Amazon Elastic Compute Cloud (EC2) is a cloud based, on-demand, compute platform that can be auto-scaled to meet demand.
英語のヒント
1. AWS Portalは、顧客がクラウドサービスとAWSのサブスクリプションを管理する、Webベースのコンソールである。AWS PortalでEC2を検索し、「Launch Instance」をクリックする。Amazon Elastic Compute Cloud(EC2)は、クラウドを基にした、必要時に使える計算プラットフォームであり、需要に合わせて自動で規模を調整できる。
2. Under Application and OS Images (Amazon Machine Image), select Ubuntu, and leave the remaining configurations to the default settings for this section.
2. 「Application and OS Images (Amazon Machine Image)」でUbuntuを選ぶ。この部分の残りの設定は、既定値のままにする。
3. Under the Instance type section, select t2.micro for the Instance type.
3. 「Instance type」で、インスタンスの種類としてt2.microを選ぶ。
4. Under the Key pair (login) section, click on Create new key pair.
4. 「Key pair (login)」で「Create new key pair」をクリックする。
5. Enter a value for Key pair name and keep the default settings. Click on Create key pair. The name used for this example is cnatanzu-private-key. Download the cnatanzu-private-key.pem file. This file is used to log in to the EC2 instance. The name provided, cnatanzu-private-key, is populated for the Key pair name in the Key pair (login) section.
英語のヒント
5. 「Key pair name」に名前を入力し、ほかは既定の設定を保つ。「Create key pair」をクリックする。この例の名前はcnatanzu-private-keyである。cnatanzu-private-key.pemをダウンロードする。このファイルを、EC2インスタンスへのログインに使う。入力したcnatanzu-private-keyという名前が、「Key pair (login)」の「Key pair name」に設定される。
6. Under the Networking settings section, select Create security group. Enable Allow SSH traffic from, Allow HTTPS traffic from the internet, Allow HTTP traffic from the internet. Set Anywhere to 0.0.0.0/0.
6. 「Networking settings」で「Create security group」を選ぶ。「Allow SSH traffic from」「Allow HTTPS traffic from the internet」「Allow HTTP traffic from the internet」を有効にする。「Anywhere」を0.0.0.0/0に設定する。
7. Under the Summary section, click Launch instance. Wait until the provisioning is complete. A Success message appears with the Instance ID. Click on the Instance ID link.
7. 「Summary」で「Launch instance」をクリックする。準備が完了するまで待つ。Instance IDとともに、成功を示すメッセージが表示される。Instance IDのリンクをクリックする。
8. Open a terminal and navigate to the directory where the cnatanzu-private-key.pem file was downloaded. Under Instance summary, copy the value from Public IPv4 DNS. Use the command to make an SSH connection to the EC2 instance by inserting the copied Public IPv4 DNS.
8. 端末を開き、cnatanzu-private-key.pemをダウンロードしたディレクトリへ移動する。「Instance summary」で「Public IPv4 DNS」の値をコピーする。次のコマンドにその値を入れ、EC2インスタンスへSSH接続する。
ssh -i nucamp-private-key.pem ubuntu@< EC2 public IPv4 DNS>
Install Homebrew (brew)
Homebrew(brew)をインストールする
Homebrew is an open-source package management system used to install and manage packages on MacOS and Linux operating systems. Homebrew, also referred to as “brew,” is used to install Octant later.
英語のヒント
Homebrewは、MacOSとLinuxで、パッケージをインストールし、管理するための、オープンソースのパッケージ管理システムである。「brew」とも呼ばれ、後でOctantをインストールするために使う。
1. Homebrew uses a compiler environment to build packages that may need to be built. The first step is to install a compiler environment with this command. The package build-essentials provides all required packages for the compiler environment. Run the command below to install the build-essentials package
1. Homebrewは、ビルドが必要なパッケージを、コンパイラー環境で構築する。最初に、次のコマンドでコンパイラー環境をインストールする。build-essentialsパッケージは、その環境に必要なパッケージをすべて提供する。次のコマンドを実行し、build-essentialsをインストールする。
sudo apt install build-essential
2. Run the following command to download the brew installation script that is used to install brew.
2. 次のコマンドで、brewをインストールするためのインストールスクリプトをダウンロードする。
curl -fsSL -o install.sh
3. Run the following command to launch the installation script.
3. 次のコマンドを実行し、インストールスクリプトを起動する。
/bin/bash install.sh
4. Once the installation script is complete, run the following two commands to add brew to the PATH environment variable. This makes the command brew recognizable in the EC2 instance.
英語のヒント
4. インストールスクリプトが完了したら、次の2つのコマンドを実行し、PATH環境変数へbrewを追加する。これで、EC2インスタンスがbrewコマンドを認識できるようになる。
(echo; echo 'eval \"$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> \
/home/ubuntu/.profile eval \"$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
5. Confirm brew was added to the PATH environment variable. Type the command brew to confirm the brew help menu is printed to the console. This indicates that brew was installed successfully.
5. brewがPATH環境変数へ追加されたことを確認する。brewコマンドを入力し、コンソールにヘルプメニューが表示されることを確かめる。これで、正常にインストールされたと分かる。
Install and Set Up Docker
Dockerをインストールし、設定する
Tanzu requires the docker engine to be up and running. Docker Engine is an open-source containerization platform used to build Docker images and manage Docker containers. To install the Docker engine, Advanced Package Tool (apt) is used. Apt is a packaging tool used to install new packages and update existing packages.
Tanzuには、Dockerエンジンが起動し、動作していることが必要である。Docker Engineは、Dockerイメージを構築し、Dockerコンテナーを管理する、オープンソースのコンテナー化プラットフォームである。インストールには、Advanced Package Tool(apt)を使う。aptは、新しいパッケージのインストールと、既存パッケージの更新を行うツールである。
1. Run the command to update the apt utility itself before installing Docker.
1. Dockerをインストールする前に、次のコマンドでaptユーティリティー自体を更新する。
sudo apt update
2. Run the command below to install the following packages as prerequisites for installing Docker:
英語のヒント
2. Dockerのインストールの前提として、次のパッケージを入れるコマンドを実行する。
◦ apt-transport-https, which allows the package manager to transfer files over the HTTPS protocol
◦ apt-transport-https:パッケージマネージャーが、HTTPSプロトコルでファイルを転送できるようにする。
◦ ca-certificates, which makes available common Certificate Authority certificates to aid in verifying the security of connections
◦ ca-certificates:一般的な認証局の証明書を利用できるようにし、接続の安全性の確認を助ける。
◦ curl, which is used for transferring data to or from a server
◦ curl:サーバーとの間でデータを送受信するために使う。
◦ software-properties-common, which is a package to help manage the software installations
◦ software-properties-common:ソフトウェアのインストールの管理を支援するパッケージ。
sudo apt install apt-transport-https ca-certificates curl software-properties-common
3. Download a public key file from Docker with the command below. The public key file is then added to a list of trusted keys managed by apt.
英語のヒント
3. 次のコマンドで、Dockerから公開鍵ファイルをダウンロードする。そのファイルを、aptが管理する信頼済みキーの一覧へ追加する。
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
4. Run the add-apt-repository command below to add the external Docker repository to the apt sources list.
4. 次のadd-apt-repositoryコマンドを実行し、外部のDockerリポジトリをaptのソース一覧へ追加する。
sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable\""
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
5. After making the changes to the apt package information in the previous steps, update the apt index with this command.
5. 前の手順でaptのパッケージ情報を変更したので、次のコマンドでaptの索引を更新する。
sudo apt update
6. Run the command below to install Docker on the EC2 instance:
6. 次のコマンドで、EC2インスタンスにDockerをインストールする。
sudo apt install docker-ce
7. Run the next three commands to configure Docker and install Docker Compose.
7. 次の3つのコマンドで、Dockerを設定し、Docker Composeをインストールする。
◦ Add the current ubuntu user to the docker group.
◦ 現在のubuntuユーザーをdockerグループへ追加する。
sudo usermod -aG docker ${USER}
◦ Download Docker Compose. Docker Compose is a tool used for defining, via descriptor files, and managing applications that consist of multiple Docker containers.
英語のヒント
◦ Docker Composeをダウンロードする。Docker Composeは、複数のDockerコンテナーからなるアプリケーションを、記述ファイルを介して定義し、管理するツールである。
sudo curl -L \
"https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" \
-o /usr/local/bin/docker-compose
◦ Run this command to change the permissions of the downloaded docker-compose file to an executable so that it can be run.
英語のヒント
◦ 次のコマンドで、ダウンロードしたdocker-composeファイルの権限を変更し、実行できるようにする。
sudo chmod +x /usr/local/bin/docker-compose
8. Confirm that both docker and docker-compose were installed. Run these commands and confirm that the versions for docker and docker-compose are displayed to the console.
8. dockerとdocker-composeの両方がインストールされたことを確認する。次のコマンドを実行し、両方のバージョンがコンソールに表示されることを確かめる。
docker -v
docker-compose -v
9. Run the command below to start the Docker engine in the EC2 instance.
9. 次のコマンドで、EC2インスタンスのDockerエンジンを起動する。
sudo systemctl start docker
10. Run the command below to test if Docker was installed correctly.
10. 次のコマンドを実行し、Dockerが正しくインストールされたか確認する。
sudo docker run hello-world
Install and Set Up Kubectl
Kubectlをインストールし、設定する
Tanzu requires kubectl. The Kubernetes command-line tool, kubectl, is used to interact with the Tanzu Kubernetes cluster.
Tanzuにはkubectlが必要である。Kubernetesのコマンドラインツールkubectlを使い、Tanzu Kubernetesクラスターとやり取りする。
1. Download the latest release of kubectl with the command below.
1. 次のコマンドで、kubectlの最新リリースをダウンロードする。
curl -LO \"https://dl.k8s.io/release/$(curl -L -s \
https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
2. Install kubectl with the command below.
2. 次のコマンドで、kubectlをインストールする。
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
3. Run the following commands to change the permissions to kubectl file to executable so that it can be run and copy it to the ~/.local/bin directory.
英語のヒント
3. 次のコマンドを実行し、kubectlファイルのアクセス権を実行可能に変えて、~/.local/binディレクトリーへコピーする。
chmod +x kubectl
mkdir -p ~/.local/bin
mv ./kubectl ~/.local/bin/kubectl
4. Append ~/.local/bin to the $PATH environment variable. Edit the ~/.bashrc file and add the following line to the end of it.
英語のヒント
4. 環境変数$PATHに~/.local/binを追加する。~/.bashrcファイルを編集し、末尾に次の行を加える。
export PATH=$PATH:~/.local/bin
5. Save and close the file. Apply the changes by running the following command:
5. ファイルを保存して閉じる。次のコマンドを実行し、変更を反映する。
source ~/.bashrc
6. Confirm, by running the command kubectl, that it can be executed. The kubectl help menu should display in the console. This indicates that it was installed successfully.
英語のヒント
6. kubectlコマンドを実行して、実行できることを確認する。コンソールにkubectlのヘルプメニューが表示されるはずである。これは、インストールが成功したことを示す。
Install Tanzu
Tanzuをインストールする
1. Install jq as a support package for Tanzu with the following commands:
1. 次のコマンドで、Tanzuを支えるパッケージとしてjqをインストールする。
sudo apt-get update
sudo apt-get install jq
2. Install xdg-utils as a support package for Tanzu with the following command:
2. 次のコマンドで、Tanzuを支えるパッケージとしてxdg-utilsをインストールする。
sudo apt-get install --reinstall xdg-utils
3. Ensure the kubectl version is compatible with the Tanzu version.
英語のヒント
3. kubectlの版が、Tanzuの版と互換性を持つことを確かめる。
curl -H \"Accept: application/vnd.github.v3.raw" -L \
https://api.github.com/repos/vmware-tanzu/community-edition/contents/hack/get-tce-release.sh\
| bash -s v0.10.0 linux
4. Unpack the gzip file and install Tanzu using the provided shell script with the command below.
英語のヒント
4. gzipファイルを展開し、提供されているシェルスクリプトを使って、次のコマンドでTanzuをインストールする。
tar xzvf tce-linux-amd64-v0.10.0.tar.gz
5. Navigate into the tce-linux-amd64-v0.10.0/ directory and run the installation shell script with the command below.
5. tce-linux-amd64-v0.10.0/ディレクトリーへ移動し、次のコマンドでインストール用のシェルスクリプトを実行する。
/install.sh
6. Confirm Tanzu was installed successfully. Run the command tanzu. The Tanzu help menu should be displayed in the console.
英語のヒント
6. Tanzuが正しくインストールされたことを確認する。tanzuコマンドを実行すると、コンソールにTanzuのヘルプメニューが表示されるはずである。