Readiness Gates Before Production Deployments
What readiness gates are, why they matter before production deploys, and how to build pipeline checks and Kubernetes Pod readinessGates.
Readiness gates are checks that must report "ready" before a production deployment starts or before new instances receive traffic. They confirm the target environment and its dependencies can accept the release: databases migrated, downstream services healthy, error budget available, no freeze in place. They differ from quality gates, which judge the code.
This guide explains the two places the term is used (a pipeline readiness check and the Kubernetes Pod readinessGates field), shows how to build both, and links them to the rest of a release process. It is part of our CI/CD pipeline cluster.
Key takeaways
- A quality gate asks "is this build good?". A readiness gate asks "is production ready to receive it right now?".
- Pipeline readiness gates run just before deploy: dependency health, schema version, error budget, change freeze, capacity.
- Kubernetes has a built-in Pod field,
spec.readinessGates, that lets an external controller hold a Pod out of Service endpoints until a custom condition is true. - The AWS Load Balancer Controller uses Pod readiness gates so a Pod only counts as ready after it is healthy in the load balancer target group.
- Readiness gates must fail closed and time out with a clear message, or engineers will learn to bypass them.
Where readiness gates fit in the release flow
| Stage | Gate type | Question answered | Our guide |
|---|---|---|---|
| After build and test | Quality gate | Is the artifact good enough? | CI/CD quality gates |
| Before production | Approval gate | Has a person signed off? | Approval gates |
| Immediately before deploy | Readiness gate | Is the environment ready now? | This post |
| During rollout, per Pod | Probes and Pod readiness gates | Can this instance take traffic? | Liveness and readiness probes |
| After deploy | Verification | Did the release behave? | Post-deployment validation |
A build can pass every quality gate and still fail in production because a dependency is down, a migration has not run, or the team is already burning its error budget on another incident. Readiness gates catch those environment problems.
Why readiness gates matter
They stop deploys into a broken environment
Deploying during an incident adds a second change to debug. A gate that checks open incidents or active alerts keeps the change set small while people investigate.
They enforce ordering between dependent changes
If version 2.4 of a service needs a new database column, the gate can confirm the schema version first. This avoids a rollout that crashes on every new Pod.
They turn reliability policy into code
Google's SRE book describes error budget policies in which releases pause when the budget is spent. A readiness gate that queries your SLO tool applies that policy without a meeting.
They make bypasses visible
When the gate is part of the pipeline, an override is a logged action with a name attached instead of a quiet manual deploy.
Seven pipeline readiness checks worth automating
| Check | Fails when | Typical data source |
|---|---|---|
| Dependency health | A required downstream service or database is unhealthy | Health endpoints, Prometheus up metric |
| Schema version | Database migration level is lower than the release needs | Flyway or Liquibase history table |
| Error budget | Remaining budget is below the policy threshold | SLO tooling or Prometheus recording rules |
| Active incidents and alerts | A critical alert is firing for the service | Alertmanager API, incident tool |
| Change freeze | The date is inside a declared freeze window | Calendar file in the repo, deploy policy |
| Capacity | Cluster cannot schedule the surge Pods | Cluster autoscaler status, quota usage |
| Config and secrets present | A required ConfigMap, secret or feature flag is missing | kubectl get, secret manager API |
Building a pipeline readiness gate
A script that fails closed
Keep the logic in one script that exits non-zero on any failure, including when it cannot reach the data source. This example checks Prometheus for firing critical alerts and for the health of a dependency.
#!/usr/bin/env bash
set -euo pipefail
PROM="${PROM_URL:?PROM_URL not set}"
q() { curl -fsS --max-time 10 --get "$PROM/api/v1/query" --data-urlencode "query=$1" | jq -r '.data.result | length'; }
firing=$(q 'ALERTS{alertstate="firing",severity="critical",service="payments"}')
if [ "$firing" -gt 0 ]; then
echo "NOT READY: $firing critical alert(s) firing for payments"; exit 1
fi
down=$(q 'up{job="orders-db"} == 0')
if [ "$down" -gt 0 ]; then
echo "NOT READY: orders-db target down"; exit 1
fi
echo "READY: environment checks passed"
Because of set -e and curl -f, an unreachable Prometheus also fails the gate. That is the right default for production.
Running it in GitHub Actions
jobs:
readiness:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Production readiness gate
run: ./scripts/readiness.sh
env:
PROM_URL: ${{ vars.PROM_URL }}
deploy:
needs: readiness
runs-on: ubuntu-latest
environment: production
steps:
- run: echo "deploy here"
The needs keyword makes deploy wait for the readiness job. The production environment can add required reviewers on top.
Checking the schema version
Flyway records every applied migration in a history table, flyway_schema_history by default. A gate can compare the latest successful version with the minimum the release needs:
REQUIRED="2024.10.3"
CURRENT=$(psql "$DB_URL" -tAc \
"SELECT version FROM flyway_schema_history WHERE success ORDER BY installed_rank DESC LIMIT 1")
if [ "$(printf '%s\n%s\n' "$REQUIRED" "$CURRENT" | sort -V | head -1)" != "$REQUIRED" ]; then
echo "NOT READY: schema $CURRENT is older than required $REQUIRED"; exit 1
fi
Store REQUIRED in the repository next to the code that needs it, so the requirement changes in the same pull request as the feature.
Checking a change freeze
Keep freeze windows in a file that people change through pull requests, then read it in the gate:
# freeze.txt holds lines like: 2026-12-24 2027-01-02
today=$(date -u +%F)
while read -r start end; do
if [[ "$today" > "$start" || "$today" == "$start" ]] && [[ "$today" < "$end" || "$today" == "$end" ]]; then
echo "NOT READY: change freeze $start to $end"; exit 1
fi
done < freeze.txt
Azure Pipelines: built-in checks
Azure Pipelines lets resource owners add checks to environments, service connections and other resources. The dynamic checks include Invoke REST API, Invoke Azure Function, Business Hours and Query Azure Monitor Alerts; the last one passes only if no alert rules are active when it runs. Checks run before a stage that uses the resource starts, are re-evaluated at a set interval, and skip the stage if they do not pass before the timeout. Pipeline authors cannot change them from YAML, which keeps the gate under the resource owner's control. Administrators can bypass some checks, and the bypass is shown in the checks panel.
Kubernetes Pod readiness gates
Kubernetes uses the same word for a narrower feature. A Pod is added to a Service's endpoints only when its Ready condition is true. Normally that depends on containers being ready (readiness probes). With spec.readinessGates, you add extra conditions that an external controller must set.
apiVersion: v1
kind: Pod
metadata:
name: web
spec:
readinessGates:
- conditionType: "example.com/lb-registered"
containers:
- name: web
image: nginx:1.27
readinessProbe:
httpGet:
path: /
port: 80
The Pod's Ready condition becomes true only when all containers are ready and every listed condition is True. A listed condition that is missing from status.conditions counts as false. The kubelet does not set these conditions; your controller does, through the Pod status subresource. To see the effect by hand on a test cluster:
kubectl patch pod web --subresource=status --type=json -p='[
{"op":"add","path":"/status/conditions/-",
"value":{"type":"example.com/lb-registered","status":"True"}}]'
kubectl get pod web -o wide # the READINESS GATES column shows 1/1
During a rolling update, the Deployment controller counts only ready Pods toward availability, so the rollout waits for the gate too. In production, a controller should set the condition, never a person.
Real use: AWS Load Balancer Controller
The AWS Load Balancer Controller can inject a readiness gate into Pods in namespaces labelled elbv2.k8s.aws/pod-readiness-gate-inject: enabled. The Pod becomes ready only after its IP is registered and healthy in the ALB or NLB target group. Without it, a rolling update can terminate old Pods before new ones receive traffic from the load balancer, causing brief errors.
kubectl label namespace payments elbv2.k8s.aws/pod-readiness-gate-inject=enabled
Existing Pods are not changed; the gate applies to Pods created after the label is set.
Design rules that keep gates useful
- If the gate cannot read its data, treat that as not ready.
- Retry for a short window, then fail with the exact reason so the job does not hang.
- Print which check failed and link to the dashboard that shows it.
- Emergency fixes sometimes have to ship during an incident. Make the override a named approval that is logged, and keep it out of pipeline edits.
- Keep each check fast. A gate that takes ten minutes tends to get disabled.
- If a check often blocks good deploys, fix the signal. Adding a bypass only hides the problem.
Common mistakes
| Mistake | Result | Better approach |
|---|---|---|
| Treating readiness probes as the only gate | Pods are ready but a dependency is down | Add a pipeline-level environment check |
| Gate passes when monitoring is unreachable | Silent bypass during outages | Fail closed with set -e and strict HTTP checks |
| Hard-coded freeze dates in scripts | Stale rules nobody updates | A freeze calendar file reviewed through pull requests |
| No owner for the gate | Broken checks get commented out | Platform team owns the gate code and its alerts |
Rolling out readiness gates
- List the last five production incidents caused or worsened by a deploy. Each one suggests a check.
- Start with alerts-firing and dependency-health checks; they need only Prometheus or your monitoring API.
- Run new checks in report-only mode for two weeks and compare against deploy outcomes.
- Switch them to blocking, with a documented override path.
- Add Pod readiness gates where load balancer registration lags behind Pod readiness.
Pipeline gates, approvals and Kubernetes rollouts are covered in labs in our DevOps training in Pune, in the Kharadi classroom and live online.
Frequently asked questions
What is a readiness gate in CI/CD?
It is an automated check that runs right before a production deployment and confirms the environment can accept the release: dependencies healthy, migrations applied, no critical alerts, no freeze in effect.
How is a readiness gate different from a quality gate?
A quality gate evaluates the build, such as tests, coverage and scans. A readiness gate evaluates the target environment at deploy time. A good build can still fail a readiness gate.
What is spec.readinessGates in Kubernetes?
It is a Pod field that lists extra condition types. The Pod is ready only when all containers are ready and every listed condition is set to True by an external controller.
Why does the AWS Load Balancer Controller use readiness gates?
So a Pod counts as ready only after it is healthy in the load balancer target group. This keeps rolling updates from removing old Pods before new ones actually receive traffic.
Should a readiness gate fail if monitoring is down?
For production, yes. Failing closed prevents silent bypasses. Provide a logged, approved override for emergencies.
Can readiness gates use error budgets?
Yes. A gate can query remaining error budget from your SLO tooling and block non-urgent releases when it falls below the agreed threshold.
Which CI tools support readiness checks natively?
Azure Pipelines has environment checks such as REST API calls and Azure Monitor alert queries. In GitHub Actions and GitLab CI you usually implement them as a job that deploy jobs depend on.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0