<p>I have a cron job with below spec. I am sending a POST request to end point after specific intervals. I need to change the urls based on the environment like <code>staging</code> or <code>production</code></p>
<p>Is there a way i can use the ENV variable in place of domain name and not create two separate files to use two different urls.</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: testing
spec:
  schedule: &quot;*/20 * * * *&quot;
  suspend: false
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: testing
              image: image
              ports:
                - containerPort: 3000
              args:
              - /bin/sh
              - -c
              - curl -X POST #{USE_ENV_VARIABLE_HERE}/api/v1/automated_tests/workflows #how to make this generic
          restartPolicy: Never
</code></pre>

opensource-developer
<p>You can use env variable via secret or config map. Here I have given an example with secret.</p>
<pre><code># secrets.yaml
apiVersion: v1
kind: Secret
metadata:
  name: demo-secret
type: Opaque
stringData:
   BASE_URL: &quot;example.com&quot;
</code></pre>
<p>Then you can use that secret as env in container.</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: testing
spec:
  schedule: &quot;*/20 * * * *&quot;
  suspend: false
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: testing
              image: image
              ports:
                - containerPort: 3000
              envFrom:
                - secretRef:
                     name: demo-secret
              args:
              - /bin/sh
              - -c
              - curl -X POST ${BASE_URL}/api/v1/automated_tests/workflows
          restartPolicy: Never
</code></pre>
