apiVersion: v1
kind: Namespace
metadata:
  name: bookinfo
  labels:
    istio-injection: "enabled"
spec: {}
---
# Deployment should generate a warning: two services using that deployment
# using the same port but different protocol.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: multiple-svc-multiple-prot
  namespace: bookinfo
  labels:
    app: details
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: details
      version: v1
  template:
    metadata:
      labels:
        app: details
        version: v1
    spec:
      serviceAccountName: bookinfo-details
      containers:
        - name: details
          image: docker.io/istio/examples-bookinfo-details-v1:1.15.0
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9080
---
apiVersion: v1
kind: Service
metadata:
  name: details-tcp-v1
  namespace: bookinfo
  labels:
    app: details
    service: details
spec:
  ports:
    - port: 9080
      name: tcp
      protocol: TCP
  selector:
    app: details
---
apiVersion: v1
kind: Service
metadata:
  name: details-http-v1
  namespace: bookinfo
  labels:
    app: details
    service: details
spec:
  ports:
    - port: 9080
      name: http
      protocol: HTTP
  selector:
    app: details

---
# Deployment should generate a warning: two services using that deployment
# using the same port but different protocol.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: conflicting-ports
  namespace: bookinfo
  labels:
    app: conflicting-ports
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: conflicting-ports
      version: v1
  template:
    metadata:
      labels:
        app: conflicting-ports
        version: v1
    spec:
      serviceAccountName: bookinfo-details
      containers:
        - name: details
          image: docker.io/istio/examples-bookinfo-details-v1:1.15.0
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9080
---
apiVersion: v1
kind: Service
metadata:
  name: conflicting-ports-1
  namespace: bookinfo
  labels:
    app: conflicting-ports
spec:
  ports:
    - port: 9080
      name: tcp
      targetPort: 9080
      protocol: TCP
  selector:
    app: conflicting-ports
---
apiVersion: v1
kind: Service
metadata:
  name: conflicting-ports-2
  namespace: bookinfo
  labels:
    app: conflicting-ports
spec:
  ports:
    - port: 9090
      name: http
      targetPort: 9080
      protocol: HTTP
  selector:
    app: conflicting-ports
---
# Deployment has two ports exposed, there are two services pointing to different ports.
# It shouldn't generate a warning.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: reviews-v2
  namespace: bookinfo
  labels:
    app: reviews
    version: v2
spec:
  replicas: 1
  selector:
    matchLabels:
      app: reviews
      version: v2
  template:
    metadata:
      labels:
        app: reviews
        version: v2
    spec:
      serviceAccountName: bookinfo-reviews
      containers:
        - name: reviews
          image: docker.io/istio/examples-bookinfo-reviews-v2:1.15.0
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9080
        - name: reviews-2
          image: docker.io/istio/examples-bookinfo-reviews-v2:1.15.0
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9090
---
apiVersion: v1
kind: Service
metadata:
  name: reviews-http-9080
  namespace: bookinfo
  labels:
    app: reviews
    service: reviews
spec:
  ports:
  - port: 9080
    name: http
    protocol: HTTP
  selector:
    app: reviews
---
apiVersion: v1
kind: Service
metadata:
  name: reviews-http-9090
  namespace: bookinfo
  labels:
    app: reviews
    service: reviews
spec:
  ports:
    - port: 9090
      name: http
      protocol: HTTP
  selector:
    app: reviews
---
# Deployment has no service attached. It should generate a warning.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: no-services
  namespace: bookinfo
  labels:
    app: ratings
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ratings
      version: v1
  template:
    metadata:
      labels:
        app: ratings
        version: v1
    spec:
      serviceAccountName: bookinfo-ratings
      containers:
        - name: ratings
          image: docker.io/istio/examples-bookinfo-ratings-v1:1.15.0
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9080
---
# Deployment doesn't have any container port specified and has two services using same port but different protocol.
# It should generate a warning.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: multiple-without-port
  namespace: bookinfo
  labels:
    app: productpage
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: productpage
      version: v1
  template:
    metadata:
      labels:
        app: productpage
        version: v1
    spec:
      serviceAccountName: bookinfo-productpage
      containers:
        - name: productpage
          image: docker.io/istio/examples-bookinfo-productpage-v1:1.15.0
          imagePullPolicy: IfNotPresent
---
apiVersion: v1
kind: Service
metadata:
  name: productpage-tcp-v1
  namespace: bookinfo
  labels:
    app: productpage
    service: productpage
spec:
  ports:
    - port: 9080
      name: tcp
      protocol: TCP
  selector:
    app: productpage
---
apiVersion: v1
kind: Service
metadata:
  name: productpage-http-v1
  namespace: bookinfo
  labels:
    app: productpage
    service: productpage
spec:
  ports:
    - port: 9080
      name: http
      protocol: HTTP
  selector:
    app: productpage
---
# Deployment has no services attached but also is not in the service mesh.
# It shouldn't generate a warning.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-out-mesh
  namespace: bookinfo
  labels:
    app: productpage
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: productpage
      version: v1
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "false"
      labels:
        app: productpage
        version: v1
    spec:
      serviceAccountName: bookinfo-productpage
      containers:
        - name: productpage
          image: docker.io/istio/examples-bookinfo-productpage-v1:1.15.0
          imagePullPolicy: IfNotPresent
---
apiVersion: v1
kind: Namespace
metadata:
  name: injection-disabled-ns
spec: {}
---
# Deployment has multiple service attached but using same port but different protocol.
# Sidecar is enabled although the namespaced doesn't have automatic injection.
# It should generate a warning.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ann-enabled-ns-disabled
  namespace: injection-disabled-ns
  labels:
    app: ratings
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ratings
      version: v1
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "true"
      labels:
        app: ratings
        version: v1
    spec:
      serviceAccountName: bookinfo-ratings
      containers:
        - name: ratings
          image: docker.io/istio/examples-bookinfo-ratings-v1:1.15.0
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9080
