apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-nginx-1
  namespace: my-nginx-1
spec:
  selector:
    matchLabels:
      run: my-nginx-1
  replicas: 2
  template:
    metadata:
      labels:
        run: my-nginx-1
    spec:
      containers:
      - name: my-nginx-1
        image: nginx
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: my-nginx-1
  namespace: my-nginx-1
  labels:
    run: my-nginx-1
spec:
  ports:
  - port: 80
    protocol: TCP
  selector:
    run: my-nginx-1
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-nginx-2
  namespace: my-nginx-2
spec:
  selector:
    matchLabels:
      run: my-nginx-2
  replicas: 2
  template:
    metadata:
      labels:
        run: my-nginx-2
    spec:
      containers:
      - name: my-nginx-2
        image: nginx
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: my-nginx-2
  namespace: my-nginx-2
  labels:
    run: my-nginx-2
spec:
  ports:
  - port: 80
    protocol: TCP
  selector:
    run: my-nginx-2