Notes/docs/Command Snippets/Kubernetes Snippets.md
Keannu Bernasol 223b4c0893 vault backup: 2024-11-22 01:21:22
Affected files:
docs/Command Snippets/Kubernetes Snippets.md
2024-11-22 01:21:22 +08:00

1.3 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