kubectl config code example
Example 1: kubectl use context
kubectl config view
KUBECONFIG=~/.kube/config:~/.kube/kubconfig2
kubectl config view
kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'
kubectl config view -o jsonpath='{.users[].name}'
kubectl config view -o jsonpath='{.users[*].name}'
kubectl config get-contexts
kubectl config current-context
kubectl config use-context my-cluster-name
kubectl config set-credentials kubeuser/foo.kubernetes.com --username=kubeuser --password=kubepassword
kubectl config set-context --current --namespace=ggckad-s2
kubectl config set-context gce --user=cluster-admin --namespace=foo \
&& kubectl config use-context gce
kubectl config unset users.foo
Example 2: aws config kubectl
aws eks --region <region-code> update-kubeconfig --name <cluster_name>
Example 3: kubectl restart deployment
kubectl rollout restart deployment yourDeploymentName
Example 4: kubectl create configmap
kubectl create configmap