ESXi OS 的安装网上有很多教程,没有太多值得讲解的地方,因此就参照一下其他大佬写的博客或者官方的安装文档 VMware ESXi 安装和设置 来就行;需要注意一点,ESXi OS 安装时 VMFSL 分区将会占用大量的存储空间,这将会使得 ESXi OS 安装所在的磁盘最终创建出来的 datastore 比预期小很多,而且这个 VMFSL 分区在安装好之后就很难再做调整了。因此如果磁盘存储空间比较紧张,在安装 ESXi OS 之前可以考虑下如何去掉这个分区;或者和我一样将 ESXI OS 安装在了一个 16G 的 USB Dom 盘上,不过生产环境不建议采用这种方案 😂(其实个人觉着安装在 U 盘上问题不大,ESXi OS 启动之后是加载到内存中运行的,不会对 U 盘有大量的读写操作,只不过在机房中 U 盘被人不小心拔走就凉了。
首先是挂载 vCenter 的 ISO,找到 vcsa ova 文件,它是 vCenter 虚拟机的模版
1 2 3
$ mount -o loop VMware-VCSA-all-7.0.3-18778458.iso /mnt $ ls /mnt/vcsa/VMware-vCenter-Server-Appliance-7.0.3.00100-18778458_OVF10.ova /mnt/vcsa/VMware-vCenter-Server-Appliance-7.0.3.00100-18778458_OVF10.ova
$ govc about FullName: VMware vCenter Server 7.0.3 build-18778458 Name: VMware vCenter Server Vendor: VMware, Inc. Version: 7.0.3 Build: 18778458 OS type: linux-x64 API type: VirtualCenter API version: 7.0.3.0 Product ID: vpx UUID: 0b49e119-e38f-4fbc-84a8-d7a0e548027d
Docker Add your non-root user account to the docker user group. Create the group if it does not already exist. This lets the Tanzu CLI access the Docker socket, which is owned by the root user. For more information, see steps 1 to 4 in the Manage Docker as a non-root user procedure in the Docker documentation.
# 如果没有配置 VSPHERE_TLS_THUMBPRINT 会有一个确认 vSphere thumbprint 的交互,输入 Y 就可以 Validating the pre-requisites... Do you want to continue with the vSphere thumbprint EB:F3:D8:7A:E8:3D:1A:59:B0:DE:73:96:DC:B9:5F:13:86:EF:B6:27 [y/N]: y
You have connected to a vSphere 7.0 environment which does not have vSphere with Tanzu enabled. vSphere with Tanzu includes an integrated Tanzu Kubernetes Grid Service which turns a vSphere cluster into a platform for running Kubernetes workloads in dedicated resource pools. Configuring Tanzu Kubernetes Grid Service is done through vSphere HTML5 client.
Tanzu Kubernetes Grid Service is the preferred way to consume Tanzu Kubernetes Grid in vSphere 7.0 environments. Alternatively you may deploy a non-integrated Tanzu Kubernetes Grid instance on vSphere 7.0. Deploying TKG management cluster on vSphere 7.0 ... Identity Provider not configured. Some authentication features won't work. Checking if VSPHERE_CONTROL_PLANE_ENDPOINT 192.168.20.94 is already in use Setting up management cluster... Validating configuration... Using infrastructure provider vsphere:v0.7.10 Generating cluster configuration... Setting up bootstrapper... Fetching configuration for kind node image... kindConfig: &{{Cluster kind.x-k8s.io/v1alpha4} [{ map[] [{/var/run/docker.sock /var/run/docker.sock false false }] [] [] []}] { 0 100.96.0.0/11 100.64.0.0/13 false } map[] map[] [apiVersion: kubeadm.k8s.io/v1beta2 kind: ClusterConfiguration imageRepository: projects.registry.vmware.com/tkg etcd: local: imageRepository: projects.registry.vmware.com/tkg imageTag: v3.4.13_vmware.15 dns: type: CoreDNS imageRepository: projects.registry.vmware.com/tkg imageTag: v1.8.0_vmware.5] [] [] []} Creating kind cluster: tkg-kind-c7vj6kds0a6sf43e6210 Creating cluster "tkg-kind-c7vj6kds0a6sf43e6210" ... Ensuring node image (projects.registry.vmware.com/tkg/kind/node:v1.21.2_vmware.1) ... Pulling image: projects.registry.vmware.com/tkg/kind/node:v1.21.2_vmware.1 ... Preparing nodes ... Writing configuration ... Starting control-plane ... Installing CNI ... Installing StorageClass ... Waiting 2m0s for control-plane = Ready ... Ready after 19s Bootstrapper created. Kubeconfig: /root/.kube-tkg/tmp/config_3fkzTCOL Installing providers on bootstrapper... Fetching providers Installing cert-manager Version="v1.1.0" Waiting for cert-manager to be available... Installing Provider="cluster-api" Version="v0.3.23" TargetNamespace="capi-system" Installing Provider="bootstrap-kubeadm" Version="v0.3.23" TargetNamespace="capi-kubeadm-bootstrap-system" Installing Provider="control-plane-kubeadm" Version="v0.3.23" TargetNamespace="capi-kubeadm-control-plane-system" Installing Provider="infrastructure-vsphere" Version="v0.7.10" TargetNamespace="capv-system" installed Component=="cluster-api" Type=="CoreProvider" Version=="v0.3.23" installed Component=="kubeadm" Type=="BootstrapProvider" Version=="v0.3.23" installed Component=="kubeadm" Type=="ControlPlaneProvider" Version=="v0.3.23" installed Component=="vsphere" Type=="InfrastructureProvider" Version=="v0.7.10" Waiting for provider infrastructure-vsphere Waiting for provider control-plane-kubeadm Waiting for provider cluster-api Waiting for provider bootstrap-kubeadm Waiting for resource capi-kubeadm-control-plane-controller-manager of type *v1.Deployment to be up and running pods are not yet running for deployment 'capi-kubeadm-control-plane-controller-manager' in namespace 'capi-kubeadm-control-plane-system', retrying Passed waiting on provider bootstrap-kubeadm after 25.205820854s pods are not yet running for deployment 'capi-controller-manager' in namespace 'capi-webhook-system', retrying Passed waiting on provider infrastructure-vsphere after 30.185406332s Passed waiting on provider cluster-api after 30.213216243s Success waiting on all providers. Start creating management cluster... patch cluster object with operation status: { "metadata": { "annotations": { "TKGOperationInfo" : "{\"Operation\":\"Create\",\"OperationStartTimestamp\":\"2022-02-06 02:35:34.30219421 +0000 UTC\",\"OperationTimeout\":1800}", "TKGOperationLastObservedTimestamp" : "2022-02-06 02:35:34.30219421 +0000 UTC" } } } cluster control plane is still being initialized, retrying Getting secret for cluster Waiting for resource tanzu-control-plan-kubeconfig of type *v1.Secret to be up and running Saving management cluster kubeconfig into /root/.kube/config Installing providers on management cluster... Fetching providers Installing cert-manager Version="v1.1.0" Waiting for cert-manager to be available... Installing Provider="cluster-api" Version="v0.3.23" TargetNamespace="capi-system" Installing Provider="bootstrap-kubeadm" Version="v0.3.23" TargetNamespace="capi-kubeadm-bootstrap-system" Installing Provider="control-plane-kubeadm" Version="v0.3.23" TargetNamespace="capi-kubeadm-control-plane-system" Installing Provider="infrastructure-vsphere" Version="v0.7.10" TargetNamespace="capv-system" installed Component=="cluster-api" Type=="CoreProvider" Version=="v0.3.23" installed Component=="kubeadm" Type=="BootstrapProvider" Version=="v0.3.23" installed Component=="kubeadm" Type=="ControlPlaneProvider" Version=="v0.3.23" installed Component=="vsphere" Type=="InfrastructureProvider" Version=="v0.7.10" Waiting for provider control-plane-kubeadm Waiting for provider bootstrap-kubeadm Waiting for provider infrastructure-vsphere Waiting for provider cluster-api Waiting for resource capi-kubeadm-control-plane-controller-manager of type *v1.Deployment to be up and running Passed waiting on provider control-plane-kubeadm after 10.046865402s Waiting for resource antrea-controller of type *v1.Deployment to be up and running Moving all Cluster API objects from bootstrap cluster to management cluster... Performing move... Discovering Cluster API objects Moving Cluster API objects Clusters=1 Creating objects in the target cluster Deleting objects from the source cluster Waiting for additional components to be up and running... Waiting for packages to be up and running... Waiting for package: antrea Waiting for package: metrics-server Waiting for package: tanzu-addons-manager Waiting for package: vsphere-cpi Waiting for package: vsphere-csi Waiting for resource antrea of type *v1alpha1.PackageInstall to be up and running Waiting for resource vsphere-cpi of type *v1alpha1.PackageInstall to be up and running Waiting for resource vsphere-csi of type *v1alpha1.PackageInstall to be up and running Waiting for resource metrics-server of type *v1alpha1.PackageInstall to be up and running Waiting for resource tanzu-addons-manager of type *v1alpha1.PackageInstall to be up and running Successfully reconciled package: antrea Successfully reconciled package: vsphere-csi Successfully reconciled package: metrics-server Context set for management cluster tanzu-control-plan as 'tanzu-control-plan-admin@tanzu-control-plan'. Deleting kind cluster: tkg-kind-c7vj6kds0a6sf43e6210 Management cluster created! You can now create your first workload cluster by running the following: tanzu cluster create [name] -f [file] Some addons might be getting installed! Check their status by running the following: kubectl get apps -A
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 2022/02/06 02:24:46 svType != tvType; key=release, st=map[string]interface {}, tt=<nil>, sv=map[version:], tv=<nil> CEIP Opt-in status: false
You have connected to a vSphere 7.0 environment which does not have vSphere with Tanzu enabled. vSphere with Tanzu includes an integrated Tanzu Kubernetes Grid Service which turns a vSphere cluster into a platform for running Kubernetes workloads in dedicated resource pools. Configuring Tanzu Kubernetes Grid Service is done through vSphere HTML5 client.
Tanzu Kubernetes Grid Service is the preferred way to consume Tanzu Kubernetes Grid in vSphere 7.0 environments. Alternatively you may deploy a non-integrated Tanzu Kubernetes Grid instance on vSphere 7.0. Deploying TKG management cluster on vSphere 7.0 ... Identity Provider not configured. Some authentication features won't work. Checking if VSPHERE_CONTROL_PLANE_ENDPOINT 192.168.20.94 is already in use Setting up management cluster... Validating configuration... Using infrastructure provider vsphere:v0.7.10
Start creating management cluster... patch cluster object with operation status: { "metadata": { "annotations": { "TKGOperationInfo" : "{\"Operation\":\"Create\",\"OperationStartTimestamp\":\"2022-02-06 02:35:34.30219421 +0000 UTC\",\"OperationTimeout\":1800}", "TKGOperationLastObservedTimestamp" : "2022-02-06 02:35:34.30219421 +0000 UTC" } } } cluster control plane is still being initialized, retrying Getting secret for cluster Waiting for resource tanzu-control-plan-kubeconfig of type *v1.Secret to be up and running Saving management cluster kubeconfig into /root/.kube/config
Installing providers on management cluster... Fetching providers Installing cert-manager Version="v1.1.0" Waiting for cert-manager to be available... Installing Provider="cluster-api" Version="v0.3.23" TargetNamespace="capi-system" Installing Provider="bootstrap-kubeadm" Version="v0.3.23" TargetNamespace="capi-kubeadm-bootstrap-system" Installing Provider="control-plane-kubeadm" Version="v0.3.23" TargetNamespace="capi-kubeadm-control-plane-system" Installing Provider="infrastructure-vsphere" Version="v0.7.10" TargetNamespace="capv-system" installed Component=="cluster-api" Type=="CoreProvider" Version=="v0.3.23" installed Component=="kubeadm" Type=="BootstrapProvider" Version=="v0.3.23" installed Component=="kubeadm" Type=="ControlPlaneProvider" Version=="v0.3.23" installed Component=="vsphere" Type=="InfrastructureProvider" Version=="v0.7.10" Waiting for provider control-plane-kubeadm Waiting for provider bootstrap-kubeadm Waiting for provider infrastructure-vsphere Waiting for provider cluster-api Waiting for resource capv-controller-manager of type *v1.Deployment to be up and running Passed waiting on provider infrastructure-vsphere after 20.091935635s Passed waiting on provider cluster-api after 20.109419304s Success waiting on all providers. Waiting for the management cluster to get ready for move... Waiting for resource tanzu-control-plan of type *v1alpha3.Cluster to be up and running Waiting for resources type *v1alpha3.MachineDeploymentList to be up and running Waiting for resources type *v1alpha3.MachineList to be up and running Waiting for addons installation... Waiting for resources type *v1alpha3.ClusterResourceSetList to be up and running Waiting for resource antrea-controller of type *v1.Deployment to be up and running
Moving all Cluster API objects from bootstrap cluster to management cluster... Performing move... Discovering Cluster API objects Moving Cluster API objects Clusters=1 Creating objects in the target cluster Deleting objects from the source cluster Context setfor management cluster tanzu-control-plan as 'tanzu-control-plan-admin@tanzu-control-plan'. Deleting kind cluster: tkg-kind-c7vj6kds0a6sf43e6210
Management cluster created!
You can now create your first workload cluster by running the following:
tanzu cluster create [name] -f [file]
Some addons might be getting installed! Check their status by running the following:
root@photon-machine [ ~ ]# tanzu cluster create tanzu-workload-cluster --file tanzu-workload-cluster.yaml Validating configuration... Warning: Pinniped configuration not found. Skipping pinniped configuration in workload cluster. Please refer to the documentation to check if you can configure pinniped on workload cluster manually Creating workload cluster 'tanzu-workload-cluster'... Waiting for cluster to be initialized... Waiting for cluster nodes to be available... Waiting for cluster autoscaler to be available... Unable to waitfor autoscaler deployment to be ready. reason: deployments.apps "tanzu-workload-cluster-cluster-autoscaler" not found Waiting for addons installation... Waiting for packages to be up and running... Workload cluster 'tanzu-workload-cluster' created
部署完成之后查看一下集群的 CR 信息
1 2 3 4 5 6 7 8
root@photon-machine [ ~ ]# kubectl get cluster NAME PHASE tanzu-workload-cluster Provisioned # machine 状态处于 Running 说明节点已经正常运行了 root@photon-machine [ ~ ]# kubectl get machine NAME PROVIDERID PHASE VERSION tanzu-workload-cluster-control-plane-4tdwq vsphere://423950ac-1c6d-e5ef-3132-77b6a53cf626 Running v1.21.2+vmware.1 tanzu-workload-cluster-md-0-8555bbbfc-74vdg vsphere://4239b83b-6003-d990-4555-a72ac4dec484 Running v1.21.2+vmware.1