您的位置:首页 > 其它

VMware Tanzu Kubernetes 集群部署

2020-07-21 15:15 1061 查看

目录:

  1. 创建Content Libraries
  2. 为Tanzu Kubernetes集群创建NameSpace
  3. 准备Tanzu Kubernetes集群YAML文件
  4. 创建Tanzu Kubernetes集群
  5. 登陆Tanzu Kubernetes集群

 

前提条件:

  1. Tanzu Kubernetes集群是基于vSphere with Kubernetes环境之上的,因此需要准备好vSphere with Kubernetes环境。

  2. vCenter Server必须可以上网,因为需要和VMware服务器同步Photon K8S系统镜像。

 

1. 创建Content Libraries

在Inventories中点击 “Content Libraries”

New Content Library,输入名称 Kubernetes

选择Subscribed content library,URL为

https://wp-content.vmware.com/v2/latest/lib.json

选择存储

点击Finish。

 

创建完成后,可以在Templates页面中查看到正在同步的photon k8s镜像文件(因为文件有11.71GB,因此同步时间可能从几分钟至几小时)。

 

将创建好的Content Library和Cluster进行关联。

 

2. 为Tanzu Kubernetes集群创建NameSpace

右击vSphere with Kubernetes集群,选择 New Namespace

输入名称和描述,点击Create

 

为创建好的namespace指派用户和存储

 

3. 准备Tanzu Kubernetes集群YAML文件

[code]apiVersion: run.tanzu.vmware.com/v1alpha1      # TKG API endpoint,固定值
kind: TanzuKubernetesCluster                   # Required parameter,固定值
metadata:
name: tkc-guest-cluster
namespace: tkc-cluster               # 在vSphere中创建的NameSpace
spec:
distribution:
version: v1.16.8+vmware.1-tkg.3.60d2ffd
topology:
controlPlane:
count: 3                                 # 3 control plane nodes
class: guaranteed-medium                 # medium size VM
storageClass: vk8s                       # vSphere中创建的存储策略,跟vSphere with kubernetes需要的存储策略类似
workers:
count: 3                                 # 3 worker nodes
class: guaranteed-medium                 # medium large size VM
storageClass: vk8s                       # vSphere中创建的存储策略,跟vSphere with kubernetes需要的存储策略类似
settings:
network:
cni:
name: calico                # 目前仅支持Calico
services:
cidrBlocks: ["198.51.100.0/12"]        # Cannot overlap with Supervisor Cluster
pods:
cidrBlocks: ["192.0.2.0/16"]           # Cannot overlap with Supervisor Cluster
storage:
classes: ["vk8s"]                      # vSphere中创建的存储策略,跟vSphere with kubernetes需要的存储策略类似,可以指定多个。
defaultClass: vk8s                     # vSphere中创建的存储策略,跟vSphere with kubernetes需要的存储策略类似

虚机类型配置参数

CPU 内存 (GB) 存储 (GB) 预留的 CPU 和内存
guaranteed-xlarge
4
32
16
best-effort-xlarge
4
32
16
guaranteed-large
4
16
16
best-effort-large
4
16
16
guaranteed-medium
2
8
16
best-effort-medium
2
8
16
guaranteed-small
2
4
16
best-effort-small
2
4
16
guaranteed-xsmall
2
2
16
best-effort-xsmall
2
2
16

 

4. 创建Tanzu Kubernetes集群

登陆vsphere with kubernetes集群,切换context,查看virtualmachineimages(注意:如果virtualmachineimages显示为空,则表示Content Library还没有同步完成)

创建Tanzu KUbernetes集群(yaml文件内容见第三步)

 等30分钟左右后Tanzu Kubernetes集群创建完成

查看Tanzu Kubernetes集群中的VirtualMachine

 在vCenter Server中查看

 

5. 登陆Tanzu Kubernetes集群

登陆命令

kubectl vsphere login  --server https://xxxx --insecure-skip-tls-verify \
--tanzu-kubernetes-cluster-namespace tkc-cluster \
--tanzu-kubernetes-cluster-name tkc-guest-cluster \
--vsphere-username administrator@vsphere.local

登录成功后,切换到Tanzu Kubernetes集群

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: