istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/config/analysis/analyzers/testdata/deployment-multi-service.yaml (about)

     1  apiVersion: v1
     2  kind: Namespace
     3  metadata:
     4    name: bookinfo
     5    labels:
     6      istio-injection: "enabled"
     7  spec: {}
     8  ---
     9  # Deployment should generate a warning: two services using that deployment
    10  # using the same port but different protocol.
    11  apiVersion: apps/v1
    12  kind: Deployment
    13  metadata:
    14    name: multiple-svc-multiple-prot
    15    namespace: bookinfo
    16    labels:
    17      app: details
    18      version: v1
    19  spec:
    20    replicas: 1
    21    selector:
    22      matchLabels:
    23        app: details
    24        version: v1
    25    template:
    26      metadata:
    27        labels:
    28          app: details
    29          version: v1
    30      spec:
    31        serviceAccountName: bookinfo-details
    32        containers:
    33          - name: details
    34            image: docker.io/istio/examples-bookinfo-details-v1:1.15.0
    35            imagePullPolicy: IfNotPresent
    36            ports:
    37              - containerPort: 9080
    38  ---
    39  apiVersion: v1
    40  kind: Service
    41  metadata:
    42    name: details-tcp-v1
    43    namespace: bookinfo
    44    labels:
    45      app: details
    46      service: details
    47  spec:
    48    ports:
    49      - port: 9080
    50        name: tcp
    51        protocol: TCP
    52    selector:
    53      app: details
    54  ---
    55  apiVersion: v1
    56  kind: Service
    57  metadata:
    58    name: details-http-v1
    59    namespace: bookinfo
    60    labels:
    61      app: details
    62      service: details
    63  spec:
    64    ports:
    65      - port: 9080
    66        name: http
    67        protocol: HTTP
    68    selector:
    69      app: details
    70  
    71  ---
    72  # Deployment should generate a warning: two services using that deployment
    73  # using the same port but different protocol.
    74  apiVersion: apps/v1
    75  kind: Deployment
    76  metadata:
    77    name: conflicting-ports
    78    namespace: bookinfo
    79    labels:
    80      app: conflicting-ports
    81      version: v1
    82  spec:
    83    replicas: 1
    84    selector:
    85      matchLabels:
    86        app: conflicting-ports
    87        version: v1
    88    template:
    89      metadata:
    90        labels:
    91          app: conflicting-ports
    92          version: v1
    93      spec:
    94        serviceAccountName: bookinfo-details
    95        containers:
    96          - name: details
    97            image: docker.io/istio/examples-bookinfo-details-v1:1.15.0
    98            imagePullPolicy: IfNotPresent
    99            ports:
   100              - containerPort: 9080
   101  ---
   102  apiVersion: v1
   103  kind: Service
   104  metadata:
   105    name: conflicting-ports-1
   106    namespace: bookinfo
   107    labels:
   108      app: conflicting-ports
   109  spec:
   110    ports:
   111      - port: 9080
   112        name: tcp
   113        targetPort: 9080
   114        protocol: TCP
   115    selector:
   116      app: conflicting-ports
   117  ---
   118  apiVersion: v1
   119  kind: Service
   120  metadata:
   121    name: conflicting-ports-2
   122    namespace: bookinfo
   123    labels:
   124      app: conflicting-ports
   125  spec:
   126    ports:
   127      - port: 9090
   128        name: http
   129        targetPort: 9080
   130        protocol: HTTP
   131    selector:
   132      app: conflicting-ports
   133  ---
   134  # Deployment has two ports exposed, there are two services pointing to different ports.
   135  # It shouldn't generate a warning.
   136  apiVersion: apps/v1
   137  kind: Deployment
   138  metadata:
   139    name: reviews-v2
   140    namespace: bookinfo
   141    labels:
   142      app: reviews
   143      version: v2
   144  spec:
   145    replicas: 1
   146    selector:
   147      matchLabels:
   148        app: reviews
   149        version: v2
   150    template:
   151      metadata:
   152        labels:
   153          app: reviews
   154          version: v2
   155      spec:
   156        serviceAccountName: bookinfo-reviews
   157        containers:
   158          - name: reviews
   159            image: docker.io/istio/examples-bookinfo-reviews-v2:1.15.0
   160            imagePullPolicy: IfNotPresent
   161            ports:
   162              - containerPort: 9080
   163          - name: reviews-2
   164            image: docker.io/istio/examples-bookinfo-reviews-v2:1.15.0
   165            imagePullPolicy: IfNotPresent
   166            ports:
   167              - containerPort: 9090
   168  ---
   169  apiVersion: v1
   170  kind: Service
   171  metadata:
   172    name: reviews-http-9080
   173    namespace: bookinfo
   174    labels:
   175      app: reviews
   176      service: reviews
   177  spec:
   178    ports:
   179    - port: 9080
   180      name: http
   181      protocol: HTTP
   182    selector:
   183      app: reviews
   184  ---
   185  apiVersion: v1
   186  kind: Service
   187  metadata:
   188    name: reviews-http-9090
   189    namespace: bookinfo
   190    labels:
   191      app: reviews
   192      service: reviews
   193  spec:
   194    ports:
   195      - port: 9090
   196        name: http
   197        protocol: HTTP
   198    selector:
   199      app: reviews
   200  ---
   201  # Deployment has no service attached. It should generate a warning.
   202  apiVersion: apps/v1
   203  kind: Deployment
   204  metadata:
   205    name: no-services
   206    namespace: bookinfo
   207    labels:
   208      app: ratings
   209      version: v1
   210  spec:
   211    replicas: 1
   212    selector:
   213      matchLabels:
   214        app: ratings
   215        version: v1
   216    template:
   217      metadata:
   218        labels:
   219          app: ratings
   220          version: v1
   221      spec:
   222        serviceAccountName: bookinfo-ratings
   223        containers:
   224          - name: ratings
   225            image: docker.io/istio/examples-bookinfo-ratings-v1:1.15.0
   226            imagePullPolicy: IfNotPresent
   227            ports:
   228              - containerPort: 9080
   229  ---
   230  # Deployment doesn't have any container port specified and has two services using same port but different protocol.
   231  # It should generate a warning.
   232  apiVersion: apps/v1
   233  kind: Deployment
   234  metadata:
   235    name: multiple-without-port
   236    namespace: bookinfo
   237    labels:
   238      app: productpage
   239      version: v1
   240  spec:
   241    replicas: 1
   242    selector:
   243      matchLabels:
   244        app: productpage
   245        version: v1
   246    template:
   247      metadata:
   248        labels:
   249          app: productpage
   250          version: v1
   251      spec:
   252        serviceAccountName: bookinfo-productpage
   253        containers:
   254          - name: productpage
   255            image: docker.io/istio/examples-bookinfo-productpage-v1:1.15.0
   256            imagePullPolicy: IfNotPresent
   257  ---
   258  apiVersion: v1
   259  kind: Service
   260  metadata:
   261    name: productpage-tcp-v1
   262    namespace: bookinfo
   263    labels:
   264      app: productpage
   265      service: productpage
   266  spec:
   267    ports:
   268      - port: 9080
   269        name: tcp
   270        protocol: TCP
   271    selector:
   272      app: productpage
   273  ---
   274  apiVersion: v1
   275  kind: Service
   276  metadata:
   277    name: productpage-http-v1
   278    namespace: bookinfo
   279    labels:
   280      app: productpage
   281      service: productpage
   282  spec:
   283    ports:
   284      - port: 9080
   285        name: http
   286        protocol: HTTP
   287    selector:
   288      app: productpage
   289  ---
   290  # Deployment has no services attached but also is not in the service mesh.
   291  # It shouldn't generate a warning.
   292  apiVersion: apps/v1
   293  kind: Deployment
   294  metadata:
   295    name: deployment-out-mesh
   296    namespace: bookinfo
   297    labels:
   298      app: productpage
   299      version: v1
   300  spec:
   301    replicas: 1
   302    selector:
   303      matchLabels:
   304        app: productpage
   305        version: v1
   306    template:
   307      metadata:
   308        annotations:
   309          sidecar.istio.io/inject: "false"
   310        labels:
   311          app: productpage
   312          version: v1
   313      spec:
   314        serviceAccountName: bookinfo-productpage
   315        containers:
   316          - name: productpage
   317            image: docker.io/istio/examples-bookinfo-productpage-v1:1.15.0
   318            imagePullPolicy: IfNotPresent
   319  ---
   320  apiVersion: v1
   321  kind: Namespace
   322  metadata:
   323    name: injection-disabled-ns
   324  spec: {}
   325  ---
   326  # Deployment has multiple service attached but using same port but different protocol.
   327  # Sidecar is enabled although the namespaced doesn't have automatic injection.
   328  # It should generate a warning.
   329  apiVersion: apps/v1
   330  kind: Deployment
   331  metadata:
   332    name: ann-enabled-ns-disabled
   333    namespace: injection-disabled-ns
   334    labels:
   335      app: ratings
   336      version: v1
   337  spec:
   338    replicas: 1
   339    selector:
   340      matchLabels:
   341        app: ratings
   342        version: v1
   343    template:
   344      metadata:
   345        annotations:
   346          sidecar.istio.io/inject: "true"
   347        labels:
   348          app: ratings
   349          version: v1
   350      spec:
   351        serviceAccountName: bookinfo-ratings
   352        containers:
   353          - name: ratings
   354            image: docker.io/istio/examples-bookinfo-ratings-v1:1.15.0
   355            imagePullPolicy: IfNotPresent
   356            ports:
   357              - containerPort: 9080
   358  ---
   359  # Deployment has no services attached, has the istio-proxy image, but is waypoint deployment.
   360  # It shouldn't generate a warning since it's controlled by Istio.
   361  apiVersion: apps/v1
   362  kind: Deployment
   363  metadata:
   364    name: test-waypoint
   365    namespace: bookinfo
   366    labels:
   367      gateway.istio.io/managed: istio.io-mesh-controller
   368  spec:
   369    replicas: 1
   370    selector:
   371      matchLabels:
   372        gateway.networking.k8s.io/gateway-name: productpage
   373    template:
   374      metadata:
   375        labels:
   376          sidecar.istio.io/inject: "false"
   377          gateway.networking.k8s.io/gateway-name: productpage
   378          istio.io/gateway-name: productpage
   379      spec:
   380        serviceAccountName: productpage-istio-waypoint
   381        containers:
   382          - name: istio-proxy
   383            image: docker.io/istio/proxyv2:1.20.0-dev1
   384            imagePullPolicy: IfNotPresent