1

Is it possible to scale down a pod to 0 replicas when other pod is down?I'm familiar with the basics of the Horizontal Auto-Scaling concept, but as I understand it scales pod up or down only when demands for resources (CPU, memory) changes. My CI pipeline follows a green/blue pattern, so when the new version of the application is being deployed the second one is scaled down to 0 replicas, leaving other pods belonging to the same environment up wasting resources. Do you have any idea how to solve it using kubernetes or helm features?

Thanks

TheRocket
  • 145
  • 2
  • 10

1 Answers1

1

If you have a CI pipeline you can just run the kubectl command and scale down the deployment before deploying the blue-green this way no resource wasting will be there.

However yes, you can scale UP/DOWN the deployment or application based on the custom metrics.

i would recommend you checking out Cloud-native project Keda : https://keda.sh/

Keda:

KEDA is a Kubernetes-based Event Driven Autoscaler. With KEDA, you can drive the scaling of any container in Kubernetes based on the number of events needing to be processed.

Example

apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
  name: {scaled-object-name}
spec:
  scaleTargetRef:
    deploymentName: {deployment-name} # must be in the same namespace as the ScaledObject
    containerName: {container-name}  #Optional. Default: deployment.spec.template.spec.containers[0]
  pollingInterval: 30  # Optional. Default: 30 seconds
  cooldownPeriod:  300 # Optional. Default: 300 seconds
  minReplicaCount: 0   # Optional. Default: 0
  maxReplicaCount: 100 # Optional. Default: 100
  triggers:
  # {list of triggers to activate the deployment}

Scale object ref : https://keda.sh/docs/1.4/concepts/scaling-deployments/#scaledobject-spec

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
  • Thank you for your reply, unfortunately both solutions can't be applied to my case. I work in a company with strict rules, and I don't have direct access to kubectl command, because it is wrapped somewhere in ansible playbook which I can't modify. Second option can't be applied as well, because I don't have privileges to install anything on GKE – TheRocket May 04 '22 at 07:25
  • 1
    apart of that even i am not about other option if you have limited access to the cluster. – Harsh Manvar May 04 '22 at 08:48