DevOps And Deployment Flashcards
(10 cards)
What is CI/CD, and why is it used in software development?
CI/CD stands for Continuous Integration/Continuous Deployment. CI automates testing on code changes; CD automates deployment. Example: GitHub Actions runs tests on push, deploys to AWS on merge. Reduces bugs, speeds releases.
How do you configure a basic CI pipeline with GitHub Actions?
```yaml
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with: { node-version: ‘16’ }
- run: npm install
- run: npm test
Explanation: Tests Node.js app on every push, ensuring code quality (O(1) setup).”
What is Kubernetes, and what problem does it solve?
Kubernetes orchestrates containers for scalability and reliability. Example: kubectl apply -f deployment.yaml
deploys a Node.js app across clusters. Solves: Load balancing, auto-scaling.
How does a load balancer work in deployment?
A load balancer distributes traffic across servers. Example: AWS ELB routes requests to multiple EC2 instances running a Node.js API, improving availability and throughput.
What is blue-green deployment, and its benefits?
Blue-green deployment runs two environments (blue, green); traffic switches to the new version (green) after testing. Example: Swap ECS services in AWS. Benefits: Zero downtime, easy rollback.
How do you manage environment variables in a Node.js app?
”```javascript
require(‘dotenv’).config();
const dbUrl = process.env.DB_URL;
Explanation: Loads variables from .env (e.g., DB_URL=postgres://…) for secure configuration.” “
How do you write a Dockerfile for a Node.js application?
”,”```dockerfile FROM node:16 WORKDIR /app COPY package*.json ./ RUN npm install COPY . . EXPOSE 3000 CMD [‘node’, ‘index.js’]
Explanation: Builds a containerized Node.js app, exposes port 3000.
What is Docker, and how does it simplify deployment?
Docker packages apps with dependencies into containers for consistent environments. Example: docker run -p 3000:3000 my-app runs a Node.js app identically in dev and prod.”
What is a CDN, and how does it improve full-stack apps?
A CDN (Content Delivery Network) caches static assets (e.g., React JS/CSS) on edge servers. Example: Cloudflare serves frontend assets, reducing latency for users.”
How do you monitor a production backend application?
Use Prometheus for metrics (e.g., API latency) and Grafana for visualization. Example: Log errors with Winston in Node.js, alert on high error rates.”