<p>Is there any way I can have an AWS deployment using kubernetes where I have a variable and scalable number of pods for my app BUT the environment on the VM is different for a single host?</p>
<p>Basically I want that one of my pods doing a task that no of the other pods will do all the time. I am planning to control this using an environment variable.</p>

Matias Barrios
<p>You can have multiple deployments, however if you are in need of <code>uniqueness</code> between the pods, you should consider <code>statefulsets</code> over deployments. However, deciding between <code>statefulset</code> and <code>deployment</code> is <strong>mostly decided by the type of the application and it is a major decision.</strong> so, using <code>statefulset</code> may not fit in as a 100% replacement for  a deployment.</p>
<p>In <code>statefulsets</code> each pod get its unique but non-random identity via its hostname.</p>
<p>For example, you can create a <code>mysql</code> statefulset using following:</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  creationTimestamp: null
  labels:
    app: foo
  name: foo
spec:
  serviceName: mysql
  replicas: 3
  selector:
    matchLabels:
      app: foo
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: foo
    spec:
      containers:
      - image: mysql
        name: mysql
      containers:
      - env:
        - name: MYSQL_ROOT_PASSWORD
          value: root
        image: mysql
        name: mysql
</code></pre>
<p>This would create three replicas of the pod:</p>
<pre><code>k get pod -l app=foo
NAME    READY   STATUS    RESTARTS   AGE
foo-0   1/1     Running   0          5m17s
foo-1   1/1     Running   0          5m14s
foo-2   1/1     Running   0          5m10s
</code></pre>
<p>Now you can fetch the hostname of the pods, the first pod will be always suffixed with <code>0</code> and 2nd with <code>1</code> and so on.</p>
<pre><code>exec -it foo-0 --  hostname
foo-0
k exec -it foo-1 --  hostname
foo-1
k exec -it foo-2 --  hostname
foo-2
</code></pre>
<p>you can use <code>hostname</code> as selector do decide what action is required on which pod.  <a href="https://stackoverflow.com/a/41733207/6309601">Here</a> is one very good read on this.</p>
