How do I do progressive delivery for Deployments in Kubernetes with Argo CD?

Progressive delivery in Kubernetes with Argo CD allows teams to roll out applications gradually, ensuring reliability and reducing risks. This approach helps in releasing features to a subset of users before a full rollout, allowing for testing and measuring the impact effectively.
Kubernetes, Argo CD, Progressive Delivery, Continuous Deployment, Canary Releases, Deployment Strategies

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 5  # Total replicas
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-app-container
        image: my-app-image:latest
---
apiVersion: service/v1
kind: Service
metadata:
  name: my-app-service
spec:
  selector:
    app: my-app
  ports:
  - port: 80
    targetPort: 8080
    protocol: TCP
    name: http
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: my-app-rollout
spec:
  replicas: 10  # New replicas for progressive delivery
  strategy:
    canary:
      steps:
      - setWeight: 20  # First step, 20% traffic to new version
      - pause: {}
      - setWeight: 50  # Second step, increase to 50% traffic
      - pause: {}
      - setWeight: 100  # Final step, 100% traffic to new version
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-app-container
        image: my-app-image:v2  # New version
    

Kubernetes Argo CD Progressive Delivery Continuous Deployment Canary Releases Deployment Strategies