Notes/docs/Command Snippets/Kubernetes Snippets.md
Keannu Bernasol eb573c83cd vault backup: 2024-11-22 11:22:55
Affected files:
docs/Command Snippets/Kubernetes Snippets.md
2024-11-22 11:22:55 +08:00

1.5 KiB

  • Get all pods
kubectl get pods
  • Get all replicacontrollers
kubectl get replicacontrollers
  • Get all replicasets
kubectl get replicasets
  • Describe a specific resource (ex. Describe a deployment named myapp-deployment)
kubectl describe deployment/myapp-deployment

# This works too
kubectl describe deployment myapp-deployment
  • Get specific resource information in wide format
kubectl describe deployment/myapp-deployment -o wide
  • Create a deployment
kubectl create -f deployment.yml
  • Update a deployment
kubectl apply -f deployment.yml
  • Check rollout/deployment history
kubectl rollout history deployment/myapp-deployment
  • Update a deployment, tracking changes (deprecated)
kubectl apply -f deployment.yml --record
  • Update a deployment using annotate(Note: Changes to scale will not create a new deployment. Annotating after this may result in the message for the previous deployment being replaced)
# This assumes you've annotated the previous deployment already
kubectl apply -f deployment.yml

# Annotate the new deployment
kubectl annotate deployment/myapp-deployment kubernetes.io/change-cause="DESCRIBE_CHANGES_HERE"

# You can then view the rollout history
kubectl rollout history deployment/myapp-deployment
  • Restart a deployment (repulls latest image if imagePullPolicy is set to Always)
kubectl rollout restart deployment/myapp-deployment