# copy cluster's certificate to a file
vi cluster-certificate.txt
# Set cluster
kubectl config set-cluster <CLUSTER_NAME> --server=https://37.187.1.138:6443 --certificate-authority=cluster-certificate.txt --embed-certs=true
# Set credentials
kubectl config set-credentials <USER_NAME> --token=<TOKEN>
# Set context
kubectl config set-context <KUBECTL_CONTEXT_NAME> --cluster=<CLUSTER_NAME> --user=<USER_NAME> --namespace=<NAMESPACE>
# Use context
kubectl config use-context <KUBECTL_CONTEXT_NAME>
# Delete a config map
kubectl get configmaps | awk '{print $1}' | grep -v 'NAME' | xargs kubectl delete configmap
# Real "get all"
kubectl get -n <NAMESPACE> configmaps,daemonsets,deployments,endpoints,ingresses,jobs,persistentvolumeclaims,pods,podtemplates,replicasets,services,statefulsets
# Delete ALL
kubectl get -n <NAMESPACE> configmaps,daemonsets,deployments,endpoints,ingresses,jobs,persistentvolumeclaims,pods,podtemplates,replicasets,services,statefulsets,secrets | awk '{print $1}' | grep -v "NAME" | grep -v "secret/default-token" | xargs kubectl delete
kubectl get deployment
# Stop
kubectl scale deployment.apps/<DEPLOYMENT_NAME> --replicas 0
# Start
kubectl scale deployment.apps/<DEPLOYMENT_NAME> --replicas 1
Sometime you just want to restart a container into a pod.
This will send a SIGTERM
signal to process 1, which is the main process running in the container. All other processes will be children of process 1, and will be terminated after process 1 exits.
Note: It will not solve your problem. This is only a quick fix.
kubectl exec -it <POD_NAME> -c <CONTAINER_NAME> -- /bin/sh -c "kill 1"
I don't know why but sometimes, helm upgrade
doesn't upgrade these annotations so I have to do it manualy.
kubectl annotate --overwrite ingress <INGRESS_NAME> "nginx.ingress.kubernetes.io/rewrite-target"-
kubectl annotate --overwrite ingress <INGRESS_NAME> "ingress.kubernetes.io/rewrite-target"-
- kubectx and kubens to "switch faster between clusters and namespaces in kubectl".
- jonmosco/kube-ps1to add the current Kubernetes context and namespace to your prompt.
- Kubernetes client kubectl container
- Kubectl-debug
- jordanwilson230/kubectl-plugins