Tanzu Community Editionを使ってみた


Tanzu Community Editionがリリースされたのクラスターを作成してみました。

tanzu CLIのインストール

githubのvmware-tanzu/community-editionからtanzu CLIをダウンロードしてインストールします。
※ rootユーザーで実行するとinstallスクリプトの実行で怒られるので、一般ユーザーで実行する必要があります。

$ wget https://github.com/vmware-tanzu/community-edition/releases/download/v0.9.1/tce-linux-amd64-v0.9.1.tar.gz
$ tar zxvf tce-linux-amd64-v0.9.1.tar.gz
$ cd tce-linux-amd64-v0.9.1
$ ls
bin install.sh uninstall.sh
$ ./install.sh

tanzu CLIがインストールされます。プラグインもインストールされています。

$ which tanzu
/usr/local/bin/tanzu
$ tanzu version
version: v0.2.1
buildDate: 2021-09-29
sha: ceaa474
$ tanzu plugin list
  NAME                LATEST VERSION  DESCRIPTION                                                        REPOSITORY  VERSION  STATUS       
  builder             v0.2.1          Build Tanzu components                                             core-admin  v0.2.1   installed
  cluster             v0.2.1          Kubernetes cluster operations                                      core        v0.2.1   installed
  codegen                             Tanzu code generation tool                                         core-admin           not installed
  conformance         v0.9.0          Run Sonobuoy conformance tests against clusters                    tce         v0.9.1   installed
  diagnostics         v0.9.0          Cluster diagnostics                                                tce         v0.9.1   installed
  kubernetes-release  v0.2.1          Kubernetes release operations                                      core        v0.2.1   installed
  login               v0.2.1          Login to the platform                                              core        v0.2.1   installed
  management-cluster  v0.2.1          Kubernetes management cluster operations                           core        v0.2.1   installed
  package             v0.2.1          Tanzu package management                                           core        v0.2.1   installed
  pinniped-auth       v0.2.1          Pinniped authentication operations (usually not directly invoked)  core        v0.2.1   installed
  standalone-cluster  v0.9.0          Create clusters without a dedicated management cluster             tce         v0.9.1   installed
  test                                Test the CLI                                                       core-admin           not installed

tanzu CLIの利用

tanzu CLIでmanagement-clusterの作成を開始すると、Tanzu Kubernetes Gridと似た画面が表示されますが、Management Clusterのデプロイ先としてDockerが追加されています。

$ tanzu management-cluster create -b 192.168.0.190:8080 -u --browser=none
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'
ERROR 2021/10/04 22:24:27 svType != tvType; key=release, st=map[string]interface {}, tt=<nil>, sv=map[version:], tv=<nil>

Validating the pre-requisites...
Serving kickstart UI at http://192.168.0.190:8080

Standalone Clusterの作成

今回はDocker環境にStandalone ClusterとしてTanzu Kubernetes Clusterをデプロイしてみます。TKGにはなかった「standalone-cluster」オプションでdocker環境にクラスターを作成することが可能です。

$ tanzu standalone-cluster create mycluster -i docker
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/masanara/.kube-tkg/tmp/config_OZsVOxmQ
Installing providers on bootstrapper...
Start creating standalone cluster...
Saving standalone cluster kubeconfig into /home/masanara/.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 mycluster as 'mycluster-admin@mycluster'.
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

クラスターの利用

クラスターの作成が完了すると、クラスターにアクセスするためのcontextが追加されるので、kubectlコマンドでアクセス可能です。Standalone Cluterはmaster x 1 / node x 1で構成されています。

$ kubectl config get-contexts
CURRENT   NAME                        CLUSTER     AUTHINFO          NAMESPACE
          mycluster-admin@mycluster   mycluster   mycluster-admin
$ kubectl config use-context mycluster-admin@mycluster
Switched to context "mycluster-admin@mycluster".
$ kubectl get node -o wide
NAME                              STATUS   ROLES                  AGE     VERSION                               INTERNAL-IP   EXTERNAL-IP   OS-IMAGE           KERNEL-VERSION     CONTAINER-RUNTIME
mycluster-control-plane-vznm8     Ready    control-plane,master   2m34s   v1.21.2+vmware.1-360497810732255795   172.18.0.4    <none>        Ubuntu 20.04 LTS   5.4.0-88-generic   containerd://1.3.3-14-g449e9269
mycluster-md-0-6db57bb9bf-zldgp   Ready    <none>                 111s    v1.21.2+vmware.1-360497810732255795   172.18.0.5    <none>        Ubuntu 20.04 LTS   5.4.0-88-generic   containerd://1.3.3-14-g449e9269

dockerを確認すると、各ノードとAPI向けのharpoxyがコンテナとして起動していることがわかります。

$ docker ps -a
CONTAINER ID   IMAGE                                                         COMMAND                  CREATED         STATUS         PORTS                                  NAMES
54f90cae8e66   projects.registry.vmware.com/tkg/kind/node:v1.21.2_vmware.1   "/usr/local/bin/entr…"   4 minutes ago   Up 4 minutes                                          mycluster-md-0-6db57bb9bf-zldgp
ea153e9a2792   projects.registry.vmware.com/tkg/kind/node:v1.21.2_vmware.1   "/usr/local/bin/entr…"   5 minutes ago   Up 5 minutes   41789/tcp, 127.0.0.1:41789->6443/tcp   mycluster-control-plane-vznm8
f9be4b92159e   kindest/haproxy:v20210715-a6da3463                            "haproxy -sf 7 -W -d…"   5 minutes ago   Up 5 minutes   37947/tcp, 0.0.0.0:37947->6443/tcp     mycluster-lb

podはこんな感じで起動しています。

$ kubectl get pod -A
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE
kube-system   antrea-agent-hq2z5                                       2/2     Running   0          25m
kube-system   antrea-agent-w4psc                                       2/2     Running   0          25m
kube-system   antrea-controller-86f8988c5f-q76rs                       1/1     Running   0          25m
kube-system   coredns-8dcb5c56b-k86m4                                  1/1     Running   0          26m
kube-system   coredns-8dcb5c56b-s9j9l                                  1/1     Running   0          26m
kube-system   etcd-mycluster-control-plane-vznm8                       1/1     Running   0          26m
kube-system   kube-apiserver-mycluster-control-plane-vznm8             1/1     Running   0          26m
kube-system   kube-controller-manager-mycluster-control-plane-vznm8    1/1     Running   0          26m
kube-system   kube-proxy-pznjm                                         1/1     Running   0          26m
kube-system   kube-proxy-xsn9b                                         1/1     Running   0          25m
kube-system   kube-scheduler-mycluster-control-plane-vznm8             1/1     Running   0          26m
tkg-system    kapp-controller-6499b8866-x7fcn                          1/1     Running   0          25m
tkg-system    tanzu-capabilities-controller-manager-6ff97656b8-hfhq5   1/1     Running   0          25m
tkr-system    tkr-controller-manager-6bc455b5d4-5lvdl                  1/1     Running   0          25m

ローカルの環境でも簡単にTanzu Kubernetes Gridが試せそうです。