Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Istio sidecar injection to the job pod

How to disable Istio sidecar injection for the Kubernetes Job?

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: pod-restart
spec:
  concurrencyPolicy: Forbid
  schedule: '0 8 * * *'
  jobTemplate:
    metadata:
      annotations:
        sidecar.istio.io/inject: "false"
    spec:
      backoffLimit: 2
      activeDeadlineSeconds: 600
      template:
        spec:
          serviceAccountName: pod-restart
          restartPolicy: Never
          containers:
            - name: kubectl
              image: bitnami/kubectl
              command: ['kubectl', 'rollout', 'restart', 'deployment/myapp']

Sidecar still gets injected.

like image 628
Jonas Avatar asked Jan 20 '21 10:01

Jonas


People also ask

How do I disable Istio sidecar injection?

Disable automatic proxy sidecar injection Remove the istio-injection=enabled label from the default namespace by using the kubectl label as shown. The kubectl get namespace command confirms that the label is removed from the default namespace. Finally, delete the NGINX deployment.

How do I disable Istio in Kubernetes?

Uninstalling Istio from a cluster Ensure your default mTLS mode is set to Permissive mTLS. Shift traffic away from the Istio ingress gateway. Turn off sidecar auto-injection, if enabled. Restart application pods (for example using rolling restart) to remove the Envoy sidecars.

Which Istioctl command injects sidecars manually?

In order to take advantage of all of Istio's features, pods in the mesh must be running an Istio sidecar proxy. The following sections describe two ways of injecting the Istio sidecar into a pod: manually using the istioctl command or by enabling automatic Istio sidecar injection in the pod's namespace.


1 Answers

The annotation is in wrong place. You have to put it on the pod template.

apiVersion: batch/v1beta1
kind: CronJob
metadata:
spec:
  jobTemplate:
    spec:
      template:
        metadata:
          annotations:
            sidecar.istio.io/inject: "false"

There is working CronJob example with istio injection disabled.

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        metadata:
          annotations:
            sidecar.istio.io/inject: "false"
        spec:
          containers:
          - name: hello
            image: busybox
            args:
            - /bin/sh
            - -c
            - date; echo "Hello, World!"
          restartPolicy: OnFailure

Also there is related github issue about that.

like image 146
Jakub Avatar answered Sep 29 '22 23:09

Jakub