kubectl - Pod Design Flashcards
list pods labels in my-namespace
kubectl get po –show-labels -n my-namespace
Create nginx-prod1 pod with label env=prod
kubectl run nginx-prod1 –image=nginx –restart=Never –labels=env=dev
show pods with label env=dev
kubectl get po -l env=dev
show pods that have label env
kubectl get po -L env
create nginx pod on node-1
- kubectl run nginx –image=nginx –restart=Never –dry-run=client -o yaml > nginx-pod.yaml
- Add yaml:
spec:
nodeName: node-1 - kubectl create -f nginx-pod.yaml
Create a service for nginx on port 80 targeting port 9376
kubectl expose deployment nginx –port=80 –targetPort=9376
Create deployment named hr-app running nginx:1.18 with 2 replicas
- kubectl create deployment hr-app –image=nginx:1.18 –dry-run=client -o yaml > deploy.yaml
- vim deploy.yaml ->
spec:
replicas: 2
Scale hr-app to 3 replicas
kubectl scale deployment/hr-app –replicas 3
Remove a NoSchedule taint from node1 with selector spray=mortein
kubectl taint nodes node1 spray=mortein:NoSchedule-
Label node1 node with color=blue
kubectl label node node1 color=blue
Clean cluster by removing autoscaled deployment webapp
kubectl delete deployment webapp
kubectl delete hpa webapp
create cronjob date-job that uses busybox image a prints date and “hello” every minute
kubectl create cronjob date-job –image=busybox –schedule=”*/1 * * * *” – bin/sh -c “date; echo hello”