<p>When you have a StatefulSet or a Deployment you usually have means to provide commands that will be fed into a pod's container on its creation.</p>
<p>Is it possible, more arguments to be injected into the commands array as the deployment autoscales with say an HPA or remove certain if it downscales?</p>
<p>For example, here if you want to allow nsqlookupd to scale out (another deployment), then you'd have to register its new pod IPs into the command list of a nsqAdmin pod.</p>
<pre><code>command:
   - /nsqd
   - -data-path
   - /data
   - -lookupd-tcp-address
   - nsqlookupd-0.nsqlookupd:4160
   - -lookupd-tcp-address
   - nsqlookupd-1.nsqlookupd:4160
   - -lookupd-tcp-address
   - nsqlookupd-2.nsqlookupd:4160
    ...
</code></pre>
<p>The situation is hypothetical, as you need to reach a crazy-high amount of queues I guess to have the need to extend beyond 3 nsqlookupd-s (NSQ's queue discovery svc) so for moderate loads, a fixed count of looupd-s will do. Even so, I wonder how such type of automated scaling in an extreme case that can be handled in Kubernetes.</p>
<p>Especially for event-driven systems, there must be use cases, this is the closest I could think of.</p>

KDX2
<p>This question is more rather more about an option on how to scale certain services in Kubernetes. I think the best pattern for this is to have a <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/operator/" rel="nofollow noreferrer">Kubernetes Operator</a>. Essentially, this would manage the lifecycle of your nsqd application. There are several operator tools that you can use to create your nsqd operator:</p>
<ul>
<li><a href="https://github.com/operator-framework/getting-started" rel="nofollow noreferrer">Operator Framework</a></li>
<li><a href="https://kudo.dev/" rel="nofollow noreferrer">KUDO</a></li>
<li><a href="https://book.kubebuilder.io/" rel="nofollow noreferrer">Kubebuilder</a></li>
<li><a href="https://metacontroller.app/" rel="nofollow noreferrer">Metacontroller</a></li>
</ul>
<p>A good example of a scale-out operator is <a href="https://strimzi.io/" rel="nofollow noreferrer">Srimzi</a> which is Kafka operator for Kubernetes.</p>
<p>You can also find other well-known operators in the <a href="https://operatorhub.io/" rel="nofollow noreferrer">Operator Hub</a>.</p>
