通过SDK操纵公有云

基于腾讯云Go SDK开发

下载开发工具集

go get -u github.com/tencentcloud/tencentcloud-sdk-go

为集群准备CVM

从本地开发集群K8S读取安全凭证secretId和secretKey配置信息, 然后把安全凭证传送给SDK客户端

secretId, secretKey:= K8SClient.Secrets("namespace=tencent").Get("cloud-pass")
credential := CloudCommon.NewCredential("secretId", "secretKey")
client, _ := cvm.NewClient(credential, regions.Beijing)
request := cvm.NewAllocateHostsRequest()
request.FromJsonString(K8SClient.Configs("namespace=tencent").Get("K8S-TENCENT-PROD"))
response, err := client.AllocateHosts(request)

通过ANSIBLE在CVM搭建K8S集群

Ansible.Hosts().Get(response.ToJsonString())

调用ANSIBLE开始在CVM部署K8S集群

Related