<p>I am running Kubernetes cluster on GKE. Running the monolithic application and now migrating to microservices so both are running parallel on cluster.</p>

<p>A monolithic application is simple python app taking the memory of <code>200Mb</code> around.</p>

<p>K8s cluster is simple single node cluster GKE having <code>15Gb memory and 4vCPU</code>.</p>

<p>Now i am thinking to apply the HPA for my microservices and monolithic application.</p>

<p>On single node i have also installed Graylog stack which include (<code>elasticsearch, mongoDb, Graylog</code> pod). Sperated by namespace <code>Devops</code>.</p>

<p>In another namespace monitoring there is <code>Grafana, Prometheus, Alert manager</code> running. </p>

<p>There is also <code>ingress controller and cert-manager</code> running.</p>

<p>Now in default namespace there is another <code>Elasticsearch</code> for application use, <code>Redis, Rabbitmq</code> running. These all are single pod, Type <code>statefulsets</code> or <code>deployment</code> with volume.</p>

<p>Now i am thinking to apply the HPA for microservices and application. </p>

<p>Can someone suggest how to add node-pool on GKE and auto scale. When i added node in pool and deleted old node from GCP console whole cluster restarted and service goes down for while.</p>

<p>Plus i am thinking to use the <code>affinity/anti-affinity</code> so can someone suggest devide infrastructure and implement HPA.</p>

Harsh Manvar
<p>From the wording in your question, I suspect that you want to <em>move</em> your current workloads to the new pool without disruption.</p>

<p>Since this action represents a <em>voluntary disruption</em>, you can start by defining a <code>PodDisruptionBudget</code> to <a href="https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#how-disruption-budgets-work" rel="nofollow noreferrer">control the number of pods that <strong>can</strong> be evicted in this voluntary disruption operation</a>:</p>

<blockquote>
  <p>A PDB limits the number of pods of a replicated application that are down simultaneously from voluntary disruptions.</p>
</blockquote>

<p>The settings in the PDB depend on your application and your business needs, for a reference on the values to apply, you can check <a href="https://kubernetes.io/docs/tasks/run-application/configure-pdb/#think-about-how-your-application-reacts-to-disruptions" rel="nofollow noreferrer">this</a>.</p>

<p>Following this, you can <code>drain</code> the nodes where your application is scheduled since it will be <em>"protected"</em> by the budget and, <code>drain</code> uses the <a href="https://kubernetes.io/docs/tasks/administer-cluster/safely-drain-node/#the-eviction-api" rel="nofollow noreferrer">Eviction API</a> instead of directly deleting the pods, which should make evictions graceful.</p>

<p>Regarding <code>Affinity</code>, I'm not sure how it fits in the beforementioned goal that you're trying to achieve. However, there is an answer of this particular regard <a href="https://stackoverflow.com/questions/57969331/hpa-implementation-on-single-node-kubernetes-cluster#comment102349386_57969331">in the comments</a>.</p>
