Help Center/
Application Service Mesh/
FAQs/
Adding a Service/
How Do I Inject a Sidecar for the Pod Created Using a Job or Cron Job?
Updated on 2025-03-18 GMT+08:00
How Do I Inject a Sidecar for the Pod Created Using a Job or Cron Job?
Prerequisites
- Ensure that ASM 1.15.5-r3 or later is used to create service meshes.
- By default, the sidecar is not injected for the pod created using a job or cron job. If sidecar injection is required, choose Labels and Annotations in Advanced Settings and set sidecar.istio.io/inject to true for Pod Label.
The following is an example cron job:
kind: CronJob apiVersion: batch/v1 metadata: name: mycronjob namespace: default spec: schedule: '*/1 * * * *' jobTemplate: spec: template: metadata: creationTimestamp: null labels: app: mycronjob sidecar.istio.io/inject: 'true' ...
- Before using a job or cron job, you need to run a specific command in the target container to disable the sidecar.
Disabling a Sidecar After a Job or Cron Job Is Complete
Call curl -sf -XPOST http://127.0.0.1:15000/quitquitquit to disable istio-proxy after a job or cron job is complete.
The following is an example cron job:
kind: CronJob apiVersion: batch/v1 metadata: name: mycronjob namespace: default spec: schedule: '*/1 * * * *' concurrencyPolicy: Forbid suspend: false jobTemplate: metadata: creationTimestamp: null spec: template: metadata: creationTimestamp: null labels: app: cronjob1 sidecar.istio.io/inject: 'true' version: v1 spec: containers: - name: mycronjob-1 image: 'busybox:latest' command: - /bin/bash - '-c' args: - | trap "curl --max-time 2 -s -f -XPOST http://127.0.0.1:15000/quitquitquit" EXIT while ! curl -s -f http://127.0.0.1:15020/healthz/ready; do sleep 1;done sleep 2 date; echo Hello from the Kubernetes cluster<Your Job command> ...
Parent topic: Adding a Service
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot