|
Hint
|
Answer
|
|
List all nodes (in the current namespace)
|
kubectl get nodes
|
|
Show all pods in the current namespace
|
kubectl get pods
|
|
Show all pods in ALL namespaces
|
kubectl get pods -A
|
|
Describe a pod named nginx
|
kubectl describe pod nginx
|
|
Describe all pods (in the current namespace)
|
kubectl describe pods
|
|
Output the YAML for pod named nginx
|
kubectl get pod nginx -o yaml
|
|
Watch pods (in current namespace)
|
kubectl get pods -w
|
|
Create from a manifest file called app.yaml (hint: use apply)
|
kubectl apply -f app.yaml
|
|
Delete from a manifest file app.yaml
|
kubectl delete -f app.yaml
|
|
List all namespaces
|
kubectl get namespaces
|
|
Create a namespace named dev
|
kubectl create ns dev
|
|
Switch context namespace to dev
|
kubectl config set-context --current --namespace=dev
|
|
Create a deployment "web" using image nginx:1.25
|
kubectl create deploy web --image=nginx1.25
|
|
Scale deployment "web" to 3 replicas
|
kubectl scale deploy web --replicas=3
|
|
Update a deployment image (rolling update). Set "web" container nginx to nginx:1.26
|
kubectl set image deploy/web nginx=nginx:1.26
|
|
Check rollout status of the "web" deployment
|
kubectl rollout status deploy/web
|
|
Roll back a deployment of "web"
|
kubectl rollout undo deploy/web
|
|
Expose a deployment called "web" as a service on port 80 as ClusterIP
|
kubectl expose deploy web --port=80
|
|
Port Forwarding: Forward Local port 8080 to pod nginx on port 80
|
kubectl port-forward pod/nginx 8080:80
|
|
Exec into a pod. Get a shell in pod nginx.
|
kubectl exec -it nginx -- sh
|
|
View logs for pod nginx
|
kubectl logs nginx
|
|
View logs for a specific container. Pod is app, container is api
|
kubectl logs app -c api
|
|
Create a configmap (literal) app-cm with key=value
|
kubectl create cm app-cm --from-literal=key=value
|
|
Create a secret db with user=admin
|
kubectl create secret generic db --from-literal=user=admin
|
|
Create a service account
|
kubectl create sa build-bot
|
|
Get Events (sorted)
|
kubectl get events --sort-by=.metadata.creationTimestamp
|
|
Show wide pod details
|
kubectl get pods -o wide
|