Kubernetes `Rollout`

November 14, 2024 note-to-self k8s

In k8s, you don't "deploy", you "rollout". But, you don't "rollout" either. You either apply a deployment (or do it through helm, preferably), or kubectl create deployment <name>. But really, do it through helm won't ya?

  1. Apply the Deployment or Update:

    • When you want to deploy an application or update it, you use kubectl apply -f <file> or kubectl create deployment <name>, or use helm helm install <release-name> <chart>
    • This action creates or updates the resources, which automatically starts a rollout.
  2. Manage the Rollout with kubectl rollout Commands:

    • After starting the deployment (or update), you use kubectl rollout commands to manage or observe the rollout's progress:
      • Check status with kubectl rollout status deployment <deployment-name> to ensure the update is progressing without issues.
      • Undo the rollout with kubectl rollout undo deployment <deployment-name> if you need to roll back to the previous version.
      • Pause or resume the rollout with kubectl rollout pause or kubectl rollout resume if you need to halt changes temporarily.
  3. Do it all with helm:

    • helm install (To "rollout")
    • helm list (To find the release name)
    • helm history my-app (To see the revision history)
    • helm rollback my-app 2 (To roll back to revision 2; ("rollback!"))
    • helm status my-app (To verify the rollback)

The way I understand it, kubectl apply/helm install initiates the rollout, while kubectl rollout/helm list/history/rollback/status commands help you manage the rollout and watch it progress.