Deployment Guide

Table of Contents

Overview

This guide walks you through the process of safely deploying applications to production environments. It covers preparation, best‑practice strategies, continuous integration pipelines, and rollback methods.

Prerequisites

Deployment Strategies

Choose the strategy that matches your risk tolerance and architecture.

Blue/Green Deployment

# Example using AWS Elastic Beanstalk
eb create blue-env
eb create green-env
# Swap CNAME when ready
eb swap blue-env green-env

Canary Releases

# Kubernetes canary using Argo Rollouts
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: my-app
spec:
  strategy:
    canary:
      steps:
      - setWeight: 10
      - pause: {duration: 5m}
      - setWeight: 30
      - pause: {duration: 5m}
      - setWeight: 100

Rolling Update

# Docker Swarm rolling update
docker service update \
  --image myapp:1.2.0 \
  --update-parallelism 2 \
  --update-delay 10s \
  myapp_service

CI/CD Integration

Automate builds, tests, and deployments using pipelines. Below is a GitHub Actions example for Docker deployments.

name: CI/CD Pipeline
on:
  push:
    branches: [ main ]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to DockerHub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USER }}
          password: ${{ secrets.DOCKER_PASS }}
      - name: Build and push
        uses: docker/build-push-action@v4
        with:
          context: .
          push: true
          tags: myrepo/myapp:latest
      - name: Deploy to Kubernetes
        uses: azure/k8s-deploy@v4
        with:
          manifests: k8s/deployment.yaml
          images: myrepo/myapp:latest
          kubectl-version: 'v1.27.0'
          namespace: production

Rollback Procedures

In case of a failed deployment, revert to the previous stable version.

Docker

# Revert to previous image tag
docker service update \
  --image myapp:1.1.0 \
  myapp_service

Kubernetes

# Rollback using rollout undo
kubectl rollout undo deployment/my-app --to-revision=2

FAQ

How do I test a deployment without affecting users?
Use a staging environment that mirrors production. Deploy there first and run integration tests before promoting to production.
What monitoring should I enable?
Collect logs (e.g., ELK), metrics (Prometheus), and alerts (Grafana, PagerDuty). Track deployment success rate, latency, and error rates.

← Back to Articles