Skip to content

Instantly share code, notes, and snippets.

@wickedev
Created September 24, 2019 10:51
Show Gist options
  • Save wickedev/9416f1856a112976aacae8782cc633db to your computer and use it in GitHub Desktop.
Save wickedev/9416f1856a112976aacae8782cc633db to your computer and use it in GitHub Desktop.
kubectl config view --raw \
-o=jsonpath='{.clusters[0].cluster.certificate-authority-data}' \
| base64 --decode
cat <<EOF | kubectl apply -f -
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
EOF
SECRET=$(kubectl -n kube-system get secret | grep gitlab-admin | awk '{print $1}')
TOKEN=$(kubectl -n kube-system get secret $SECRET -o jsonpath='{.data.token}' | base64 --decode)
echo $TOKEN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment