codefresh-io / k8s-canary-deployment

Performing a kubernetes deployment with canary
https://codefresh.io/kubernetes-tutorial/fully-automated-canary-deployments-kubernetes/
MIT License
18 stars 16 forks source link

Support for HPA #2

Closed rms1000watt closed 5 years ago

rms1000watt commented 5 years ago

Would you be able to add support for Horizontal Pod Autoscalers? A workflow could be something like:

  1. Check if HPA exists
  2. Backup HPA (if exists)
  3. Delete HPA
  4. Do the normal canary deployment process
  5. Deploy backed-up HPA with updated deployment version

Example deployment, service, HPA (not tested)

kind: Deployment
apiVersion: apps/v1
metadata:
  name: app-name-0.0.0
  labels:
    service: app-name
spec:
  selector:
    matchLabels:
      service: app-name
  replicas: 6
  template:
    metadata:
      labels:
        service: app-name
    spec:
      containers:
        - name: app-name
          image: 000000000000.dkr.ecr.us-east-1.amazonaws.com/app-name
          ports:
          - containerPort: 9000
---
kind: Service
apiVersion: v1
metadata:
  name: app-name
  labels:
    service: app-name
    version: 0.0.0
spec:
  ports:
  - name: http
    port: 9000
    protocol: TCP
    targetPort: 9000
  selector:
    service: app-name
---
kind: HorizontalPodAutoscaler
apiVersion: autoscaling/v2beta1
metadata:
  name: app-name
spec:
  scaleTargetRef:
    apiVersion: apps/v1beta1
    kind: Deployment
    name: app-name-0.0.0
  minReplicas: 6
  maxReplicas: 12
  metrics:
  - type: Resource
    resource:
      name: cpu
      targetAverageUtilization: 40
kostis-codefresh commented 5 years ago

Yes, we can add this. We are currently discussing internally if we are going to proceed with the current design of the canary step or if it is time to re-write it in Go/Python.

rms1000watt commented 5 years ago

https://github.com/codefresh-io/k8s-canary-deployment/pull/7 should be taken care of here

kostis-codefresh commented 5 years ago

Thank you.