Istio sidecar manual injection failed

Hey guys,

I’m trying to manually inject sidecar to my service pod but “Annotations: sidecar.istio.io/inject: true” isn’t working.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hello
  template:
    metadata:
      labels:
        app: hello
      annotations:
        sidecar.istio.io/inject: "true"
    spec:
      containers:
      - name: hello
        image: openshift/hello-openshift
        ports:
        - containerPort: 8080

Any ideas why this happened or am I going the wrong direction?

Thanks,
Ray

if you take a look at the mutatingwebhookconfiguration you will see that the namespace also has to be annotated for automatic injection. the Label you are using is typically used to prevent auto injection in an enabled namespace

kubectl get mutatingwebhookconfiguration istio-sidecar-injector
...
  namespaceSelector:
    matchLabels:
      istio-injection: enabled

you must enable namespace auto inject ~