VMware vSphere Tanzu部署_13_创建TKC集群
整体文章
VMware vSphere Tanzu部署_01_Tanzu架构设计
VMware vSphere Tanzu部署_02_ESXI系统安装
VMware vSphere Tanzu部署_03_vCenter部署
VMware vSphere Tanzu部署_04_vCenter管理esxi并迁移网卡到DSwitch
VMware vSphere Tanzu部署_05_vyos虚拟路由器部署
VMware vSphere Tanzu部署_06_haproxy部署
VMware vSphere Tanzu部署_07_tanzu存储策略配置
VMware vSphere Tanzu部署_08_配置tanzu为单节点
VMware vSphere Tanzu部署_09_配置tanzu内容库
VMware vSphere Tanzu部署_10_开启Tanzu功能
VMware vSphere Tanzu部署_11_创建TKC命名空间
VMware vSphere Tanzu部署_12_下载使用Tanzu-K8S工具
VMware vSphere Tanzu部署_13_创建TKC集群
VMware vSphere Tanzu部署_14_部署容器应用
VMware vSphere Tanzu部署_15_TKG Cluster获取永不过期Token
VMware vSphere Tanzu部署_16_TKC集群节点VM密码获取
1.登录tanzu集群
登录语法为:
kubectl vsphere login --server=<ip> \
--vsphere-username <username> \
--insecure-skip-tls-verify
- 登录示例
jianhua@napp:~$ kubectl vsphere login --server=192.168.203.194 --vsphere-username administrator@vsphere.local --insecure-skip-tls-verify
KUBECTL_VSPHERE_PASSWORD environment variable is not set. Please enter the password below
Password:
Logged in successfully.
You have access to the following contexts:
192.168.203.194
tkc-01
If the context you wish to use is not in this list, you may need to try
logging in again later, or contact your cluster administrator.
To change context, use `kubectl config use-context <workload name>`
jianhua@napp:~$
2.tanzu内的信息查看
2.1.查看可部署的virtualmachineclass
$ kubectl get virtualmachineclass
- 查询示例
# 查看virtualmachineclass
jianhua@napp:~$ kubectl get virtualmachineclass
NAME CPU MEMORY AGE
best-effort-small 2 4Gi 31m
best-effort-xsmall 2 2Gi 31m
jianhua@napp:~$
2.2.查看存储策略
$ kubectl get storageclasses.storage
- 查询示例
# 查看storageclasses
jianhua@napp:~$ kubectl get storageclasses.storage
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
tanzu-storage-policy csi.vsphere.vmware.com Delete Immediate true 35m
jianhua@napp:~$
2.3.查看可部署的tkc版本
kubectl get tkr
- 查询示例
jianhua@napp:~$ kubectl get tkr
NAME VERSION READY COMPATIBLE CREATED UPDATES AVAILABLE
v1.16.12---vmware.1-tkg.1.da7afe7 1.16.12+vmware.1-tkg.1.da7afe7 False False 76m
v1.16.14---vmware.1-tkg.1.ada4837 1.16.14+vmware.1-tkg.1.ada4837 False False 75m
v1.16.8---vmware.1-tkg.3.60d2ffd 1.16.8+vmware.1-tkg.3.60d2ffd False False 76m
v1.17.11---vmware.1-tkg.1.15f1e18 1.17.11+vmware.1-tkg.1.15f1e18 False False 76m
v1.17.11---vmware.1-tkg.2.ad3d374 1.17.11+vmware.1-tkg.2.ad3d374 False False 76m
v1.17.13---vmware.1-tkg.2.2c133ed 1.17.13+vmware.1-tkg.2.2c133ed False False 76m
v1.17.17---vmware.1-tkg.1.d44d45a 1.17.17+vmware.1-tkg.1.d44d45a False False 75m
v1.17.7---vmware.1-tkg.1.154236c 1.17.7+vmware.1-tkg.1.154236c False False 76m
v1.17.8---vmware.1-tkg.1.5417466 1.17.8+vmware.1-tkg.1.5417466 False False 76m
v1.18.10---vmware.1-tkg.1.3a6cd48 1.18.10+vmware.1-tkg.1.3a6cd48 False False 76m
v1.18.15---vmware.1-tkg.1.600e412 1.18.15+vmware.1-tkg.1.600e412 False False 76m
v1.18.15---vmware.1-tkg.2.ebf6117 1.18.15+vmware.1-tkg.2.ebf6117 False False 76m
v1.18.19---vmware.1-tkg.1.17af790 1.18.19+vmware.1-tkg.1.17af790 False False 75m
v1.18.5---vmware.1-tkg.1.c40d30d 1.18.5+vmware.1-tkg.1.c40d30d False False 75m
v1.19.11---vmware.1-tkg.1.9d9b236 1.19.11+vmware.1-tkg.1.9d9b236 False False 75m
v1.19.14---vmware.1-tkg.1.8753786 1.19.14+vmware.1-tkg.1.8753786 False False 76m
v1.19.16---vmware.1-tkg.1.df910e2 1.19.16+vmware.1-tkg.1.df910e2 False False 75m
v1.19.7---vmware.1-tkg.1.fc82c41 1.19.7+vmware.1-tkg.1.fc82c41 False False 76m
v1.19.7---vmware.1-tkg.2.f52f85a 1.19.7+vmware.1-tkg.2.f52f85a False False 76m
v1.20.12---vmware.1-tkg.1.b9a42f3 1.20.12+vmware.1-tkg.1.b9a42f3 False False 76m
v1.20.2---vmware.1-tkg.1.1d4f79a 1.20.2+vmware.1-tkg.1.1d4f79a False False 76m
v1.20.2---vmware.1-tkg.2.3e10706 1.20.2+vmware.1-tkg.2.3e10706 False False 76m
v1.20.7---vmware.1-tkg.1.7fb9067 1.20.7+vmware.1-tkg.1.7fb9067 False False 75m
v1.20.8---vmware.1-tkg.2 1.20.8+vmware.1-tkg.2 False False 76m
v1.20.9---vmware.1-tkg.1.a4cee5b 1.20.9+vmware.1-tkg.1.a4cee5b False False 76m
v1.21.2---vmware.1-tkg.1.ee25d55 1.21.2+vmware.1-tkg.1.ee25d55 False False 76m
v1.21.6---vmware.1-tkg.1 1.21.6+vmware.1-tkg.1 False False 76m
v1.21.6---vmware.1-tkg.1.b3d708a 1.21.6+vmware.1-tkg.1.b3d708a False False 75m
v1.22.9---vmware.1-tkg.1 1.22.9+vmware.1-tkg.1 False False 76m [1.23.8+vmware.3-tkg.1.ubuntu]
v1.22.9---vmware.1-tkg.1.cc71bc8 1.22.9+vmware.1-tkg.1.cc71bc8 False False 76m [1.23.8+vmware.3-tkg.1]
v1.23.15---vmware.1 1.23.15+vmware.1 False False 76m [1.24.11+vmware.1-fips.1-tkg.1.ubuntu 1.23.8+vmware.3-tkg.1.ubuntu]
v1.23.8---vmware.1-tkg.1 1.23.8+vmware.1-tkg.1 False False 76m
v1.23.8---vmware.3-tkg.1 1.23.8+vmware.3-tkg.1 True True 76m [1.24.11+vmware.1-fips.1-tkg.1]
v1.23.8---vmware.3-tkg.1.ubuntu 1.23.8+vmware.3-tkg.1.ubuntu True True 76m [1.24.11+vmware.1-fips.1-tkg.1.ubuntu]
v1.24.11---vmware.1-fips.1-tkg.1 1.24.11+vmware.1-fips.1-tkg.1 True True 76m [1.25.13+vmware.1-fips.1-tkg.1]
v1.24.11---vmware.1-fips.1-tkg.1.ubuntu 1.24.11+vmware.1-fips.1-tkg.1.ubuntu True True 76m [1.25.13+vmware.1-fips.1-tkg.1.ubuntu]
v1.24.9---vmware.1 1.24.9+vmware.1 False False 76m [1.25.13+vmware.1-fips.1-tkg.1.ubuntu 1.24.11+vmware.1-fips.1-tkg.1.ubuntu]
v1.25.13---vmware.1-fips.1-tkg.1 1.25.13+vmware.1-fips.1-tkg.1 True True 76m [1.26.12+vmware.2-fips.1-tkg.2]
v1.25.13---vmware.1-fips.1-tkg.1.ubuntu 1.25.13+vmware.1-fips.1-tkg.1.ubuntu True True 76m [1.26.12+vmware.2-fips.1-tkg.2.ubuntu]
v1.25.7---vmware.3-fips.1 1.25.7+vmware.3-fips.1 False False 76m [1.26.12+vmware.2-fips.1-tkg.2.ubuntu 1.25.13+vmware.1-fips.1-tkg.1.ubuntu]
v1.26.10---vmware.1-fips.1-tkg.1 1.26.10+vmware.1-fips.1-tkg.1 True True 75m [1.27.10+vmware.1-fips.1-tkg.1 1.26.12+vmware.2-fips.1-tkg.2]
v1.26.10---vmware.1-fips.1-tkg.1.ubuntu 1.26.10+vmware.1-fips.1-tkg.1.ubuntu True True 76m [1.27.10+vmware.1-fips.1-tkg.1.ubuntu 1.26.12+vmware.2-fips.1-tkg.2.ubuntu]
v1.26.12---vmware.2-fips.1-tkg.2 1.26.12+vmware.2-fips.1-tkg.2 True True 76m [1.27.10+vmware.1-fips.1-tkg.1]
v1.26.12---vmware.2-fips.1-tkg.2.ubuntu 1.26.12+vmware.2-fips.1-tkg.2.ubuntu True True 75m [1.27.10+vmware.1-fips.1-tkg.1.ubuntu]
v1.26.13---vmware.1-fips.1 1.26.13+vmware.1-fips.1 False False 76m [1.27.10+vmware.1-fips.1-tkg.1 1.26.12+vmware.2-fips.1-tkg.2]
v1.26.5---vmware.2-fips.1 1.26.5+vmware.2-fips.1 False False 76m [1.27.10+vmware.1-fips.1-tkg.1.ubuntu 1.26.12+vmware.2-fips.1-tkg.2.ubuntu]
v1.27.10---vmware.1-fips.1-tkg.1 1.27.10+vmware.1-fips.1-tkg.1 True True 76m
v1.27.10---vmware.1-fips.1-tkg.1.ubuntu 1.27.10+vmware.1-fips.1-tkg.1.ubuntu True True 75m
v1.27.11---vmware.1-fips.1 1.27.11+vmware.1-fips.1 False False 76m [1.27.10+vmware.1-fips.1-tkg.1]
v1.27.6---vmware.1-fips.1-tkg.1 1.27.6+vmware.1-fips.1-tkg.1 True True 76m [1.27.10+vmware.1-fips.1-tkg.1]
v1.27.6---vmware.1-fips.1-tkg.1.ubuntu 1.27.6+vmware.1-fips.1-tkg.1.ubuntu True True 75m [1.27.10+vmware.1-fips.1-tkg.1.ubuntu]
v1.28.8---vmware.1-fips.1-tkg.2 1.28.8+vmware.1-fips.1-tkg.2 False False 76m
v1.29.4---vmware.3-fips.1-tkg.1 1.29.4+vmware.3-fips.1-tkg.1 False False 75m
jianhua@napp:~$
3.部署TKC集群
3.1. TKC集群yaml文件
创建名为tkc-dev.yaml的文件,内容如下
apiVersion: run.tanzu.vmware.com/v1alpha2
kind: TanzuKubernetesCluster
metadata:
# 自己定义tkc的集群名称
name: tkc-dev-cluster
# tanzu内创建的namespace名称
namespace: tkc-01
spec:
topology:
# master节点的信息
controlPlane:
replicas: 1
# master节点vmClass资源类型
vmClass: best-effort-xsmall
# master节点的存储策略
storageClass: tanzu-storage-policy
tkr:
reference:
# 配置tkc master节点版本
name: v1.26.10---vmware.1-fips.1-tkg.1
nodePools:
# 配置tkc 工作节点名称
- name: tck-dev-worker
# 配置tkc 工作节点数量
replicas: 2
# 工作节点vmClass资源类型
vmClass: best-effort-xsmall
# 工作节点的存储策略
storageClass: tanzu-storage-policy
tkr:
reference:
# 配置tkc node节点版本
name: v1.26.10---vmware.1-fips.1-tkg.1
settings:
storage:
# 配置tck集群存储策略
classes: ["tanzu-storage-policy"]
defaultClass: tanzu-storage-policy
network:
cni:
# 配置tck集群网络插件为calico
name: calico
services:
# 配置service网段
cidrBlocks: ["172.20.0.0/20"]
pods:
# 配置pod网段
cidrBlocks: ["172.20.16.0/20"]
# 配置domian
serviceDomain: cluster.local
- 创建示例
jianhua@napp:~/tkc$ kubectl apply -f tkc-dev.yaml
tanzukubernetescluster.run.tanzu.vmware.com/tkc-dev-cluster created
jianhua@napp:~/tkc$
jianhua@napp:~/tkc$ kubectl get virtualmachine
NAME POWERSTATE AGE
tkc-dev-cluster-control-plane-jmrk5 poweredOn 6m33s
tkc-dev-cluster-tck-dev-worker-zt5ls-779c467dd4xwbb9p-fpq6d poweredOn 3m6s
tkc-dev-cluster-tck-dev-worker-zt5ls-779c467dd4xwbb9p-kl9tx poweredOn 3m8s
jianhua@napp:~/tkc$
jianhua@napp:~/tkc$ kubectl get virtualmachine -o wide
NAME POWERSTATE CLASS IMAGE PRIMARY-IP AGE
tkc-dev-cluster-control-plane-jmrk5 poweredOn best-effort-xsmall ob-22748270-tkgs-ova-photon-3-v1.26.10---vmware.1-fips.1-tkg.1 192.168.202.101 8m43s
tkc-dev-cluster-tck-dev-worker-zt5ls-779c467dd4xwbb9p-fpq6d poweredOn best-effort-xsmall ob-22748270-tkgs-ova-photon-3-v1.26.10---vmware.1-fips.1-tkg.1 192.168.202.102 5m16s
tkc-dev-cluster-tck-dev-worker-zt5ls-779c467dd4xwbb9p-kl9tx poweredOn best-effort-xsmall ob-22748270-tkgs-ova-photon-3-v1.26.10---vmware.1-fips.1-tkg.1 192.168.202.103 5m18s
jianhua@napp:~/tkc$
3.2. 登录TkC集群
登录语法为:kubectl vsphere login --server=
--tanzu-kubernetes-cluster-name
--tanzu-kubernetes-cluster-namespace
--vsphere-username
--insecure-skip-tls-verify
jianhua@napp:~/tkc$ kubectl vsphere login --server=192.168.203.194 \
--tanzu-kubernetes-cluster-name tkc-dev-cluster \
--tanzu-kubernetes-cluster-namespace tkc-01 \
--vsphere-username administrator@vsphere.local \
--insecure-skip-tls-verify
KUBECTL_VSPHERE_PASSWORD environment variable is not set. Please enter the password below
Password:
Logged in successfully.
You have access to the following contexts:
192.168.203.194
tkc-01
tkc-dev-cluster
If the context you wish to use is not in this list, you may need to try
logging in again later, or contact your cluster administrator.
To change context, use `kubectl config use-context <workload name>`
jianhua@napp:~/tkc$
jianhua@napp:~/tkc$ kubectl config use-context tkc-dev-cluster
Switched to context "tkc-dev-cluster".
3.3. 查看TKC节点容器运行状态
至此我们完成了Tanzu TKC的部署
jianhua@napp:~/tkc$ kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system calico-kube-controllers-7857bc644-lxcqt 1/1 Running 0 20m
kube-system calico-node-fsktm 1/1 Running 0 17m
kube-system calico-node-rjv4j 1/1 Running 0 17m
kube-system calico-node-wvvgr 1/1 Running 0 20m
kube-system coredns-c5bb49cbf-fj5pb 1/1 Running 0 20m
kube-system coredns-c5bb49cbf-tgq6l 1/1 Running 0 20m
kube-system docker-registry-tkc-dev-cluster-control-plane-jmrk5 1/1 Running 0 21m
kube-system docker-registry-tkc-dev-cluster-tck-dev-worker-zt5ls-779c467dd4xwbb9p-fpq6d 1/1 Running 0 15m
kube-system docker-registry-tkc-dev-cluster-tck-dev-worker-zt5ls-779c467dd4xwbb9p-kl9tx 1/1 Running 0 17m
kube-system etcd-tkc-dev-cluster-control-plane-jmrk5 1/1 Running 0 21m
kube-system kube-apiserver-tkc-dev-cluster-control-plane-jmrk5 1/1 Running 0 21m
kube-system kube-controller-manager-tkc-dev-cluster-control-plane-jmrk5 1/1 Running 0 21m
kube-system kube-proxy-4gp4l 1/1 Running 0 17m
kube-system kube-proxy-m7ffq 1/1 Running 0 17m
kube-system kube-proxy-qwf6s 1/1 Running 0 20m
kube-system kube-scheduler-tkc-dev-cluster-control-plane-jmrk5 1/1 Running 0 21m
kube-system metrics-server-d595f6ddf-mvj2f 1/1 Running 0 20m
vmware-system-auth guest-cluster-auth-svc-6f9l8 1/1 Running 0 20m
vmware-system-cloud-provider guest-cluster-cloud-provider-5679f994c8-rtrg6 1/1 Running 0 20m
vmware-system-csi vsphere-csi-controller-7fc4557b5b-zhx9f 6/6 Running 0 20m
vmware-system-csi vsphere-csi-node-9blh8 3/3 Running 0 17m
vmware-system-csi vsphere-csi-node-fphgl 3/3 Running 0 17m
vmware-system-csi vsphere-csi-node-n9lnk 3/3 Running 0 20m
jianhua@napp:~/tkc$
参考文档链接
- tanzu登录:https://docs.vmware.com/en/VMware-vSphere/7.0/vmware-vsphere-with-tanzu/GUID-F5114388-1838-4B3B-8A8D-4AE17F33526A.html
- tkc-yaml模板:https://docs.vmware.com/en/VMware-vSphere/7.0/vmware-vsphere-with-tanzu/GUID-B1034373-8C38-4FE2-9517-345BF7271A1E.html
- tkc集群登录: https://docs.vmware.com/en/VMware-vSphere/7.0/vmware-vsphere-with-tanzu/GUID-AA3CA6DC-D4EE-47C3-94D9-53D680E43B60.html