apiVersion: apps/v1
kind: Deployment
metadata:
  name: foo-v1
spec:
  replicas: 2
  selector:
    matchLabels:
      app: foo
      version: v1
  template:
    metadata:
      labels:
        app: foo
        version: v1
    spec:
      containers:
      - name: whereami
        image: us-docker.pkg.dev/google-samples/containers/gke/whereami:v1.2.20
        ports:
          - containerPort: 8080
        env:
        - name: METADATA
          value: "foo-v1"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: foo-v2
spec:
  replicas: 2
  selector:
    matchLabels:
      app: foo
      version: v2
  template:
    metadata:
      labels:
        app: foo
        version: v2
    spec:
      containers:
      - name: whereami
        image: us-docker.pkg.dev/google-samples/containers/gke/whereami:v1.2.20
        ports:
          - containerPort: 8080
        env:
        - name: METADATA
          value: "foo-v2"
---
apiVersion: v1
kind: Service
metadata:
  name: foo-svc
spec:
  selector:
    app: foo
    version: v1
  ports:
  - port: 8080
    targetPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: foo-v1
spec:
  selector:
    app: foo
    version: v1
  ports:
  - port: 8080
    targetPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: foo-v2
spec:
  selector:
    app: foo
    version: v2
  ports:
  - port: 8080
    targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: bar-v1
spec:
  replicas: 2
  selector:
    matchLabels:
      app: bar
      version: v1
  template:
    metadata:
      labels:
        app: bar
        version: v1
    spec:
      containers:
      - name: whereami
        image: us-docker.pkg.dev/google-samples/containers/gke/whereami:v1.2.20
        ports:
          - containerPort: 8080
        env:
        - name: METADATA
          value: "bar-v1"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: bar-v2
spec:
  replicas: 2
  selector:
    matchLabels:
      app: bar
      version: v2
  template:
    metadata:
      labels:
        app: bar
        version: v2
    spec:
      containers:
      - name: whereami
        image: us-docker.pkg.dev/google-samples/containers/gke/whereami:v1.2.20
        ports:
          - containerPort: 8080
        env:
        - name: METADATA
          value: "bar-v2"
---
apiVersion: v1
kind: Service
metadata:
  name: bar-svc
spec:
  selector:
    app: bar
    version: v1
  ports:
  - port: 8080
    targetPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: bar-svc-canary
spec:
  selector:
    app: bar
    version: v2
  ports:
  - port: 8080
    targetPort: 8080
