Created
August 29, 2021 18:24
-
-
Save EarthmanT/d478c2f1bb63b3211a243a036fb2fa22 to your computer and use it in GitHub Desktop.
Kubectl Create and Get Token Bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo su docker | |
minikube kubectl -- apply -f - <<EOF | |
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
name: demo-account | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: ClusterRoleBinding | |
metadata: | |
name: demo-account | |
roleRef: | |
apiGroup: rbac.authorization.k8s.io | |
kind: ClusterRole | |
name: demo-account-admin | |
subjects: | |
- kind: ServiceAccount | |
name: demo-account | |
namespace: default | |
EOF | |
minikube kubectl -- apply -f - <<EOF | |
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: demo-account-secret | |
annotations: | |
kubernetes.io/service-account.name: demo-account | |
type: kubernetes.io/service-account-token | |
EOF | |
export TOKEN=$(minikube kubectl -- get serviceaccount demo-account -o=jsonpath='{.secrets[0].name}' | xargs minikube kubectl -- get secret -ojsonpath='{.data.token}' | base64 --decode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment