VMware Tanzu社区版在VMware vSphere部署

部署环境:
VMware Tanzu Commuity 0.11.0
VMware vCenter Standard 7.0 U3c
VMware ESXi Enterprise Plus 7.0 U3c
官方文档参考:https://tanzucommunityedition.io/docs/v0.11/

  1. 准备bootstrap

VMware Tanzu部署需要bootstrap启动机,用于部署初始的管理集群。本文使用Ubuntu LTS 20.04作为bootstrap。
1) 先安装docker-ce,过程简写,文档可参考:
https://docs.docker.com/engine/install/ubuntu/

sudo timedatectl set-timezone Asia/Shanghai
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release -y
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] http://mirrors.aliyun.com/docker-ce/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y

2) docker相关配置
修改用户所属组,使具有docker操作权限。(tanzu默认不使用root用户部署)

sudo usermod -aG docker $USER
newgrp docker

3) 下载kubectl
本文使用的是v1.23.5版本

curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -L -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
rm kubectl
kubectl version --client

4) Tanzu CLI
从以下URL下载Tanzu CLI安装包
https://tanzucommunityedition.io/download/
本文使用Linux 0.11.0版,下载tce-linux-amd64-v0.11.0.tar.gz,然后传至bootstrap机器,解压安装。

tar xvzf tce-linux-amd64-v0.11.0.tar.gz
cd tce-linux-amd64-v0.11.0
./install.sh
tanzu version

5) 准备SSH密钥
执行以下命令,所有提示用回车接受默认配置,保存~/.ssh/id_rsa.pub文件内容后续会用到。

ssh-keygen -t rsa -b 4096 -C "jeff@ebanban.com"
  1. 部署Management Cluster

1) 可提前下载docker镜像
Tanzu的docker镜像似乎都在国外,下载时间较长可能会超过tanzu cli默认的30分钟,建议预先进行下载。

docker pull projects.registry.vmware.com/tkg/kind/node:v1.22.5_vmware.1

2) 开始部署Management Cluster
使用以下命令开始安装。

tanzu management-cluster create –ui –bind 0.0.0.0:8080 –browser none –timeout 2h0m0s

然后用浏览器打开http://<bootstrap机器ip>:8080
然后点击下图中VMware vSphere里的Deploy

输入vCenter信息

然后将1-5步中~/.ssh/id_rsa.pub文件内容粘贴到SSH Public Key对话框中,随后点击Next

Management Cluster规格及控制节点网络按需求配置

NSX ALB如果没有使用可直接按Next跳过

Metadata部分也可直接按Next跳过

在Rosources部分选择虚拟机对应的vSphere文件夹、存储卷以及使用的主机或集群信息

在K8S网络设置部分配置集群Service及Pod所对应的CIDR,如没有特殊要求直接使用默认。注意,在网络中需要有DHCP服务器为VM分配IP

如果不使用OIDC或LDAP认证可以关闭

TCE在vSphere部署时需要用到VM模板,需预先下载后导入vSphere,然后转换为模板。本文使用的是Ubuntu 2004 Kubernetes v1.22.5 OVA。
https://customerconnect.vmware.com/en/downloads/details?downloadGroup=TCE-0110&productId=1266&rPId=86727

然后点击Review Configuration

然后点击Deploy Management Cluster开始部署

部署完成如下图所示

部署完成后vSphere会出现2台虚拟机(生产配置会有4台)

使用tanzu mc get命令获得管理集群的状态

使用以下命令可以开始管理Management Cluster

kubectl config use-context tce-mgmt-admin@tce-mgmt
  1. 部署Workload Cluster

Management Cluster部署完成后可以部署Workload Cluster。在~/.config/tanzu/tkg/clusterconfigs目录下可以找到一个随机命名的yaml文件,这是创建Management Cluster时自动生成的,将其复制并命名

cd ~/.config/tanzu/tkg/clusterconfigs
ls -l
cp <randomly>.yaml workload1.yaml

然后编辑workload-cluster1.yaml,修改以下字段。
这里指定了workload-cluster1作为集群名,kubevip为192.168.1.191,work节点数量2

CLUSTER_NAME: workload-cluster1
VSPHERE_CONTROL_PLANE_ENDPOINT: 192.168.1.191
WORKER_MACHINE_COUNT: 2

然后使用以下命令创建

tanzu cluster create –file ~/.config/tanzu/tkg/clusterconfigs/workload-cluster1.yaml –timeout 2h0m0s -v 6

部署完成如下

使用命令获得workload cluster运行情况

tanzu cluster get workload-cluster1

在vsphere中可以看到有一个control plane machine及两个worker machine

VMware Tanzu社区版在VMware vSphere部署》有1个想法

  1. Pingback引用通告: VMware NSX Application Platform部署(未完) | eBanBan Studio

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注