|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * service_mesh/v2x/ossm-traffic-manage.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="ossm-deploying-automatic-gateway-injection_{context}"] |
| 7 | += Deploying automatic gateway injection |
| 8 | + |
| 9 | +When deploying a gateway, you must opt-in to injection by adding an injection label or annotation to the gateway `deployment` object. The following example `ConfigMap` object deploys a gateway with automatic injection. |
| 10 | + |
| 11 | +.Prerequisites |
| 12 | + |
| 13 | +* The namespace must be a member of the mesh by defining it in the `ServiceMeshMemberRoll` or by creating a `ServiceMeshMember` resource. |
| 14 | +
|
| 15 | +.Example deployment with annotations |
| 16 | +[source,yaml] |
| 17 | +---- |
| 18 | + apiVersion: v1 |
| 19 | + kind: Service |
| 20 | + metadata: |
| 21 | + name: istio-ingressgateway |
| 22 | + namespace: istio-ingress |
| 23 | + spec: |
| 24 | + type: LoadBalancer |
| 25 | + selector: |
| 26 | + istio: ingressgateway |
| 27 | + ports: |
| 28 | + - port: 80 |
| 29 | + name: http |
| 30 | + - port: 443 |
| 31 | + name: https |
| 32 | + --- |
| 33 | + apiVersion: apps/v1 |
| 34 | + kind: Deployment |
| 35 | + metadata: |
| 36 | + name: istio-ingressgateway |
| 37 | + namespace: istio-ingress |
| 38 | + spec: |
| 39 | + selector: |
| 40 | + matchLabels: |
| 41 | + istio: ingressgateway |
| 42 | + template: |
| 43 | + metadata: |
| 44 | + annotations: |
| 45 | + inject.istio.io/templates: gateway <1> |
| 46 | + labels: |
| 47 | + istio: ingressgateway <2> |
| 48 | + sidecar.istio.io/inject: "true" <3> |
| 49 | + spec: |
| 50 | + containers: |
| 51 | + - name: istio-proxy |
| 52 | + image: auto <4> |
| 53 | + --- |
| 54 | + apiVersion: rbac.authorization.k8s.io/v1 <5> |
| 55 | + kind: Role |
| 56 | + metadata: |
| 57 | + name: istio-ingressgateway-sds |
| 58 | + namespace: istio-ingress |
| 59 | + rules: |
| 60 | + - apiGroups: [""] |
| 61 | + resources: ["secrets"] |
| 62 | + verbs: ["get", "watch", "list"] |
| 63 | + --- |
| 64 | + apiVersion: rbac.authorization.k8s.io/v1 |
| 65 | + kind: RoleBinding |
| 66 | + metadata: |
| 67 | + name: istio-ingressgateway-sds |
| 68 | + namespace: istio-ingress |
| 69 | +roleRef: |
| 70 | + apiGroup: rbac.authorization.k8s.io |
| 71 | + kind: Role |
| 72 | + name: istio-ingressgateway-sds |
| 73 | +subjects: |
| 74 | +- kind: ServiceAccount |
| 75 | + name: default |
| 76 | +---- |
| 77 | +<1> Select the gateway injection template rather than the default sidecar template. |
| 78 | +<2> Set a unique label for the gateway. This setting is required to ensure Gateways can select this workload. |
| 79 | +<3> Enable gateway injection. If connecting to a revisioned control plane, replace with `istio.io/rev: revision-name`. |
| 80 | +<4> The image automatically updates each time the pod starts. |
| 81 | +<5> Set up roles to allow reading credentials for TLS. |
0 commit comments