Stav Alfi
Stav Alfi

Reputation: 13923

How to check if k8s deployment is passed/failed manually?

I'm trying to understand what does kubectl rollout status <deployment name> do.

I'm using k8s-node-api, and from this thread (https://github.com/kubernetes-client/javascript/issues/536), the maintainer suggest using k8s-watch api to watch for changes in the deployment, but I'm not sure what to check.

Questions:

  1. How to make sure the new deployment succeed?
  2. How to make the the new deployment failed?
  3. Is it safe to assume that if the spec/containers/0/image changes to something different than what I'm expecting, it means there is a new deployment and I should stop watching?

Any guidance will be great!


I can't use Kubectl - I'm writing a code that does that based on what kubectl does.

Upvotes: 2

Views: 1739

Answers (3)

Stav Alfi
Stav Alfi

Reputation: 13923

After digging through k8s source code, I was able to implement this logic by my self in Node.js:

How to make sure the new deployment succeed?

How to make the the new deployment failed?

https://github.com/stavalfi/era-ci/blob/master/packages/steps/src/k8s/utils.ts#L387

Basically, I'm subscribing to events about a specific deplyoment (AFTER chancing something in it, for example, the image).

Is it safe to assume that if the spec/containers/0/image changes to something different than what I'm expecting, it means there is a new deployment and I should stop watching?

Yes. But https://github.com/stavalfi/era-ci/blob/master/packages/steps/src/k8s/utils.ts#L62 will help also to idenfity that there is a new deployment going on and the yours is no longer the "latest-deployment".


For More Info I wrote an answer about how deployment works under the hood: https://stackoverflow.com/a/66092577/806963

Upvotes: 0

Malgorzata
Malgorzata

Reputation: 7023

As we have discussed in comment section I have mentioned that to check any object and processes in Kubernetes you have to use kubectl - see: kubernetes.io/docs/reference/kubectl/overview. Take a look how to execute proper command to gain required information - kubectl-rollout. If you want to check how rollout process looks from backgroud look at the source code - src-code-rollout-kubernetes.

Pay attention on that if you are using node-api:

The node-api group was migrated to a built-in API in the > k8s.io/api repo with the v1.14 release. This repo is no longer maintained, and no longer synced with core kubernetes as of the v1.18 release.

Upvotes: 0

Ted
Ted

Reputation: 136

I often use 2 following command for check out deployment status

kubectl describe deployment <your-deployment-name>
kubectl get deployment <your-deployment-name> -oyaml

The first will show you some events about process of schedule a deployment.

The second is more detailed. It contains all of your deployment's resource info as yaml format.

Is that enough for your need ?

Upvotes: -1

Related Questions