π Day 14 of 30 Days DevOps Interview Preparation

Series: 30 Days DevOps Interview Preparation
Author: Tathagat Gaikwad
π Week 2 Revision + 20 CI/CD Interview Questions (with AWS Practical)
In my 30 Days DevOps Interview Preparation journey, Iβve reached Day 14, which is dedicated to:
β
Revising all Week 2 concepts (Git, CI/CD, Jenkins, GitHub Actions, Docker)
β
Answering 20 common CI/CD interview questions
β
Doing a small AWS practical to apply CI/CD in real-world cloud environments
π Week 2 Quick Revision
1οΈβ£ Git & GitHub
Version control to manage source code.
Branching strategies (GitFlow, trunk-based).
Importance of pull requests and code reviews in CI/CD.
2οΈβ£ Jenkins & GitHub Actions
Jenkins = self-hosted automation server with plugins.
GitHub Actions = cloud-native CI/CD tightly integrated with GitHub.
Both enable Pipeline as Code.
3οΈβ£ Docker Basics
Containerization for consistent runtime environments.
Used in CI/CD pipelines for build β test β deploy.
4οΈβ£ CI/CD Recap
CI = frequently integrating code & running automated tests.
CD = automating deployments to staging/production.
Goal β reduce deployment time, minimize errors, and ensure consistency.
βοΈ Practical: Deploy a Docker App via CI/CD on AWS
Letβs build a simple CI/CD pipeline on AWS using GitHub Actions.
πΉ Step 1: Setup AWS Infrastructure
Create EC2 instance (Ubuntu) for hosting app.
Install Docker:
sudo apt update -y sudo apt install docker.io -y sudo systemctl enable docker sudo systemctl start docker
Allow inbound port (80) in EC2 Security Group.
πΉ Step 2: Dockerize Your App
Dockerfile
for Node.js app:
FROM node:16
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
πΉ Step 3: Push Code to GitHub
Repo structure:
.
βββ app.js
βββ Dockerfile
βββ package.json
βββ .github/
βββ workflows/
βββ ci-cd.yml
πΉ Step 4: GitHub Actions CI/CD Pipeline
.github/workflows/ci-cd.yml
:
name: CI/CD on AWS EC2
on:
push:
branches: [ "main" ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build Docker image
run: docker build -t myapp:latest .
- name: Save Docker image
run: docker save myapp:latest | gzip > myapp.tar.gz
- name: Copy image to EC2
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.AWS_HOST }}
username: ubuntu
key: ${{ secrets.AWS_SSH_KEY }}
source: "myapp.tar.gz"
target: "~/"
- name: Deploy on EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_HOST }}
username: ubuntu
key: ${{ secrets.AWS_SSH_KEY }}
script: |
docker load < myapp.tar.gz
docker stop myapp || true
docker rm myapp || true
docker run -d -p 80:3000 --name myapp myapp:latest
πΉ Step 5: Test Deployment
Access app via EC2 public IP β
http://<ec2-public-ip>
Each push to main branch triggers build & deploy π
π― 20 CI/CD Interview Questions & Detailed Answers
1. What is CI/CD in DevOps?
Answer: CI (Continuous Integration) automates code build and test when developers push changes. CD (Continuous Delivery/Deployment) automates app release to staging or production. It reduces human errors, speeds up release cycles, and ensures consistent deployments.
2. Difference between Continuous Delivery vs Deployment?
Answer:
Continuous Delivery: Code is always ready to deploy but requires manual approval for production.
Continuous Deployment: Every successful pipeline automatically goes to production with no manual steps.
3. Why is CI/CD important?
Answer: It shortens development cycles, improves collaboration, reduces deployment risks, and improves customer experience with frequent updates.
4. Name popular CI/CD tools.
Answer: Jenkins, GitHub Actions, GitLab CI, Bitbucket Pipelines, CircleCI, ArgoCD.
5. How do you secure a CI/CD pipeline?
Answer: Use secret managers (AWS Secrets Manager, HashiCorp Vault), role-based access, signed artifacts, and vulnerability scanning (Trivy, Snyk).
6. What is pipeline as code?
Answer: Writing pipelines in code (e.g., Jenkinsfile
, .github/workflows/ci.yml
). Ensures version control and reusability.
7. What is Blue-Green Deployment?
Answer: Maintain two environments (Blue = live, Green = idle). Deploy new version to Green, then switch traffic. Ensures zero downtime.
8. What is Canary Deployment?
Answer: Gradually release a new version to a small % of users, monitor, and then expand. Reduces risk of failures.
9. How do you rollback in CI/CD?
Answer: Redeploy previous stable artifact, or use infrastructure automation to restore last state (Terraform, Helm rollback).
10. What is an artifact repository?
Answer: Storage for build outputs like JARs, Docker images (Nexus, Artifactory, AWS ECR, GitHub Packages).
11. What are the common stages in a CI/CD pipeline?
Answer:
Source β Code commit triggers pipeline.
Build β Compile, package, containerize app.
Test β Unit, integration, security, performance tests.
Deploy β Deploy to staging/production.
Monitor β Logs, alerts, and feedback loop.
12. What are the challenges in setting up CI/CD?
Answer:
Handling environment differences (dev vs prod).
Securing secrets and credentials.
Managing large monolithic apps.
Flaky tests causing false pipeline failures.
Cost optimization in cloud CI/CD.
13. How do you integrate testing in CI/CD?
Answer:
Use unit tests during build stage.
Integration tests on staging environment.
Security scans (SAST/DAST) integrated into pipeline.
Tools: JUnit, PyTest, Selenium, OWASP ZAP, SonarQube.
14. What is Infrastructure as Code (IaC) in CI/CD?
Answer:
IaC automates infrastructure provisioning alongside application deployment. Example: Terraform creates an AWS EC2 + S3 bucket as part of pipeline β ensuring consistency across environments.
15. How does monitoring fit into CI/CD?
Answer:
Monitoring tools (Prometheus, Grafana, CloudWatch) detect performance issues post-deployment. Integrated feedback loops help developers roll back or fix quickly, closing the DevOps lifecycle.
16. Whatβs the difference between Jenkins and GitHub Actions?
Answer:
Jenkins: Open-source, self-hosted, plugin-rich, more customizable but requires maintenance.
GitHub Actions: Cloud-native, easy integration with GitHub repos, YAML pipelines, but limited flexibility outside GitHub ecosystem.
17. How do you handle secrets in pipelines?
Answer:
Store in AWS Secrets Manager, HashiCorp Vault, or Kubernetes Secrets.
Never hardcode credentials in pipelines.
Use encrypted GitHub Secrets or Jenkins credentials plugin.
18. How do you achieve zero downtime deployment?
Answer:
Use Blue-Green deployments.
Use Rolling updates in Kubernetes.
Load balancers to gradually shift traffic without downtime.
19. Whatβs the difference between CI/CD in monoliths vs microservices?
Answer:
Monolith: One pipeline builds & deploys the whole app.
Microservices: Each service has its own pipeline β independent builds, testing, and deployments.
20. How do you measure CI/CD success?
Answer:
Deployment Frequency (how often code is released).
Lead Time for Changes (commit β production time).
Mean Time to Recover (MTTR) (rollback/recovery speed).
Change Failure Rate (deployment issues %).
These are the DORA metrics widely used in DevOps.
π Theory Expansion: CI/CD in Real-World AWS Use Cases
πΉ AWS Native CI/CD Services
CodeCommit β Source repo (like GitHub).
CodeBuild β Build & test automation.
CodeDeploy β Automated deployments (EC2, ECS, Lambda).
CodePipeline β Orchestrates the flow (source β build β deploy).
π AWS offers a fully managed CI/CD ecosystem, reducing overhead for smaller teams.
πΉ CI/CD Security Best Practices
Principle of Least Privilege (PoLP) in IAM roles.
Enable artifact signing for integrity.
Add static code analysis (SonarQube, Checkov).
Integrate container scanning with Trivy or AWS ECR scan.
πΉ Common Real-Life Scenario Asked in Interviews
Q: How would you deploy a Dockerized microservice on AWS with CI/CD?
Answer:
Developer pushes code β GitHub triggers pipeline.
GitHub Actions builds Docker image β pushes to AWS ECR.
AWS CodeDeploy or ECS updates container β runs new task.
Monitoring via CloudWatch + Prometheus for rollback triggers.
π Key Takeaways (Day 14)
βοΈ Revised Week 2 concepts: Git, CI/CD, Docker, Jenkins, GitHub Actions.
βοΈ Deployed a Docker app via GitHub Actions β AWS EC2 (hands-on).
βοΈ Answered 20 CI/CD Interview Questions with detailed theory + real-life AWS examples.
βοΈ Learned CI/CD metrics (DORA) β key in SRE/DevOps interviews.
π¬ Question for you: Do you prefer AWS-native CI/CD (CodePipeline) or third-party (Jenkins/GitHub Actions)? Why?
#DevOps #AWS #CICD #Docker #Jenkins #GitHubActions #SRE #CloudEngineer #InterviewPreparation #30DaysOfDevOps
Subscribe to my newsletter
Read articles from Tathagat Gaikwad directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
