Skip to content
tezvyn:

How do you add a basic post-deployment health check in CI/CD?

Source: devopstraininginstitute.comMediumHow cards are made

How do you add a basic post-deployment health check in CI/CD?

Tests deployment validation beyond exit-code success. Outline: add a post-deploy stage that probes an HTTP endpoint, checks status code and latency, validates critical dependencies, and triggers rollback on failure.

What's really being asked

This question probes whether you treat deployment as a process that ends with verified service health, not just with a configuration change pushed to a cluster. Interviewers want to see that you distinguish between infrastructure mutation and application readiness, and that you can build automated gates that protect users from broken releases.

The full answer

A strong answer walks through the following layers in order. First, the pipeline stage itself: you add a post-deployment job that runs after the deploy stage and is marked as a hard gate, so a failure blocks production traffic or triggers rollback. Second, the probe mechanism: you call a dedicated health endpoint such as /health or /ready with HTTP retries, exponential backoff, and a timeout budget, for example 30 seconds with three retries. Third, the validation criteria: you check that the endpoint returns a 200-level status code, responds within an SLA such as 500 milliseconds, and returns an expected payload or version identifier. Fourth, dependency validation: you confirm that the application can reach its database, cache, or message broker, either through the health endpoint depth or through a separate smoke test. Fifth, the failure action: on repeated probe failure, the pipeline should either run an automatic rollback, drain traffic from the new version, or page the on-call engineer.

The mistakes people make

The biggest red flag is saying that a successful Terraform apply, kubectl rollout status, or Ansible play exit code is sufficient proof. Another weak pattern is proposing a manual check in a browser or a single curl with no retry logic. Some candidates only mention container readiness probes inside Kubernetes but forget that the pipeline itself needs a validation stage before it marks the build green. Also, checking only that the process is running without validating traffic-serving ability misses the point.

What usually comes next

The interviewer may ask how you handle health checks during a canary or blue-green rollout, how you avoid false positives from cached health endpoints, or how you secure the health endpoint so it does not leak sensitive data while still being reachable from the CI runner. They might also ask for a concrete timeout and retry policy, or how you would validate a non-HTTP service such as a gRPC or queue worker.

A concrete example

Imagine a GitLab CI pipeline deploying a Node.js API to Kubernetes. After the Helm upgrade stage, a post-deploy job runs a script that loops up to ten times with a five-second sleep. Each iteration calls https://api-staging.example.com/health and expects HTTP 200 with a JSON body containing status: up and a version field matching the CI_COMMIT_SHA. If the call succeeds within the loop, the job passes. If not, the job fails and triggers a helm rollback to the previous revision, then notifies Slack.

Interview question

Which of the following describes a properly automated post-deployment validation stage?

  • a.The pipeline marks the build green once the Helm upgrade completes without errors
  • b.The release engineer manually opens the application in a browser to confirm it loads after each deployment
  • c.A Kubernetes readiness probe restarts the container if the application fails to start within ten seconds
  • d.A post-deploy job probes a health endpoint with retries, checks response time and dependencies, and initiates rollback if thresholds are missedCorrect
Why?

A robust validation stage must act as a hard gate that checks traffic-serving ability, latency, dependencies, and triggers rollback on failure rather than relying solely on infrastructure exit codes. Option A is a tempting distractor because a successful Helm upgrade only confirms infrastructure mutation, not actual application readiness.

Just read this? Test yourself on what you have been reading.

Read the original → devopstraininginstitute.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on ci/cd — each one lists the topics its interview covers.

See open roles