Introduction
DevOps Essentials represents the fundamental concepts, practices, and tools that every DevOps practitioner must understand. This streamlined guide focuses on the core elements needed to implement DevOps successfully, providing quick reference for daily operations and decision-making. Whether you’re starting your DevOps journey or need a concise reference, these essentials form the foundation for efficient software delivery.
Core DevOps Concepts
What is DevOps?
DevOps combines Development and Operations to:
- Accelerate software delivery
- Improve collaboration between teams
- Increase deployment reliability
- Reduce time to market
- Enhance customer satisfaction
The DevOps Mindset
- Collaboration over Silos: Break down barriers between teams
- Automation over Manual Work: Eliminate repetitive tasks
- Measurement over Assumptions: Use data to drive decisions
- Sharing over Hoarding: Open communication and knowledge transfer
Essential DevOps Principles
The CALMS Model
| Letter | Principle | Description | Key Actions |
|---|---|---|---|
| C | Culture | Collaborative, blame-free environment | Foster trust, shared responsibility |
| A | Automation | Eliminate manual, error-prone processes | Automate builds, tests, deployments |
| L | Lean | Focus on value, minimize waste | Small batches, fast feedback |
| M | Measurement | Data-driven improvements | Monitor metrics, track performance |
| S | Sharing | Open communication and learning | Knowledge sharing, transparency |
The Three Ways of DevOps
- Flow: Optimize work from Development to Operations
- Feedback: Create fast feedback loops from right to left
- Continuous Learning: Foster experimentation and learning from failures
Essential DevOps Practices
Version Control Essentials
Git Workflow Basics:
# Daily workflow
git pull origin main # Get latest changes
git checkout -b feature-name # Create feature branch
# Make changes
git add . # Stage changes
git commit -m "Clear message" # Commit changes
git push origin feature-name # Push to remote
# Create pull request
Branching Strategy:
- Main/Master: Production-ready code
- Develop: Integration branch
- Feature branches: Individual features
- Hotfix branches: Emergency fixes
Continuous Integration (CI) Essentials
CI Pipeline Components:
- Trigger: Code commit or pull request
- Build: Compile and package code
- Test: Run automated tests
- Quality Check: Code analysis and security scans
- Artifact: Store build outputs
CI Best Practices:
- Commit frequently (multiple times per day)
- Keep builds fast (<10 minutes)
- Fix broken builds immediately
- Run tests with every commit
- Maintain clean, readable code
Continuous Deployment (CD) Essentials
CD Pipeline Flow:
Code → Build → Test → Package → Deploy → Monitor
Deployment Strategies:
| Strategy | Description | Pros | Cons |
|---|---|---|---|
| Rolling | Gradually replace instances | Resource efficient | Some downtime |
| Blue-Green | Switch between two environments | Zero downtime | Double resources |
| Canary | Deploy to small user subset | Risk mitigation | Complex setup |
Infrastructure as Code (IaC) Essentials
Core Concepts:
- Declarative: Describe desired state
- Idempotent: Same result every time
- Version Controlled: Track infrastructure changes
- Repeatable: Consistent across environments
Basic Terraform Example:
# main.tf
provider "aws" {
region = "us-west-2"
}
resource "aws_instance" "web" {
ami = "ami-0c02fb55956c7d316"
instance_type = "t2.micro"
tags = {
Name = "WebServer"
}
}
Configuration Management Essentials
Ansible Playbook Example:
---
- hosts: web
become: yes
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- name: Start nginx
service:
name: nginx
state: started
enabled: yes
Essential Tools by Category
Version Control
- Git: Distributed version control system
- GitHub/GitLab/Bitbucket: Git repository hosting platforms
CI/CD Platforms
- Jenkins: Open-source automation server
- GitHub Actions: Native GitHub CI/CD
- GitLab CI: Integrated with GitLab
- Azure DevOps: Microsoft’s DevOps platform
Containerization
- Docker: Application containerization
- Kubernetes: Container orchestration
- Docker Compose: Multi-container applications
Infrastructure as Code
- Terraform: Multi-cloud infrastructure provisioning
- Ansible: Configuration management and automation
- AWS CloudFormation: AWS-native IaC
Monitoring
- Prometheus: Metrics collection and alerting
- Grafana: Metrics visualization
- ELK Stack: Logging (Elasticsearch, Logstash, Kibana)
Docker Essentials
Basic Docker Commands
# Image management
docker build -t myapp:latest . # Build image
docker images # List images
docker rmi image-name # Remove image
# Container management
docker run -p 8080:80 myapp # Run container
docker ps # List running containers
docker stop container-id # Stop container
docker rm container-id # Remove container
# Debugging
docker logs container-id # View logs
docker exec -it container-id bash # Access shell
Essential Dockerfile
FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
EXPOSE 3000
USER node
CMD ["npm", "start"]
Docker Compose Basics
version: '3.8'
services:
web:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=production
depends_on:
- db
db:
image: postgres:13
environment:
- POSTGRES_DB=myapp
- POSTGRES_PASSWORD=secret
volumes:
- db_data:/var/lib/postgresql/data
volumes:
db_data:
Kubernetes Essentials
Core Concepts
| Object | Purpose | Example Use |
|---|---|---|
| Pod | Smallest deployable unit | Running application containers |
| Deployment | Manages pod replicas | Ensuring application availability |
| Service | Network access to pods | Load balancing, service discovery |
| ConfigMap | Configuration data | Environment variables, config files |
| Secret | Sensitive data | Passwords, API keys, certificates |
Essential kubectl Commands
# Cluster info
kubectl cluster-info
kubectl get nodes
# Pod management
kubectl get pods
kubectl describe pod pod-name
kubectl logs pod-name
kubectl delete pod pod-name
# Deployment management
kubectl create deployment myapp --image=myapp:latest
kubectl scale deployment myapp --replicas=3
kubectl rollout status deployment/myapp
# Service management
kubectl expose deployment myapp --port=80 --target-port=8080
kubectl get services
Basic Kubernetes Manifest
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myapp:latest
ports:
- containerPort: 8080
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
---
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
selector:
app: myapp
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: LoadBalancer
Monitoring Essentials
Key Metrics to Monitor
The Four Golden Signals:
- Latency: Request response time
- Traffic: System demand (requests per second)
- Errors: Failed request rate
- Saturation: Resource utilization
System Metrics:
- CPU utilization
- Memory usage
- Disk I/O
- Network throughput
- Application response times
Prometheus Configuration Example
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
- job_name: 'myapp'
static_configs:
- targets: ['localhost:8080']
Basic Alerting Rules
groups:
- name: basic-alerts
rules:
- alert: HighCPUUsage
expr: cpu_usage_percent > 80
for: 5m
labels:
severity: warning
annotations:
summary: "High CPU usage detected"
- alert: ServiceDown
expr: up == 0
for: 1m
labels:
severity: critical
annotations:
summary: "Service is down"
CI/CD Pipeline Essentials
Jenkins Pipeline Example
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git 'https://github.com/user/repo.git'
}
}
stage('Build') {
steps {
sh 'npm install'
sh 'npm run build'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
stage('Docker Build') {
steps {
sh 'docker build -t myapp:${BUILD_NUMBER} .'
}
}
stage('Deploy') {
steps {
sh 'kubectl set image deployment/myapp myapp=myapp:${BUILD_NUMBER}'
}
}
}
post {
always {
cleanWs()
}
}
}
GitHub Actions Workflow
name: CI/CD Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Build application
run: npm run build
- name: Build Docker image
run: docker build -t myapp:${{ github.sha }} .
- name: Deploy to staging
if: github.ref == 'refs/heads/main'
run: |
# Deployment commands here
echo "Deploying to staging"
Security Essentials
DevSecOps Integration Points
| Stage | Security Practice | Tools |
|---|---|---|
| Code | Static Analysis (SAST) | SonarQube, Checkmarx |
| Build | Dependency Scanning | Snyk, WhiteSource |
| Test | Dynamic Analysis (DAST) | OWASP ZAP |
| Deploy | Container Scanning | Clair, Trivy |
| Runtime | Monitoring | Falco, Sysdig |
Container Security Best Practices
# Use specific, minimal base images
FROM node:16-alpine
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -u 1001
# Set working directory
WORKDIR /app
# Copy and install dependencies first
COPY package*.json ./
RUN npm ci --only=production && npm cache clean --force
# Copy application code
COPY --chown=nextjs:nodejs . .
# Switch to non-root user
USER nextjs
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
CMD ["npm", "start"]
Common DevOps Patterns
Environment Promotion
Developer Workstation → Development → Testing → Staging → Production
Configuration Management
- Environment-specific configs: Use environment variables
- Secrets management: Use dedicated secret stores (Vault, K8s secrets)
- Feature flags: Control feature rollouts
Backup and Recovery
- Database backups: Automated, tested backups
- Infrastructure snapshots: Regular infrastructure backups
- Disaster recovery plans: Documented recovery procedures
Essential Metrics and KPIs
DORA Metrics
- Deployment Frequency: How often you deploy
- Lead Time for Changes: Time from commit to production
- Mean Time to Recovery: Time to recover from incidents
- Change Failure Rate: Percentage of deployments causing problems
Operational Metrics
- System Uptime: Availability percentage
- Response Time: Application performance
- Error Rate: Failure percentage
- Throughput: Requests handled per second
Troubleshooting Quick Reference
Common Issues and Solutions
| Problem | Symptoms | Quick Fix |
|---|---|---|
| Build Failure | Pipeline stops at build stage | Check logs, verify dependencies |
| Test Failures | Tests failing in CI | Run tests locally, check environment |
| Deployment Issues | App not starting in production | Verify configurations, check resources |
| Performance Problems | Slow response times | Check metrics, scale resources |
| Container Issues | Containers crashing | Check logs, verify resources limits |
Debug Commands
# Docker debugging
docker logs container-name
docker exec -it container-name sh
docker inspect container-name
# Kubernetes debugging
kubectl describe pod pod-name
kubectl logs pod-name
kubectl get events --sort-by=.metadata.creationTimestamp
# System debugging
htop # Process monitor
netstat -tulpn # Network connections
df -h # Disk usage
free -m # Memory usage
Getting Started Checklist
Week 1: Foundation
- [ ] Set up Git repository with branching strategy
- [ ] Configure basic CI pipeline
- [ ] Create Dockerfile for application
- [ ] Set up development environment
Week 2: Automation
- [ ] Implement automated testing
- [ ] Configure CD pipeline
- [ ] Set up basic monitoring
- [ ] Create infrastructure as code
Week 3: Enhancement
- [ ] Add security scanning
- [ ] Implement logging
- [ ] Configure alerts
- [ ] Document processes
Week 4: Optimization
- [ ] Review and optimize pipelines
- [ ] Implement advanced deployment strategies
- [ ] Set up comprehensive monitoring
- [ ] Train team members
Essential Resources
Documentation
- Docker Docs: https://docs.docker.com
- Kubernetes Docs: https://kubernetes.io/docs
- Git Handbook: https://guides.github.com
- Terraform Docs: https://www.terraform.io/docs
Learning Platforms
- Katacoda: Interactive DevOps scenarios
- Play with Docker: Free Docker playground
- Kubernetes by Example: Hands-on K8s tutorials
- DevOps Roadmap: Step-by-step learning path
Communities
- DevOps.com: News and best practices
- Reddit r/devops: Community discussions
- Stack Overflow: Technical Q&A
- CNCF: Cloud Native Computing Foundation
Quick Command Reference
Git Essentials
git status # Check repository status
git add . # Stage all changes
git commit -m "message" # Commit changes
git push origin main # Push to remote
git pull origin main # Pull latest changes
git branch # List branches
git checkout -b name # Create new branch
Docker Essentials
docker build -t name . # Build image
docker run -p 8080:80 name # Run container
docker ps # List containers
docker images # List images
docker logs container-id # View logs
docker stop container-id # Stop container
Kubernetes Essentials
kubectl get pods # List pods
kubectl describe pod name # Pod details
kubectl logs pod-name # View logs
kubectl apply -f file.yaml # Apply manifest
kubectl delete pod name # Delete pod
kubectl get services # List services
Memory Aids
DevOps Acronyms
- CI/CD: Continuous Integration/Continuous Deployment
- IaC: Infrastructure as Code
- DORA: DevOps Research and Assessment
- SRE: Site Reliability Engineering
- MTTR: Mean Time To Recovery
- MTBF: Mean Time Between Failures
Remember CALMS
- Culture: Collaboration and trust
- Automation: Eliminate manual work
- Lean: Focus on value delivery
- Measurement: Data-driven decisions
- Sharing: Open communication
This essentials cheatsheet provides the core knowledge needed to implement and operate DevOps practices effectively, serving as a quick reference for daily DevOps activities.
