<p>I have two deployment files 
1.
<strong>deployment-1.yaml</strong>
<code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: process
  labels:
    app: process
spec:
  replicas: 3
  selector:
    matchLabels:
      app: process
  template:
    metadata:
      labels:
        app: process
        version: v1
    spec:
      containers:
      - name: pull
        image: parma/k8s-php:red
        ports:
        - containerPort: 80</code></p>

<p>2.
<strong>deployment-2.yaml</strong>
<code>apiVersion: apps/v1
    kind: Deployment
metadata:
  name: process
  labels:
    app: process
spec:
  replicas: 3
  selector:
    matchLabels:
      app: process
  template:
    metadata:
      labels:
        app: process
        version: v2
    spec:
      containers:
      - name: pull
        image: parma/k8s-php:green
        ports:
        - containerPort: 80
</code></p>

<p>As i have specified two different versions in spec.template.metadata, it does not keep running 6 pods for both replica set, it only enables latest replicaset up and running.</p>

<p>Is there any way to achieve canary deployment by keeping both the replicaset in single deployment up and running with 3 pods from v1 and 3 pods from v2</p>

Paramanand Dhuri
<ol>
<li>You can't have multiple deployments with the same name. Rename them to process-v1 and process-v2.</li>
<li>You need to have different selectors for each of them. First one should have matchLabels: {app: process, version: v1}, the second one matchLabels: {app: process, version: v2}.</li>
</ol>

<p>So technically that will be two completely separate deployments. What makes them "baseline" and "canary" is how you send traffic to them. If you specify common selector (just {app: process}) in your service, then both of the deployments will see a fraction of traffic.</p>
