DevOps & Infrastructure Guide
Master modern DevOps practices, containerization, orchestration, and cloud platforms.
Quick Start
Docker Basics
# Dockerfile example
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "index.js"]
Kubernetes Deployment
# Simple K8s deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-deployment
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myapp:1.0
ports:
- containerPort: 3000
Terraform Infrastructure
# AWS EC2 with Terraform
resource "aws_instance" "web" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
tags = {
Name = "web-server"
}
}
DevOps Technology Stack
Containerization
- Docker: Images, containers, registry
- Docker Compose: Multi-container orchestration
- Image Security: Scanning, signing, base image selection
- Best Practices: Minimal images, layer caching, security
Container Orchestration
- Kubernetes: Pods, Services, Deployments, StatefulSets
- Helm: Package management for Kubernetes
- Service Mesh: Istio, Linkerd for networking
- Container Security: RBAC, NetworkPolicies, Pod Security
Infrastructure as Code
# Terraform modules
module "network" {
source = "./modules/network"
vpc_cidr = "10.0.0.0/16"
public_subnets = [
"10.0.1.0/24",
"10.0.2.0/24"
]
}
- Terraform: HCL, state management, modules
- Ansible: Agentless configuration management
- CloudFormation: AWS native IaC
- Pulumi: Infrastructure as code with programming languages
Cloud Platforms
AWS
- Compute: EC2, ECS, EKS, Lambda
- Storage: S3, EBS, EFS
- Database: RDS, DynamoDB, ElastiCache
- Networking: VPC, ALB, CloudFront
- Security: IAM, KMS, Secrets Manager
Other Platforms
- Google Cloud Platform: Compute Engine, Cloud Run, GKE
- Azure: VMs, App Service, AKS
- DigitalOcean: Simpler alternative, good for learning
CI/CD Pipelines
Popular Platforms
- GitHub Actions: Integrated with GitHub
- GitLab CI: GitLab native CI/CD
- Jenkins: Self-hosted, highly customizable
- CircleCI: Cloud-based, easy setup
# GitHub Actions example
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: npm test
- name: Build
run: npm run build
- name: Deploy
run: ./deploy.sh
Monitoring & Logging
Monitoring
- Prometheus: Metrics collection
- Grafana: Visualization and dashboards
- Datadog: Cloud monitoring service
- New Relic: Application performance monitoring
Logging
- ELK Stack: Elasticsearch, Logstash, Kibana
- Splunk: Log aggregation and analysis
- Cloudwatch: AWS native logging
Alerting
- PagerDuty: On-call management
- Alertmanager: Prometheus alerting
- Opsgenie: Alert and incident response
Linux Administration
System Management
# Common commands
systemctl start/stop/restart service-name
journalctl -u service-name # View logs
ps aux | grep process-name # Process info
top/htop # System monitoring
- User and permission management
- Package managers (apt, yum, pacman)
- Systemd services
- Shell scripting and automation
- Network configuration
DevOps Workflow
Development → Production
- Plan: Design infrastructure
- Code: Write application and IaC
- Build: Containerize, create artifacts
- Test: Unit, integration, security tests
- Deploy: Stage and production deployment
- Monitor: Metrics, logs, alerts
- Optimize: Performance tuning
Deployment Strategies
- Blue-Green: Two identical environments
- Canary: Gradual rollout to subset
- Rolling: Gradually replace old version
- Feature Flags: Toggle features safely
Security Best Practices
Container Security
- Scan images for vulnerabilities
- Run as non-root user
- Use minimal base images
- Sign images
Infrastructure Security
- Network policies and firewalls
- Encryption in transit and at rest
- Secrets management
- IAM principle of least privilege
Learning Resources
Hands-On Platforms
- Katakoda: Interactive learning environments (archived)
- Play with Docker: Browser-based Docker practice
- Linux Academy: DevOps courses
- A Cloud Guru: AWS and cloud courses
Official Documentation
Practice Projects
- Docker Multi-container App - Docker Compose setup
- Kubernetes Deployment - Deploy app with services
- Terraform Infrastructure - Complete AWS setup
- CI/CD Pipeline - Build and deploy workflow
- Monitoring Stack - Prometheus + Grafana
Next Steps
- Learn Docker fundamentals
- Practice Kubernetes basics
- Choose cloud platform (AWS recommended)
- Learn Infrastructure as Code (Terraform)
- Set up CI/CD pipeline
- Implement monitoring and logging
- Master Linux administration
Roadmap.sh Reference: https://roadmap.sh/devops
Status: ✅ Production Ready | SASMP: v1.3.0 | Bonded Agent: 03-devops-cloud-specialist
1---2name: devops-guide3description: Comprehensive DevOps and infrastructure guide covering Docker, Kubernetes, AWS, Terraform, CI/CD pipelines, Linux, and cloud deployment strategies. Use when setting up infrastructure, automation, or deployment systems.4---56# DevOps & Infrastructure Guide78Master modern DevOps practices, containerization, orchestration, and cloud platforms.910## Quick Start1112### Docker Basics13```dockerfile14# Dockerfile example15FROM node:18-alpine16WORKDIR /app17COPY package*.json ./18RUN npm install19COPY . .20EXPOSE 300021CMD ["node", "index.js"]22```2324### Kubernetes Deployment25```yaml26# Simple K8s deployment27apiVersion: apps/v128kind: Deployment29metadata:30 name: app-deployment31spec:32 replicas: 333 selector:34 matchLabels:35 app: myapp36 template:37 metadata:38 labels:39 app: myapp40 spec:41 containers:42 - name: myapp43 image: myapp:1.044 ports:45 - containerPort: 300046```4748### Terraform Infrastructure49```hcl50# AWS EC2 with Terraform51resource "aws_instance" "web" {52 ami = "ami-0c55b159cbfafe1f0"53 instance_type = "t2.micro"5455 tags = {56 Name = "web-server"57 }58}59```6061## DevOps Technology Stack6263### Containerization64- **Docker**: Images, containers, registry65- **Docker Compose**: Multi-container orchestration66- **Image Security**: Scanning, signing, base image selection67- **Best Practices**: Minimal images, layer caching, security6869### Container Orchestration70- **Kubernetes**: Pods, Services, Deployments, StatefulSets71- **Helm**: Package management for Kubernetes72- **Service Mesh**: Istio, Linkerd for networking73- **Container Security**: RBAC, NetworkPolicies, Pod Security7475### Infrastructure as Code76```hcl77# Terraform modules78module "network" {79 source = "./modules/network"80 vpc_cidr = "10.0.0.0/16"8182 public_subnets = [83 "10.0.1.0/24",84 "10.0.2.0/24"85 ]86}87```8889- **Terraform**: HCL, state management, modules90- **Ansible**: Agentless configuration management91- **CloudFormation**: AWS native IaC92- **Pulumi**: Infrastructure as code with programming languages9394### Cloud Platforms9596#### AWS97- **Compute**: EC2, ECS, EKS, Lambda98- **Storage**: S3, EBS, EFS99- **Database**: RDS, DynamoDB, ElastiCache100- **Networking**: VPC, ALB, CloudFront101- **Security**: IAM, KMS, Secrets Manager102103#### Other Platforms104- **Google Cloud Platform**: Compute Engine, Cloud Run, GKE105- **Azure**: VMs, App Service, AKS106- **DigitalOcean**: Simpler alternative, good for learning107108### CI/CD Pipelines109110#### Popular Platforms111- **GitHub Actions**: Integrated with GitHub112- **GitLab CI**: GitLab native CI/CD113- **Jenkins**: Self-hosted, highly customizable114- **CircleCI**: Cloud-based, easy setup115116```yaml117# GitHub Actions example118name: Deploy119on:120 push:121 branches: [main]122123jobs:124 deploy:125 runs-on: ubuntu-latest126 steps:127 - uses: actions/checkout@v2128 - name: Run tests129 run: npm test130 - name: Build131 run: npm run build132 - name: Deploy133 run: ./deploy.sh134```135136### Monitoring & Logging137138#### Monitoring139- **Prometheus**: Metrics collection140- **Grafana**: Visualization and dashboards141- **Datadog**: Cloud monitoring service142- **New Relic**: Application performance monitoring143144#### Logging145- **ELK Stack**: Elasticsearch, Logstash, Kibana146- **Splunk**: Log aggregation and analysis147- **Cloudwatch**: AWS native logging148149#### Alerting150- **PagerDuty**: On-call management151- **Alertmanager**: Prometheus alerting152- **Opsgenie**: Alert and incident response153154### Linux Administration155156#### System Management157```bash158# Common commands159systemctl start/stop/restart service-name160journalctl -u service-name # View logs161ps aux | grep process-name # Process info162top/htop # System monitoring163```164165- User and permission management166- Package managers (apt, yum, pacman)167- Systemd services168- Shell scripting and automation169- Network configuration170171## DevOps Workflow172173### Development → Production1741751. **Plan**: Design infrastructure1762. **Code**: Write application and IaC1773. **Build**: Containerize, create artifacts1784. **Test**: Unit, integration, security tests1795. **Deploy**: Stage and production deployment1806. **Monitor**: Metrics, logs, alerts1817. **Optimize**: Performance tuning182183### Deployment Strategies184- **Blue-Green**: Two identical environments185- **Canary**: Gradual rollout to subset186- **Rolling**: Gradually replace old version187- **Feature Flags**: Toggle features safely188189## Security Best Practices190191### Container Security192- Scan images for vulnerabilities193- Run as non-root user194- Use minimal base images195- Sign images196197### Infrastructure Security198- Network policies and firewalls199- Encryption in transit and at rest200- Secrets management201- IAM principle of least privilege202203## Learning Resources204205### Hands-On Platforms206- **Katakoda**: Interactive learning environments (archived)207- **Play with Docker**: Browser-based Docker practice208- **Linux Academy**: DevOps courses209- **A Cloud Guru**: AWS and cloud courses210211### Official Documentation212- [Kubernetes Docs](https://kubernetes.io/docs/)213- [Docker Docs](https://docs.docker.com/)214- [Terraform Docs](https://www.terraform.io/docs/)215- [AWS Documentation](https://docs.aws.amazon.com/)216217### Practice Projects2181. **Docker Multi-container App** - Docker Compose setup2192. **Kubernetes Deployment** - Deploy app with services2203. **Terraform Infrastructure** - Complete AWS setup2214. **CI/CD Pipeline** - Build and deploy workflow2225. **Monitoring Stack** - Prometheus + Grafana223224## Next Steps2252261. Learn Docker fundamentals2272. Practice Kubernetes basics2283. Choose cloud platform (AWS recommended)2294. Learn Infrastructure as Code (Terraform)2305. Set up CI/CD pipeline2316. Implement monitoring and logging2327. Master Linux administration233234**Roadmap.sh Reference**: https://roadmap.sh/devops235236---237238**Status**: ✅ Production Ready | **SASMP**: v1.3.0 | **Bonded Agent**: 03-devops-cloud-specialist