或者點擊項目左側的【operation】→【Kubernetes】→【Add Kubernetes cluster】塑煎。
- name隨意
- API URL通過
kubectl cluster-info | grep 'Kubernetes master' | awk '/http/ {print $NF}'
得到阅羹。 - CA Certificates勺疼,先運行
kubectl get secrets
查看默認的token,可以看到default-token-xxxxx捏鱼,然后通過kubectl get secret <secret name> -o jsonpath="{['data']['ca\.crt']}" | base64 --decode
可得到执庐。
~ # kubectl get secrets
NAME TYPE DATA AGE
default-token-4w6nw kubernetes.io/service-account-token 3 22d
~ # kubectl get secret default-token-4w6nw -o jsonpath="{['data']['ca\.crt']}" | base64 --decode
-----BEGIN CERTIFICATE-----
………………………………………………………………
………………………………………………………………
………………………………………………………………
-----END CERTIFICATE-----
- Service Token,先創(chuàng)建一個叫做gitlab-admin-service-account.yaml的文件导梆,內容如下轨淌。再通過
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep gitlab-admin | awk '{print $1}')
得到token值。
/home # cat gitlab-admin-service-account.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: gitlab-admin
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: gitlab-admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: gitlab-admin
namespace: kube-system
/home # kubectl apply -f gitlab-admin-service-account.yaml
serviceaccount "gitlab-admin" created
clusterrolebinding "gitlab-admin" created
/home# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep gitlab-ad
min | awk '{print $1}')
Name: gitlab-admin-token-jd7dh
Namespace: kube-system
Labels: <none>
Annotations: kubernetes.io/service-account.name: gitlab-admin
kubernetes.io/service-account.uid: 44ff86e5-61f2-4e5a-94c6-68202032048f
Type: kubernetes.io/service-account-token
Data
====
namespace: 11 bytes
token: ……………………
ca.crt: 1497 bytes
添加成功看尼,可自行選擇添加Application递鹉。