...
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands
Use a different kubectl context
Code Block | ||
---|---|---|
| ||
kubectl --kubeconfig ~/.kube/config2 get pods --all-namespaces |
Adding user kubectl accounts
Normally you don't use the admin account directly when working with particular namespaces. Details on how to create a user token and the appropriate role bindings.
Code Block | ||
---|---|---|
| ||
# TODO: create a script out of this # create a namespace # https://kubernetes.io/docs/tasks/administer-cluster/namespaces-walkthrough/#create-new-namespaces vi mobrien_namespace.yaml { "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "mobrien", "labels": { "name": "mobrien" } } } kubectl create -f mobrien_namespace.yaml # or kubectl --kubeconfig ~/.kube/admin create ns mobrien namespace "mobrien" created # service account kubectl --kubeconfig ~/.kube/admin --namespace=mobrien create sa mobrien serviceaccount "mobrien" created # rolebinding mobrien kubectl --kubeconfig ~/.kube/admin --namespace=mobrien create rolebinding mobrien-mobrien-privilegedpsp --clusterrole=privilegedpsp --serviceaccount=netprog:mobrien rolebinding "mobrien-mobrien-privilegedpsp" created # rolebinding default kubectl --kubeconfig ~/.kube/admin --namespace=mobrien create rolebinding mobrien-default-privilegedpsp --clusterrole=privilegedpsp --serviceaccount=mobrien:default rolebinding "mobrien-default-privilegedpsp" created # rolebinding admin kubectl --kubeconfig ~/.kube/admin --namespace=mobrien --namespace=mobrien create rolebinding mobrien-mobrien-admin --clusterrole=admin --serviceaccount=mobrien:mobrien rolebinding "mobrien-mobrien-admin" created # rolebinding persistent-volume-role kubectl --kubeconfig ~/.kube/admin --namespace=mobrien create clusterrolebinding mobrien-mobrien-persistent-volume-role --clusterrole=persistent-volume-role --serviceaccount=mobrien:mobrien clusterrolebinding "mobrien-mobrien-persistent-volume-role" created # rolebinding default-persistent-volume-role kubectl --kubeconfig ~/.kube/admin --namespace=mobrien create clusterrolebinding mobrien-default-persistent-volume-role --clusterrole=persistent-volume-role --serviceaccount=mobrien:default clusterrolebinding "mobrien-default-persistent-volume-role" created # rolebinding helm-pod-list kubectl --kubeconfig ~/.kube/admin --namespace=mobrien create clusterrolebinding mobrien-mobrien-helm-pod-list --clusterrole=helm-pod-list --serviceaccount=mobrien:mobrien clusterrolebinding "mobrien-mobrien-helm-pod-list" created # rolebinding default-helm-pod-list kubectl --kubeconfig ~/.kube/admin --namespace=mobrien create clusterrolebinding mobrien-default-helm-pod-list --clusterrole=helm-pod-list --serviceaccount=mobrien:default clusterrolebinding "mobrien-default-helm-pod-list" created |
Helm on Rancher unauthorized
...