Skip to content

Instantly share code, notes, and snippets.

@rsmitty
Created April 23, 2024 13:43
Show Gist options
  • Save rsmitty/d57d334171e9ad47e2506688e508153e to your computer and use it in GitHub Desktop.
Save rsmitty/d57d334171e9ad47e2506688e508153e to your computer and use it in GitHub Desktop.
Create a service account for use outside of omni context
## Create service account
$ kubectl -n kube-system create serviceaccount <user-name>
## Bind the service account to the cluster-admin role
$ kubectl create clusterrolebinding <user-name> --clusterrole=cluster-admin --serviceaccount=kube-system:<user-name>
## Create a token for the service account
$ kubectl create token <user-name> -n kube-system
## Create a kubeconfig with this new token
apiVersion: v1
clusters:
- cluster:
server: https://<control plane ip>:6443
name: <cluster-name>
contexts:
- context:
cluster: <cluster-name>
namespace: default
user: <user-name>
name: <cluster-name>
current-context: <cluster-name>
kind: Config
preferences: {}
users:
- name: <user-name>
user:
token: <generated token>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment