<p>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?</p>
<p>Thanks</p>

<p>If you have a <strong>CI</strong> 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.</p>
<p>However yes, you can scale <strong>UP/DOWN</strong> the deployment or application based on the custom metrics.</p>
<p>i would recommend you checking out Cloud-native project <strong>Keda</strong> : <a href="https://keda.sh/" rel="nofollow noreferrer">https://keda.sh/</a></p>
<p><strong>Keda</strong>:</p>
<blockquote>
<p>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.</p>
</blockquote>
<p><strong>Example</strong></p>
<pre><code>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}
</code></pre>
<p>Scale object ref : <a href="https://keda.sh/docs/1.4/concepts/scaling-deployments/#scaledobject-spec" rel="nofollow noreferrer">https://keda.sh/docs/1.4/concepts/scaling-deployments/#scaledobject-spec</a></p>
