https://www.cnblogs.com/sanduzxcvbnm/p/13844799.html
    https://docs.gitlab.com/ee/user/project/clusters/add_remove_clusters.html#add-existing-cluster

    1. [rancher@rmaster01 ~]$ kubectl cluster-info | grep 'Kubernetes master' | awk '/http/ {print $NF}'
    2. https://192.168.6.102:6443
    3. [rancher@rmaster01 ~]$ kubectl get secrets
    4. NAME TYPE DATA AGE
    5. default-token-rftrn kubernetes.io/service-account-token 3 45d
    6. longhorn-uninstall-service-account-token-dqvsc kubernetes.io/service-account-token 3 7d16h
    7. [rancher@rmaster01 ~]$ kubectl get secrets default-token-rftrn -o jsonpath="{['data']['ca\.crt']}" | base64 --decode
    8. -----BEGIN CERTIFICATE-----
    9. MIICwjCCAaqgAwIBAgIBADANBgkqhkiG9w0BAQsFADASMRAwDgYDVQQDEwdrdWJl
    10. LWNhMB4XDTIxMDMwMzE1NDMzMVoXDTMxMDMwMTE1NDMzMVowEjEQMA4GA1UEAxMH
    11. a3ViZS1jYTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANCAOttBxjOZ
    12. CwW3c2SKJdEo1UxQxp95dDQFKfgZ6G4yzzsVjAwUwOFOZlXI3r99XuEjXklxEhk/
    13. CBHnsYMu+L0qzmxQ/5eq7O5i2pTvPLBB5+0hJj/h+IFCewrU8CGWKQEgsfgJxLc8
    14. YXleulETB0V3nQwEv/nN9RRB3bxhLq/j/nJnw7vZbcKPIErPtXOKPUaCYEyddEpo
    15. /I3f1pjEzZWiyaZBWcfqx4kJ1GD+bAatIuhL65c4gUbwlDdjM4mIz3ZDIFeJb8D8
    16. RPCOiU9kH45rU5Mr1oqkFefWJgyvY4IYPxUYgnyI0biZh78/gBNMIqhA3+qzKZiW
    17. Ub0cjrDea4kCAwEAAaMjMCEwDgYDVR0PAQH/BAQDAgKkMA8GA1UdEwEB/wQFMAMB
    18. Af8wDQYJKoZIhvcNAQELBQADggEBAKII/rm9I5H6s+2UtefrmKp00a74iYzQjzU6
    19. sM2Ovz2r1DLw29LM2vLfbfSiHvl9XIIA5rFyya6Nc0cbAUS56yMZSnA5XJli6Y0y
    20. yQpUUfoynkDCbKlHrsLitCBVGmcGzNJtggjMij2fQCc9B6eQk45iut65jxs3tkgY
    21. zZGtfC0+NLoDd/0iQEmtONHFtxpOhVXcDhvjeERaeDUBhU9Kp9hSfFCXFpywLtbo
    22. 4dO2le44vhKzjpJW7i1UNAtYnNVqPrMzxNGgXdEDih/h6InqGWq61jBmgO+Wo3fm
    23. hYpC152HuuXVacrGH7EE+E4P7GkxW5Y5SafZOgWPtv0WU4TQk2w=
    24. -----END CERTIFICATE-----
    25. [rancher@rmaster01 ~]$

    gitlab添加Kubernetes集群集成 - 图1

    1. [rancher@rmaster01 ~]$ vim gitlab-admin-service-account.yaml
    2. [rancher@rmaster01 ~]$ kubectl apply -f gitlab-admin-service-account.yaml
    3. serviceaccount/gitlab created
    4. Warning: rbac.authorization.k8s.io/v1beta1 ClusterRoleBinding is deprecated in v1.17+, unavailable in v1.22+; use rbac.authorization.k8s.io/v1 ClusterRoleBinding
    5. clusterrolebinding.rbac.authorization.k8s.io/gitlab-admin created
    6. [rancher@rmaster01 ~]$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep gitlab | awk '{print $1}')
    7. Name: gitlab-token-7r4c9
    8. Namespace: kube-system
    9. Labels: <none>
    10. Annotations: kubernetes.io/service-account.name: gitlab
    11. kubernetes.io/service-account.uid: d317866d-e6e3-4375-b241-8b406a8d8f5a
    12. Type: kubernetes.io/service-account-token
    13. Data
    14. ====
    15. ca.crt: 1017 bytes
    16. namespace: 11 bytes
    17. token: eyJhbGciOiJSUzI1NiIsImtpZCI6IldsX0UyaDZXTm51N2RzUTRWa21td204R3dhVmxLNmNtOWZ1dkRKSG5WWUEifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJnaXRsYWItdG9rZW4tN3I0YzkiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZ2l0bGFiIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiZDMxNzg2NmQtZTZlMy00Mzc1LWIyNDEtOGI0MDZhOGQ4ZjVhIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmdpdGxhYiJ9.SYn-WHm58Kfgmv9Yf6T1U0eYQExCy6M8DBlc3bKVA4n3nLFRZSxxVb6Lbu93-6zkT_mDgertERxoDY-dPWY489iwAg7hy23MEO6VeRhpzh9-OCHggdnTLyesEUqx7pVJiZ0pcI3feEP7BC1GJCHLZ8ncTDsSnvaKi5JiRIk9r_rmV0jHbc97aUKBAqvVIeboZmCIMLwDektJFM6dWnJa2MdtUQW3BWzmdIiugty59tvKu0dzGHQBX6fa9MN7JtGVWabxGKyf_XkbWC3SVI7RQPj2cV1kXWRUVRh5csSShYqBt9jfjiT9U4e61vMAkpCet5QRDbcvdKjbrNZcKDEJTQ
    18. [rancher@rmaster01 ~]$ cat gitlab-admin-service-account.yaml
    19. apiVersion: v1
    20. kind: ServiceAccount
    21. metadata:
    22. name: gitlab
    23. namespace: kube-system
    24. ---
    25. apiVersion: rbac.authorization.k8s.io/v1beta1
    26. kind: ClusterRoleBinding
    27. metadata:
    28. name: gitlab-admin
    29. roleRef:
    30. apiGroup: rbac.authorization.k8s.io
    31. kind: ClusterRole
    32. name: cluster-admin
    33. subjects:
    34. - kind: ServiceAccount
    35. name: gitlab
    36. namespace: kube-system
    37. [rancher@rmaster01 ~]$

    gitlab添加Kubernetes集群集成 - 图2

    gitlab添加Kubernetes集群集成 - 图3