apiVersion: v1
kind: Namespace
metadata:
  name: default
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: foo
  namespace: default
spec:
  replicas: 2
  selector:
    matchLabels:
      app: foo
  template:
    metadata:
      labels:
        app: foo
    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"
---
apiVersion: v1
kind: Service
metadata:
  name: foo-svc
  namespace: default
  annotations:
    cloud.google.com/neg: '{"exposed_ports": {"80":{}}}'
spec:
  selector:
    app: foo
  ports:
  - port: 80
    targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: bar
  namespace: default
spec:
  replicas: 2
  selector:
    matchLabels:
      app: bar
  template:
    metadata:
      labels:
        app: bar
    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"
---
apiVersion: v1
kind: Service
metadata:
  name: bar-svc
  namespace: default
  annotations:
    cloud.google.com/neg: '{"exposed_ports": {"80":{}}}'
spec:
  selector:
    app: bar
  ports:
  - port: 80
    targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: foo-v2
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: foo-v2
  template:
    metadata:
      labels:
        app: foo-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-v2-svc
  namespace: default
  annotations:
    cloud.google.com/neg: '{"exposed_ports": {"80":{}}}'
spec:
  selector:
    app: foo-v2
  ports:
  - port: 80
    targetPort: 8080