2021/10/04 に VMware の Kubernetes(k8s) ディストリビューション Tanzu に Commpunity Edition が設定され、無償で利用出来る様になりました。
Tanzu をホームラボで試すにはライセンス的に厳しかったのですが、これからは気軽に試せますね。
Introducing VMware Tanzu Community Edition によると、VMware Tanzu Community Editionでは、下記の様にk8sを利用するのに必要な機能を一通り網羅して提供してくれる様です。
今回は、VMware Tanzu Community Edition(TCE) を用いて Standalone Clusters
を Docker
方式で仮想マシン上に構築してみます。
基本的には公式ドキュメントを確認して手順に沿って実施しています。
環境
設定対象
- Ubuntu 20.04.2 LTS
- 設置先のdocker hostとして利用(リモートのサーバー)
- docker hostとしてセットアップ済みのモノを用意
- VMware Tanzu Community Edition V0.9.1 (2021/10/16時点で最新)
操作元
- Windows 10
- RLogin 2.26
準備:システム/ハードウエア要件を確認
Support Matrix を確認する
今回は Ubuntu(Linux)上に環境を構築する
Linux Local Bootstrap Machine Prerequisites
- Arch: x86; ARM is currently unsupported
- RAM: 6 GB
- CPU: 2
- アーキテクチャ、メモリサイズ、CPU個数を確認
- Arch
x86_64
、 RAM8GB
、 CPU4
である事を確認% cat /etc/issue.net Ubuntu 20.04.3 LTS % uname -p x86_64 % free -m total used free shared buff/cache available Mem: 7933 347 6706 1 880 7330 Swap: 4061 0 4061 % grep processor /proc/cpuinfo | wc -l 4
- Arch
Check and set the cgroup
- Cgroups v1 を利用している事を確認
% docker infdocker info | grep -i cgroup Cgroup Driver: cgroupfs Cgroup Version: 1 WARNING: No swap limit support
Infrastructure Providers (Target Platforms)
- Local Docker
- 6 GB of RAM and 4 CPUs (with no other containers running).
- 15 GB of local machine disk storage for images
- セットアップ先の Docker 環境のスペックを確認
% docker system info Client: Context: default Debug Mode: false Plugins: app: Docker App (Docker Inc., v0.9.1-beta3) buildx: Build with BuildKit (Docker Inc., v0.6.3-docker) scan: Docker Scan (Docker Inc., v0.9.0) Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 20.10.11 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 1 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc Default Runtime: runc Init Binary: docker-init containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d runc version: v1.0.2-0-g52b36a2 init version: de40ad0 Security Options: apparmor seccomp Profile: default Kernel Version: 5.4.0-91-generic Operating System: Ubuntu 20.04.3 LTS OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 7.748GiB Name: XXXHost00X ID: DR36:L6VE:KTVW:GQHN:4CCF:4XEC:52D6:5FVA:7NBC:NDBV:63O6:DH2P Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false WARNING: No swap limit support
セットアップ
Standalone Clusters で Linux かつ Docker のセットアップ手順を確認する
Linux Local Bootstrap Machine Prerequisites の環境確認は既に実施済みなので、Installation Procedure を確認
- 事前条件
- You must download and install the latest version of kubectl. For more information, see Install and Set Up kubectl on Linux in the Kubernetes documentation.
- You must download and install the latest version of docker. For more information, see Install Docker Engine in the Docker documentation.
- docker はインストール済み環境なので、 kubectl のセットアップが必要ですが、この後の手順で対応してそうなので、そちらを実施する
Option 2: Curl GitHub release の手順に沿って実施
- ダウンロードするファイルを確認
V0.9.1
が最新バージョンである事を確認- Download recent releases of VMware Tanzu Community Edition here.
- Ubuntu 上へダウンロード
% wget https://github.com/vmware-tanzu/community-edition/releases/download/v0.9.1/tce-linux-amd64-v0.9.1.tar.gz ..... tce-linux-amd64-v0.9.1.tar.gz 100%[=======================================>] 170.33M 11.4MB/s in 16s 2021-10-15 20:30:35 (10.6 MB/s) - 'tce-linux-amd64-v0.9.1.tar.gz' saved [178604663/178604663]
- ダウンロードファイル解凍
% tar zxvf tce-linux-amd64-v0.9.1.tar.gz tce-linux-amd64-v0.9.1/ tce-linux-amd64-v0.9.1/bin/ tce-linux-amd64-v0.9.1/bin/tanzu tce-linux-amd64-v0.9.1/bin/tanzu-plugin-cluster tce-linux-amd64-v0.9.1/bin/tanzu-plugin-kubernetes-release tce-linux-amd64-v0.9.1/bin/tanzu-plugin-login tce-linux-amd64-v0.9.1/bin/tanzu-plugin-package tce-linux-amd64-v0.9.1/bin/tanzu-plugin-pinniped-auth tce-linux-amd64-v0.9.1/bin/tanzu-plugin-management-cluster tce-linux-amd64-v0.9.1/bin/tanzu-plugin-builder tce-linux-amd64-v0.9.1/bin/tanzu-plugin-standalone-cluster tce-linux-amd64-v0.9.1/bin/tanzu-plugin-conformance tce-linux-amd64-v0.9.1/bin/tanzu-plugin-diagnostics tce-linux-amd64-v0.9.1/install.sh tce-linux-amd64-v0.9.1/uninstall.sh
- インストーラー起動
% cd tce-linux-amd64-v0.9.1/ % sudo ./install.sh /bin/bash: warning: setlocale: LC_ALL: cannot change locale (ja_JP.UTF-8) + ALLOW_INSTALL_AS_ROOT= + [[ 1000 -eq 0 ]] +++ dirname ./install.sh ++ cd . ++ pwd + MY_DIR=/home/ysaotome/tce-linux-amd64-v0.9.1 ++ uname + BUILD_OS=Linux + case "${BUILD_OS}" in + XDG_DATA_HOME=/home/ysaotome/.local/share + echo /home/ysaotome/.local/share /home/ysaotome/.local/share ++ command -v tanzu + TANZU_BIN_PATH= + [[ -n '' ]] + TANZU_BIN_PATH=/usr/local/bin + [[ :/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ysaotome/bin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin: == *\:\/\h\o\m\e\/\y\s\a\o\t\o\m\e\/\b\i\n\:* ]] + [[ -d /home/ysaotome/bin ]] + echo Installing tanzu cli to /usr/local/bin Installing tanzu cli to /usr/local/bin + sudo install /home/ysaotome/tce-linux-amd64-v0.9.1/bin/tanzu /usr/local/bin + mkdir -p /home/ysaotome/.local/share/tanzu-cli + for plugin in "${MY_DIR}"/bin/tanzu-plugin* + install /home/ysaotome/tce-linux-amd64-v0.9.1/bin/tanzu-plugin-builder /home/ysaotome/.local/share/tanzu-cli + for plugin in "${MY_DIR}"/bin/tanzu-plugin* + install /home/ysaotome/tce-linux-amd64-v0.9.1/bin/tanzu-plugin-cluster /home/ysaotome/.local/share/tanzu-cli + for plugin in "${MY_DIR}"/bin/tanzu-plugin* + install /home/ysaotome/tce-linux-amd64-v0.9.1/bin/tanzu-plugin-conformance /home/ysaotome/.local/share/tanzu-cli + for plugin in "${MY_DIR}"/bin/tanzu-plugin* + install /home/ysaotome/tce-linux-amd64-v0.9.1/bin/tanzu-plugin-diagnostics /home/ysaotome/.local/share/tanzu-cli + for plugin in "${MY_DIR}"/bin/tanzu-plugin* + install /home/ysaotome/tce-linux-amd64-v0.9.1/bin/tanzu-plugin-kubernetes-release /home/ysaotome/.local/share/tanzu-cli + for plugin in "${MY_DIR}"/bin/tanzu-plugin* + install /home/ysaotome/tce-linux-amd64-v0.9.1/bin/tanzu-plugin-login /home/ysaotome/.local/share/tanzu-cli + for plugin in "${MY_DIR}"/bin/tanzu-plugin* + install /home/ysaotome/tce-linux-amd64-v0.9.1/bin/tanzu-plugin-management-cluster /home/ysaotome/.local/share/tanzu-cli + for plugin in "${MY_DIR}"/bin/tanzu-plugin* + install /home/ysaotome/tce-linux-amd64-v0.9.1/bin/tanzu-plugin-package /home/ysaotome/.local/share/tanzu-cli + for plugin in "${MY_DIR}"/bin/tanzu-plugin* + install /home/ysaotome/tce-linux-amd64-v0.9.1/bin/tanzu-plugin-pinniped-auth /home/ysaotome/.local/share/tanzu-cli + for plugin in "${MY_DIR}"/bin/tanzu-plugin* + install /home/ysaotome/tce-linux-amd64-v0.9.1/bin/tanzu-plugin-standalone-cluster /home/ysaotome/.local/share/tanzu-cli + mkdir -p /home/ysaotome/.local/share/tce + install /home/ysaotome/tce-linux-amd64-v0.9.1/uninstall.sh /home/ysaotome/.local/share/tce + TANZU_PLUGIN_CACHE=/home/ysaotome/.cache/tanzu/catalog.yaml + [[ -n /home/ysaotome/.cache/tanzu/catalog.yaml ]] + echo 'Removing old plugin cache from /home/ysaotome/.cache/tanzu/catalog.yaml' Removing old plugin cache from /home/ysaotome/.cache/tanzu/catalog.yaml + rm -f /home/ysaotome/.cache/tanzu/catalog.yaml + tanzu init ./install.sh: line 72: tanzu: command not found ++ tanzu plugin repo list ./install.sh: line 73: tanzu: command not found ++ grep tce + TCE_REPO= + [[ -z '' ]] + tanzu plugin repo add --name tce --gcp-bucket-name tce-tanzu-cli-plugins --gcp-root-path artifacts ./install.sh: line 75: tanzu: command not found ++ grep core-admin ++ tanzu plugin repo list ./install.sh: line 77: tanzu: command not found + TCE_REPO= + [[ -z '' ]] + tanzu plugin repo add --name core-admin --gcp-bucket-name tce-tanzu-cli-framework-admin --gcp-root-path artifacts-admin ./install.sh: line 79: tanzu: command not found + echo 'Installation complete!' Installation complete!
- kubectl コマンドのセットアップ
% curl -LO https://dl.k8s.io/release/v1.20.1/bin/linux/amd64/kubectl % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 154 100 154 0 0 503 0 --:--:-- --:--:-- --:--:-- 503 100 38.3M 100 38.3M 0 0 9205k 0 0:00:04 0:00:04 --:--:-- 10.2M % sudo instasudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl % kubectl version Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.1", GitCommit:"c4d752765b3bbac2237bf87cf0b1c2e307844666", GitTreeState:"clean", BuildDate:"2020-12-18T12:09:25Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
Tanzu コマンドの動作確認
- Tanzu Community Editionインストーラーインターフェイスを確認する
% tanzu standalone-cluster create -b xxx.xxx.xxx.xxx:8080 --ui Validating the pre-requisites... Serving kickstart UI at http://xxx.xxx.xxx.xxx:8080 unable to open browser: exec: "xdg-open": executable file not found in $PATH
- ブラウザで表示された URL を開く
このままGUIからセットアップも出来そうだったけど、ドキュメントに沿ってこの後の手順もコマンドラインで実施
Creating Clusters の Docker の手順に沿って実施
- 対象 Ubuntu 上で Docker コンテナが稼働してない事とコンテナ、イメージ、ストレージが真っさらな事を確認
% docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES % docker system prune -a --volumes WARNING! This will remove: - all stopped containers - all networks not used by at least one container - all volumes not used by at least one container - all images without at least one container associated to them - all build cache Are you sure you want to continue? [y/N] y Total reclaimed space: 0B
- tanzu コマンドで
test-k8s-cluster
という名称のスタンドアロンクラスターをDocker上に作成(この環境で初回実行が5分程度で完了)% tanzu standalone-cluster create -i docker test-k8s-cluster Downloading TKG compatibility file from 'projects.registry.vmware.com/tkg/framework-zshippable/tkg-compatibility' Downloading the TKG Bill of Materials (BOM) file from 'projects.registry.vmware.com/tkg/tkg-bom:v1.4.0' Downloading the TKr Bill of Materials (BOM) file from 'projects.registry.vmware.com/tkg/tkr-bom:v1.21.2_vmware.1-tkg.1' Validating the pre-requisites... Identity Provider not configured. Some authentication features won't work. Setting up standalone cluster... Validating configuration... Using infrastructure provider docker:v0.3.23 Generating cluster configuration... Setting up bootstrapper... Bootstrapper created. Kubeconfig: /home/ysaotome/.kube-tkg/tmp/config_SlqZFVMz Installing providers on bootstrapper... Start creating standalone cluster... Saving standalone cluster kubeconfig into /home/ysaotome/.kube/config Waiting for bootstrap cluster to get ready for save ... Waiting for addons installation... Moving all Cluster API objects from bootstrap cluster to standalone cluster... Context set for standalone cluster test-k8s-cluster as 'test-k8s-cluster-admin@test-k8s-cluster'. Cleaning up unneeded resources (for standalone clusters)... Standalone cluster created! You can now use Kubectl to access your cluster: kubectl get pods -A You can also delete the cluster by running the following: tanzu standalone-cluster delete [name] Some addons might be getting installed! Check their status by running the following: kubectl get apps -A
動作確認
- クラスタへ接続する kubectl コンテキストを設定
% kubectl config use-context test-k8s-cluster-admin@test-k8s-cluster Switched to context "test-k8s-cluster-admin@test-k8s-cluster".
- kubectl の設定状態を確認
% kubectl config get-contexts CURRENT NAME CLUSTER AUTHINFO NAMESPACE * test-k8s-cluster-admin@test-k8s-cluster test-k8s-cluster test-k8s-cluster-admin
- kubectl でクラスタのAPIサーバーにアクセスできることを確認
% kubectl get pods -A NAMESPACE NAME READY STATUS RESTARTS AGE kube-system antrea-agent-gqtkl 2/2 Running 0 4m11s kube-system antrea-agent-wn42v 2/2 Running 0 4m11s kube-system antrea-controller-86f8988c5f-zrwsx 1/1 Running 0 4m11s kube-system coredns-8dcb5c56b-gpf8b 1/1 Running 0 4m55s kube-system coredns-8dcb5c56b-prb52 1/1 Running 0 4m55s kube-system etcd-test-k8s-cluster-control-plane-p284d 1/1 Running 0 4m58s kube-system kube-apiserver-test-k8s-cluster-control-plane-p284d 1/1 Running 0 4m58s kube-system kube-controller-manager-test-k8s-cluster-control-plane-p284d 1/1 Running 0 5m6s kube-system kube-proxy-r7tfm 1/1 Running 0 4m28s kube-system kube-proxy-rzcdc 1/1 Running 0 4m55s kube-system kube-scheduler-test-k8s-cluster-control-plane-p284d 1/1 Running 0 4m58s tkg-system kapp-controller-6499b8866-b5kft 1/1 Running 0 4m32s tkg-system tanzu-capabilities-controller-manager-6ff97656b8-nhvpj 1/1 Running 0 4m51s tkr-system tkr-controller-manager-6bc455b5d4-2znwh 1/1 Running 0 4m51s
無事、リモートの Ubuntu 上に k8s クラスタを作成し、 kubectl からアクセス出来る事を確認
最後に
かなり簡単に環境構築をして利用出来る事が確認できました。
Tanzu 由来のパッケージ管理機能も使い込んでみたい所。あと、 GitLab の k8s 管理機能から使ってみたいですね。