DevOps: From Code to Production
Automate building, testing, and deploying software - CI/CD pipelines, infrastructure as code, and operational monitoring.
0 of 5 concepts completed (0%)
What You'll Learn
Tutorial Contents
1.CI/CD Pipeline Design
Pipeline Stages ```yaml # GitHub Actions production-grade CI/CD pipeline name: CI/CD Pipeline on: push: branches: [main] pull_request: branches: [main]
jobs: # Stage 1: Code Quality (run on every PR) lint-and-type-check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 20, cache: npm } - run: npm ci - run: npm run lint - run: npm run type-check
# Stage 2: Tests (parallel for speed) test: runs-on: ubuntu-latest needs: lint-and-type-check strategy: matrix: test-suite: [unit, integration] services: postgres: image: postgres:15 env: POSTGRES_DB: testdb POSTGRES_PASSWORD: test ports: ["5432:5432"] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 20, cache: npm } - run: npm ci - run: npm run test:${{ matrix.test-suite }} -- --coverage - uses: codecov/codecov-action@v3 # track coverage over time
# Stage 3: Security Scan security: runs-on: ubuntu-latest needs: test steps: - uses: actions/checkout@v4 - run: npm audit --audit-level=high - uses: snyk/actions/node@master env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
# Stage 4: Build Docker image build: runs-on: ubuntu-latest needs: [test, security] if: github.ref == 'refs/heads/main' outputs: image-tag: ${{ steps.meta.outputs.tags }} steps: - uses: actions/checkout@v4 - uses: docker/build-push-action@v5 with: push: true tags: ghcr.io/myorg/myapp:${{ github.sha }}
# Stage 5: Deploy to staging deploy-staging: needs: build runs-on: ubuntu-latest environment: staging steps: - uses: azure/k8s-deploy@v4 with: manifests: k8s/staging/ images: ghcr.io/myorg/myapp:${{ github.sha }}
# Stage 6: Smoke tests against staging smoke-tests: needs: deploy-staging runs-on: ubuntu-latest steps: - run: npm run test:smoke -- --base-url=https://staging.example.com
# Stage 7: Production deploy (manual approval gate) deploy-production: needs: smoke-tests runs-on: ubuntu-latest environment: production # requires manual approval in GitHub steps: - uses: azure/k8s-deploy@v4 with: manifests: k8s/production/ strategy: canary percentage: 20 # start with 20% traffic ```
2.Infrastructure as Code & Monitoring
Terraform for Cloud Infrastructure ```hcl # terraform/main.tf production web app infrastructure terraform { required_providers { aws = { source = "hashicorp/aws", version = "~> 5.0" } } backend "s3" { bucket = "my-terraform-state" key = "prod/terraform.tfstate" region = "us-east-1" } }
# Variables variable "environment" { default = "production" } variable "app_name" { default = "my-app" } variable "instance_count" { default = 2 }
# ECS Service (containerized app) resource "aws_ecs_service" "app" { name = "${var.app_name}-${var.environment}" cluster = aws_ecs_cluster.main.id task_definition = aws_ecs_task_definition.app.arn desired_count = var.instance_count
deployment_circuit_breaker { enable = true rollback = true # auto-rollback on deployment failure }
load_balancer { target_group_arn = aws_lb_target_group.app.arn container_name = "app" container_port = 3000 } }
# RDS Database with automated backups resource "aws_db_instance" "postgres" { identifier = "${var.app_name}-db" engine = "postgres" engine_version = "15.3" instance_class = "db.t3.medium" allocated_storage = 100 storage_encrypted = true backup_retention_period = 7 # 7 days of backups backup_window = "03:00-04:00" maintenance_window = "sun:04:00-sun:05:00" deletion_protection = true # prevent accidental deletion tags = { Environment = var.environment, Application = var.app_name } } ```
Monitoring & Alerting ```yaml # Prometheus alert rules (alerts.yml) groups: - name: application rules: - alert: HighErrorRate expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.05 for: 2m annotations: summary: "High error rate on {{ $labels.service }}" description: "Error rate is {{ $value | humanizePercentage }}"
- alert: HighLatency expr: histogram_quantile(0.95, http_request_duration_seconds_bucket) > 0.5 for: 5m annotations: summary: "p95 latency above 500ms"
- alert: PodCrashLooping expr: rate(kube_pod_container_status_restarts_total[15m]) > 0 for: 5m annotations: summary: "Pod {{ $labels.pod }} is crash looping" ```
Code Example
// DevOps Pipeline
/**
* 1. Code Commit
* Developer pushes code to Git
*/
git push origin feature/new-feature
/**
* 2. Continuous Integration (GitHub Actions)
* - Build code
* - Run tests
* - Security scan
*/
name: CI Pipeline
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm ci
- run: npm run build
- run: npm test
- run: npm run security-scan
/**
* 3. Infrastructure as Code (Terraform)
* Define infrastructure in version control
*/
resource "aws_ec2_instance" "web_server" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
tags = {
Name = "web-server-prod"
}
}
resource "aws_rds_instance" "database" {
allocated_storage = 20
db_name = "mydb"
engine = "postgres"
instance_class = "db.t3.micro"
username = "admin"
}
/**
* 4. Continuous Deployment (Kubernetes)
* Automatically deploy after build succeeds
*/
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: app
image: myapp:latest
ports:
- containerPort: 3000
/**
* 5. Monitoring & Logging
* Track application health and performance
*/
const monitoring = {
metrics: [
'Request latency (p50, p95, p99)',
'Error rate',
'CPU and memory usage',
'Database query performance',
'Cache hit rate'
],
logging: [
'Structured logs (JSON)',
'Log aggregation (ELK stack)',
'Log search and analysis',
'Alert on errors'
],
alerting: [
'Error rate > 1%',
'Latency p99 > 500ms',
'Memory > 80%',
'Database down'
]
};
/**
* 6. Incident Response
* When alerts fire
*/
const incidentResponse = {
1: 'Alert fires (latency spike)',
2: 'On-call engineer notified',
3: 'Check logs and metrics',
4: 'Identify root cause',
5: 'Apply fix or rollback',
6: 'Post-incident review',
7: 'Implement preventative measure'
};Pro Tips
- 1Infrastructure as Code is non-negotiable. If you're SSH-ing into servers to make changes, you don't have DevOps you have a ticking time bomb.
- 2Instrument your deployments before you optimize them. You can't improve what you don't measure track deployment frequency, lead time, change failure rate, and MTTR.
- 3Feature flags decouple deployment from release. Deploy incomplete features safely, enable them per user/percentage, and roll back instantly without a redeploy.
- 4On-call rotation should include developers, not just ops. Engineers who get paged for their own code write more reliable code.
Topics Covered
Continue Learning
Explore the official documentation and deepen your knowledge with real-world practice.
Explore the Full Portfolio
This is the complete portfolio of Sufi Khan Sulaiman, a technology leader specialising in B2B commerce and digital automation. Start from the Home page for the overview, then move through two decades of career experience across FLIR Systems, Lorex Technology, and 1c Platform, and the full catalogue of project case studies spanning headless commerce migrations, AI recommendation engines, and multi-channel fulfilment systems.
The skills and certifications page maps the technical and leadership capabilities behind the work, while the articles and the knowledge base break down the thinking into actionable frameworks. For hands-on learning, the tutorials and applications sections cover practical builds from front-end fundamentals to full-stack web apps.
For consulting engagement, the expertise page outlines service offerings, the ecommerce hub covers platform architecture and automation strategy, and the ecommerce guide (PDF) is a downloadable 55-page field manual. When you are ready to talk, the contact page is the direct line.