<p>I have two <code>kind: Deployment</code> in my <code>yaml</code> file
The main one</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: accounts-management-service
  labels:
    app: accounts-management-service
spec:
  replicas: $($env:WEB_REPLICAS)
  selector:
    matchLabels:
      app: accounts-management-service
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 20%
      maxUnavailable: 10%
  progressDeadlineSeconds: 3600
  template:
    metadata:
      labels:
        app: accounts-management-service
    spec:
      containers:
        - image: registry$(GetHash).azurecr.io/$(GetContext 'ApplicationContainerName')
          name: accounts-management-service
          command: [&quot;npm&quot;]
          args: [&quot;run&quot;, &quot;start:production:web&quot;]
          resources:
            requests:
              memory: &quot;500Mi&quot;
              cpu: &quot;1000m&quot;
            limits:
              memory: &quot;4096Mi&quot;
              cpu: &quot;1001m&quot;
          env:
            - name: CONFIG_DEPLOYMENT_UNIT
              value: $(GetContext 'DeploymentUnit')
            - name: NODE_ENV
              value: $(GetContext 'DeploymentUnit')
            - name: TENANT
              value: &quot;$(GetContext 'DeploymentUnit' | Format -NoHyphens)$(GetContext 'Cluster')&quot;
            - name: ROLE
              value: $(GetContext 'Cluster')
          ports:
            - containerPort: 1337
              protocol: TCP
          volumeMounts:
            - name: secret-agent
              mountPath: /var/run/secret-agent
          readinessProbe:
            httpGet:
              path: /v0.1/status
              port: 1337
            successThreshold: 2
            failureThreshold: 3
            initialDelaySeconds: 60
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /v0.1/status_without_db
              port: 1337
            failureThreshold: 3
            initialDelaySeconds: 60
            periodSeconds: 30
      volumes:
        - name: secret-agent
          hostPath:
            path: /var/run/secret-agent
            type: DirectoryOrCreate
</code></pre>
<p>and the second one</p>
<pre><code># second
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: accounts-management-service-second
  labels:
    app: accounts-management-service-second
spec:
  replicas: $($env:second_REPLICAS)
  selector:
    matchLabels:
      app: accounts-management-service-second
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 10%
      maxUnavailable: 10%
  template:
    metadata:
      labels:
        app: accounts-management-service-second
    spec:
      containers:
        - image: registry$(GetHash).azurecr.io/$(GetContext 'ApplicationContainerName')
          name: accounts-management-service-second
          command: [&quot;npm&quot;]
          args: [&quot;run&quot;, &quot;start:production:second&quot;]
          resources:
            requests:
              memory: &quot;500Mi&quot;
              cpu: &quot;250m&quot;
            limits:
              memory: &quot;8192Mi&quot;
              cpu: &quot;1001m&quot;
          env:
            - name: CONFIG_DEPLOYMENT_UNIT
              value: $(GetContext 'DeploymentUnit')
            - name: NODE_ENV
              value: $(GetContext 'DeploymentUnit')
            - name: TENANT
              value: &quot;$(GetContext 'DeploymentUnit' | Format -NoHyphens)$(GetContext 'Cluster')&quot;
            - name: ROLE
              value: $(GetContext 'Cluster')
          ports:
            - containerPort: 1337
              protocol: TCP
          volumeMounts:
            - name: secret-agent
              mountPath: /var/run/secret-agent
          readinessProbe:
            httpGet:
              path: /status
              port: 1337
            initialDelaySeconds: 60
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /status
              port: 1337
            initialDelaySeconds: 60
            periodSeconds: 10
      volumes:
        - name: secret-agent
          hostPath:
            path: /var/run/secret-agent
            type: DirectoryOrCreate
</code></pre>
<p>They both point to the same volume path. I am new to Kubernetes and I am trying to understand the relation between pod creation and two <code>kind: Deployment</code>s. It would be nice if someone can explain thos. I hope that this falls into the SO allowed questions category.</p>

MikiBelavista
<p>Basically Deployments find out which pods they are managing by labels defined in the deployments spec section as well as under .spec.template.spec section.</p>
<p>Deployments check for running pods that match the supplied labels while figuring out whether the available replica count is the desired replica count.</p>
<p>If desired count &gt; available count the DeploymentController creates a new pod based on the template section (actually, the deployment controls a ReplicaSet which in turn controls the pods, but this is additional knowledge not really needed for your understanding). However, deployments do not only create and delete pods based on the template. If there are already pods running in the namespace the deployment is on which matches the labels specified in your deployment, it will count this pod as being part of your deployment and towards the available replicas.</p>
<p>Hope this clarifies your understanding of deployments a bit.</p>
