Blog/DevOps/CI/CD

CI/CD

11 essential ci/cd interview questions

CI/CD is a software development practice where code changes are automatically tested and deployed to production using automation pipelines, ensuring faster and reliable releases. I have implemented CI/CD using GitHub Actions. Whenever I push code to the repository, the GitHub Actions pipeline is triggered automatically. It first builds the application, then creates a Docker image using a Dockerfile, and finally pushes or runs that Docker container on an AWS server. This setup helps me automate the entire deployment process, reduce manual effort, and ensure consistent deployments. Workflow: Code push → GitHub Actions triggers → Build app → Create Docker image → Push to registry → Deploy to AWS. Benefits: continuous testing, faster releases, consistency, reduced errors.
CI (Continuous Integration): merge code frequently, automated tests catch issues early. CD (Continuous Delivery/Deployment): automated release to production. Benefits: faster releases, fewer bugs, better quality, quick feedback. Requires test coverage, automated tests, robust monitoring.
Jenkins: open-source, flexible, self-hosted. GitHub Actions: Git-native, free for public repos. GitLab CI/CD: built-in, powerful. CircleCI: cloud-based. Travis CI: simple GitHub integration. Choose based on: hosting, features, cost, integration.
1. Trigger: code push to repository. 2. Build: compile, run tests. 3. Test: unit tests, integration tests. 4. Deploy: staging environment. 5. Release: production deployment. Each stage should be automated. Use status checks before merging.
Continuous Delivery: automatically deploy to staging, manual release to production. Continuous Deployment: automatically deploy to production. CD (delivery) provides control before release. CD (deployment) speeds up releases. Choose based on risk tolerance.
Unit tests: fast, test small components. Integration tests: test component interactions. End-to-end tests: test full workflow (slower). Run fast tests first. Require code coverage threshold (e.g., 80%). Fail pipeline on test failure. Parallelize tests for speed.
Artifacts: compiled binaries, packages, reports from build. Store in artifact repository (Artifactory, Nexus). Tag with build number, version. Retention policies: keep recent, delete old. Use artifacts to deploy to different environments. Reproducible builds.
Store configuration externally (environment variables, config servers). Separate config from code. Use secrets management (HashiCorp Vault, AWS Secrets Manager). Rotate secrets regularly. Different config per environment (dev, staging, prod). Never commit secrets.
Two identical production environments: blue (current), green (new). Route traffic to blue, deploy to green, test, switch traffic to green. If issues, switch back immediately. Zero downtime deployment. Requires infrastructure redundancy.
Route small traffic percentage to new version (canary). Monitor metrics (errors, latency). Gradually increase traffic if healthy. Rollback if issues detected. Safer than all-at-once. Allows early issue detection.
Monitor: build success rate, deployment frequency, lead time. Alerts: build failures, deployment issues. Metrics dashboards: visualize trends. Logs: aggregate and analyze. Notify teams: Slack, email on failures. Improve feedback loop.