How to install faster a cluster K8S.
Namespaces
kubectl get namespaces
kubectl create namespace trainning
kubectl config set-context --current --namespace=trainning
kubectl config view | grep namespace:
kubectl config view
Selector -l --selector
kubectl get pods --selector='run=httpd'
kubectl logs --selector='run=httpd' kubectl logs -l run=httpd
Resources handling
kubectl delete all --all
kubectl delete po --wait=false
kubectl run nginx --image=nginx --requests 'cpu=100m,memory=256Mi' --limits='cpu=200m,memory=512Mi'
kubectl run nginx --image=nginx --serviceaccount=myuser --port=66 --env=var1=val1
kubectl create quota myrq --hard=cpu=1,memory=1G,pods=2
kubectl annotate pod nginx1 nginx2 nginx3 description='my description'
kubectl annotate pod nginx{1..3} description-
PODS
kubectl run nginx --image=nginx --restart=Never --dry-run=client -n mynamespace -o yaml > pod.yaml
kubectl run busybox --image=busybox --restart=Never -- /bin/sh -c 'i=0; while true; do echo "$i:
kubectl run busybox --image=busybox --command --restart=Never -- /bin/sh -c 'i=0; while true; do echo "$i:
kubectl run busybox --image=busybox -it --rm --restart=Never -- echo 'hello world'
kubectl run nginx2 --image=nginx --restart=Never --labels=access=granted --rm -it -- curl http://nginx
kubectl get pod/nodes --show-labels
kubectl label pod nginx2 app=v2 --overwrite
kubectl label pod nginx1 nginx2 nginx3 app- kubectl label pod nginx{1..3} app-
kubectl label pod -l "type in (worker,runner)" protected=true
kubectl set image pod/ = kubectl set image pod/nginx nginx=nginx:1.7.1
kubectl logs nginx -p kubectl logs nginx --previous
kubectl exec nginx --it -- /bin/sh kubectl exec nginx -- ls -la
kubectl get pod --label-columns=app
Services
kubectl run nginx --image=nginx --restart=Never --port=80 --expose
kubectl get ep nginx
JOBS
kubectl create job busybox --image=busybox -- /bin/sh -c 'echo hello;sleep 30;echo world'
Deployment
kubectl autoscale deploy nginx --min=5 --max=10 --cpu-percent=80
Configmap
kubectl create cm configmap4 --from-file=kecialKey=config.txt
Various
kubectl cp /:/tmp/foo /tmp/bar kubectl cp /tmp/foo_dir :/tmp/bar_dir -c
source <(kubectl completion bash)
kubeadm token create --print-join-command