# kubernetes
# contexts
kubectl config get-contexts
kubectl config use-context minikube
kubectl config set-content mycontext --nmespace=mystuff
kubectl config view
kubectl cluster-info
kubectl get componentstatuses
# resource info
kubectl get namespaces
kubectl get nodes
kubectl get ep
kubectl get pods -o wide # output more info
kubectl get svc
kubectl get deployments
kubectl get all # does not include all resources
kubectl api-resources # get supported resources
# get all resources
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found
# describe
kubectl describe svc webapi-svc
kubectl describe nodes node-1
# labels
kubectl get pods --show-labels
# search for matching labels
kubectl get pods -selector="ver=1,env=prod" # negate this with -selector="ver!=1"
# search for labels logical OR
kubectl get pods -selector="ver in (1,2)" # notin also valid
# create and update resources
kubectl create -f svc.yml
kubectl apply -f svc.yml
kubectl apply -f deploy.yml --record
kubectl rollout status deployment APP
# watch deploy progress
kubectl get service webapi-svc --watch`
# deleting
kubectl delete -f deploy.yml
kubectl delete deployments --all
# kubectl - more
kubectl logs <pod> -f # tail container logs
kubectl logs --previous <pod> # get logs from previous instance of a pod
kubectl exec -it <pod> -- bash # open a shell in container
kubectl cp <po>:/remote/path/to/file /local/path/to/file # reverse to copy from pod to local
# launch a pod
kubectl run grafana --image=grafana/grafana --port=3000
# minikube
minikube start
minikube dashboard
minikube service webapi-chart --url