CI/CD Pipeline
CI/CD Overview
My frequently used CI/CD pipeline. CI is performed with GitHub Actions, and CD is automated with ArgoCD.
GitHub Push → GitHub Actions (Build & Test) → Docker Registry → ArgoCD → KubernetesGitHub Actions
CI Workflow
.github/workflows/ci.yml:
| |
ArgoCD
Application Definition
| |
Manual Sync
| |
Kustomize
Directory Structure
k8s/
├── base/
│ ├── deployment.yaml
│ ├── service.yaml
│ └── kustomization.yaml
└── overlays/
├── development/
│ ├── kustomization.yaml
│ └── patches/
├── staging/
│ ├── kustomization.yaml
│ └── patches/
└── production/
├── kustomization.yaml
└── patches/Base
k8s/base/kustomization.yaml:
| |
Overlay (Production)
k8s/overlays/production/kustomization.yaml:
| |
Docker Image Build
Dockerfile
| |
Jib (Build without Dockerfile)
build.gradle.kts:
| |
Build:
| |
Deployment Process
1. Development Environment
| |
2. Staging Environment
| |
3. Production Environment
| |
Rollback
Rollback with ArgoCD
| |
Rollback with Kubernetes
| |
Monitoring
Check Deployment Status
| |
Slack Notifications
Deployment notifications from GitHub Actions to Slack:
| |
Security
1. Secrets Management
GitHub Actions Secrets:
| |
Required Secret Items:
GCP_PROJECT: GCP Project IDGCP_SA_KEY: GCP Service Account Key (JSON)DATABASE_URL: Database connection stringSLACK_WEBHOOK: Slack notification Webhook URLDOCKER_REGISTRY_TOKEN: Docker Registry authentication token
2. Container Security
Scanning image vulnerabilities with Trivy:
| |
3. Docker Layer Optimization and Security
| |
4. SAST/DAST Security Scanning
| |
5. Secret Manager Usage (Production)
Using external Secret Manager in Kubernetes:
| |
6. Deployment Permission Management
Restricting deployment permissions with RBAC:
| |
Performance
1. Docker Image Optimization
Multi-stage Build + Layer Optimization:
| |
2. Build Cache Strategy
| |
3. Parallel Build and Testing
| |
4. Conditional Builds
| |
Reliability
1. Blue-Green Deployment
| |
2. Canary Deployment
| |
3. Health Checks and Readiness
| |
4. Rollback Strategy
| |
5. Deployment Notifications and Monitoring
| |
Checklist
Security
- Are sensitive information stored in GitHub Secrets?
- Is container image vulnerability scanning enabled?
- Are containers running as non-root user?
- Is SAST/DAST security scanning performed?
- Are deployment permissions restricted with RBAC?
Performance
- Using multi-stage builds?
- Leveraging Docker Layer caching?
- Running builds/tests in parallel?
- Skipping unnecessary builds?
Reliability
- Using Blue-Green or Canary deployment?
- Are Health Checks properly configured?
- Are automatic rollback conditions defined?
- Are deployment notifications configured?
- Maintaining rollback history?
Troubleshooting
Image Pull Failure
| |
ArgoCD Sync Failure
| |