K8s config commands

Config

Azure

log-in into a tenant

az login --tenant 7f2c3a6b-e849-4d6f-b65d-1c0ef8b0f41c

configure local kubectl .kube config file

az aks get-credentials --resource-group my-aks --name aksname --admin

(the –admin part is optional but useful)

Contexts & Namespaces

see all configured contexts

kubectl config get-contexts

configure a context with a default namespace

kubectl config set-context <context_here> --namespace=<namespace_here>
# example
kubectl config set-context my-aks-context --namespace=aks-dev

change context

kubectl config use-context <context_here>
# example
kubectl config use-context my-aks-context

see all namespaces

kubectl get ns

Work with API Resources

list all api-resources

kubectl api-resources

Pods

find pods with partial name

kubectl get pods --show-labels --no-headers | grep kpi

Reference(s)

http://www.opslib.com/2020/05/kubernetes-cheatsheet-k8s-command.html