qkhanhpro
qkhanhpro

Reputation: 5240

kubectl rollout status - When the command complete?

Currently I am using this in my pipeline

kubectl apply -f deployment.yaml && kubectl rollout status -f deployment.yaml

With this in yaml

      readinessProbe:
        tcpSocket:
          port: 90
        initialDelaySeconds: 120
        periodSeconds: 10
        timeoutSeconds: 10
        failureThreshold: 1
        successThreshold: 1
      livenessProbe:
        tcpSocket:
          port: 90
        initialDelaySeconds: 120
        periodSeconds: 20
        timeoutSeconds: 2
        failureThreshold: 1
        successThreshold: 1

For me, kubectl rollout is running for a very long time, blocking the deployment pipeline. From the documentation

By default 'rollout status' will watch the status of the latest rollout until it's done

My question:

1/ Which actions are the parts that contribute to the deployment "until it's done" (resource creation, resource teardown?... )

2/ Does readinessProbe and livenessProbe contribute to the deployment time

Upvotes: 3

Views: 12673

Answers (3)

Greg Dubicki
Greg Dubicki

Reputation: 6950

As of May 2024 it is documented in the official Kubernetes docs, in Kubernetes / Documentation / Concepts / Workloads / Workload Management / Deployments, under the "Complete Deployment" section:

Kubernetes marks a Deployment as complete when it has the following characteristics:

  • All of the replicas associated with the Deployment have been updated to the latest version you've specified, meaning any updates you've requested have been completed.
  • All of the replicas associated with the Deployment are available.
  • No old replicas for the Deployment are running.

Upvotes: 3

Peter Honeder
Peter Honeder

Reputation: 1

Another reference for this is here in the kubectl source: https://github.com/kubernetes/kubectl/blob/197123726db24c61aa0f78d1f0ba6e91a2ec2f35/pkg/polymorphichelpers/rollout_status.go#L89

It's quite self explanatory if you look at the log messages.

Upvotes: 0

David Maze
David Maze

Reputation: 160003

The criteria for this are in the kubectl source. A deployment is "complete" if:

  • It hasn't timed out
  • Its updated-replica count is at least its desired-replica count (every new pod has been created)
  • Its current-replica count is at most its updated-replica count (every old pod has been destroyed)
  • Its available-replica count is at least its updated-replica count (every new pod is running)

You can use kubectl get deployment -w or kubectl get pod -w to watch a deployment actually happen in real time; the kubectl get -w option watches the given resources and prints out a new line whenever they change. You'll see the following sequence occur (with default Deployment settings, one at a time for "small" deployments):

  1. A new pod is created
  2. The new pod passes its probes and become ready
  3. An old pod is terminated
  4. The old pod actually exits and is deleted

So for kubectl rollout status deployment/... to finish, all of these steps must happen – new pods are created, new pods all pass their health checks, old pods are destroyed – for every replica in the deployment.

Upvotes: 7

Related Questions