All Policies
Add Istio Sidecar Injection
In order for Istio to inject sidecars to workloads deployed into Namespaces, the label `istio-injection` must be set to `enabled`. As an alternative to rejecting Namespace definitions which don't already contain this label, it can be added automatically. This policy adds the label `istio-inject` set to `enabled` for all new Namespaces.
Policy Definition
/istio/add-sidecar-injection-namespace/add-sidecar-injection-namespace.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: add-sidecar-injection-namespace
5 annotations:
6 policies.kyverno.io/title: Add Istio Sidecar Injection
7 policies.kyverno.io/category: Istio
8 policies.kyverno.io/severity: medium
9 kyverno.io/kyverno-version: 1.8.0
10 policies.kyverno.io/minversion: 1.6.0
11 kyverno.io/kubernetes-version: "1.24"
12 policies.kyverno.io/subject: Namespace
13 policies.kyverno.io/description: >-
14 In order for Istio to inject sidecars to workloads deployed into Namespaces, the label
15 `istio-injection` must be set to `enabled`. As an alternative to rejecting Namespace definitions
16 which don't already contain this label, it can be added automatically. This policy adds the label
17 `istio-inject` set to `enabled` for all new Namespaces.
18spec:
19 rules:
20 - name: add-istio-injection-enabled
21 match:
22 any:
23 - resources:
24 kinds:
25 - Namespace
26 mutate:
27 patchStrategicMerge:
28 metadata:
29 labels:
30 istio-injection: enabled