1 Star 0 Fork 0

powerpaas / rke

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
kubeconfig.go 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
package pki
import "encoding/base64"
func getKubeConfigX509(kubernetesURL string, clusterName string, componentName string, caPath string, crtPath string, keyPath string) string {
return `apiVersion: v1
kind: Config
clusters:
- cluster:
api-version: v1
certificate-authority: ` + caPath + `
server: "` + kubernetesURL + `"
name: "` + clusterName + `"
contexts:
- context:
cluster: "` + clusterName + `"
user: "` + componentName + `-` + clusterName + `"
name: "` + clusterName + `"
current-context: "` + clusterName + `"
users:
- name: "` + componentName + `-` + clusterName + `"
user:
client-certificate: ` + crtPath + `
client-key: ` + keyPath + ``
}
func GetKubeConfigX509WithData(kubernetesURL string, clusterName string, componentName string, cacrt string, crt string, key string) string {
return `apiVersion: v1
kind: Config
clusters:
- cluster:
api-version: v1
certificate-authority-data: ` + base64.StdEncoding.EncodeToString([]byte(cacrt)) + `
server: "` + kubernetesURL + `"
name: "` + clusterName + `"
contexts:
- context:
cluster: "` + clusterName + `"
user: "` + componentName + `-` + clusterName + `"
name: "` + clusterName + `"
current-context: "` + clusterName + `"
users:
- name: "` + componentName + `-` + clusterName + `"
user:
client-certificate-data: ` + base64.StdEncoding.EncodeToString([]byte(crt)) + `
client-key-data: ` + base64.StdEncoding.EncodeToString([]byte(key)) + ``
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/powerpaas/rke.git
git@gitee.com:powerpaas/rke.git
powerpaas
rke
rke
v0.2.9-rc2

搜索帮助

344bd9b3 5694891 D2dac590 5694891