Scenario Your team uses GitLab CI/CD to deploy to Kubernetes. One day, a developer merges a patch that introduces a critical bug. The pipeline passes all tests (because they were outdated), triggers a deployment to production, the bug causes intermittent failures, and your SRE team is woken up at 3 AM.
Symptoms The application is running but returning 500 errors for specific endpoints. Deploy logs show success, but monitoring shows increased error rates. The rollout completed without manual intervention—no safety checks between staging and production.
Diagnosis The CI/CD pipeline lacks guardrails: no automated integration tests that mock production dependencies, no security scanning, no approval step before production. Artifact promotion is automatic from any branch. There is no canary analysis or automated rollback.
Commands
To fix this, implement a pipeline with quality gates:
1. Add a .gitlab-ci.yml stage for linting, unit tests, integration tests (npm run test, jest --coverage).
2. Add a security scanning stage (e.g., trivy image analyze myimage:tag).
3. Introduce manual approval for production deployment: use when: manual in the production job and require approvals from the lead engineer.
4. Enable canary deployments: deploy to 10% of pods first, run smoke tests, then promote.
5. Use artifact promotion: build once, promote across environments with signed attestation.
Example commands:
# Build and tag
docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
# Deploy canary
kubectl set image deployment/app app=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --record
kubectl rollout pause deployment/app
# Run smoke tests
# After tests pass, resume rollout
kubectl rollout resume deployment/app
Risk Controls - Use feature flags toggled off by default. - Implement deployment freeze windows during critical hours. - Use GitLab's merge request approvals and pipeline success as prerequisites. - Store secrets in vault and inject at runtime, not in CI variables.
Rollback
- Automate rollback if error rate exceeds threshold: kubectl rollout undo deployment/app.
- Use GitLab's auto-rollback by checking deployment health with a post-deployment job.
Verification - Confirm that the rollback reverted to the previous stable version. - Check application logs and metrics. - Run a synthetic test against the application.
When to Submit an OpsGlobal Ticket - If your team needs help designing a resilient CI/CD pipeline with proper guardrails. - If an incident occurs despite existing guardrails and you need root cause analysis. - If you require assistance with Kubernetes rollback strategies or canary deployments.
Use cases
Useful for teams handling CI/CD issues and needing a clear troubleshooting and delivery workflow.
Problem background
Learn how to enforce quality gates, automated testing, and rollback procedures to prevent bad deployments from reaching production.
Troubleshooting steps
Confirm impact and recent changes, collect logs, configuration and metrics, then apply fixes from low to high risk.
Command examples
Replace sample resource names with real values and store passwords, tokens and keys in environment variables.
Risks
Before production changes, confirm backups, access boundaries, change windows and rollback paths.
Rollback plan
Keep original configuration and release versions; roll back config, images or database changes if metrics degrade.
Deliverables
Root-cause notes, key commands, remediation steps, verification results and follow-up recommendations.
Need help with a similar technical issue?
If your servers, Kubernetes, Docker, CI/CD, databases or monitoring systems have similar issues, submit logs and config files for remote diagnosis.