0

I can enter the following from a command prompt to create a Kubernetes job:

curl -ik -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -X POST -H 'Content-Type: application/yaml' --data '
apiVersion: batch/v1
kind: Job
metadata:
  name: c360srv01-job
spec:
  template:
    metadata:
      name: c360srv01
    spec:
      containers:
      - name: c360srv01
        image: joegoldberg/controlm:appimage
        env:
        - name: LOOPCTR
          value: "10"
        - name: STIME
          value: "60"
      restartPolicy: Never
' https://10.96.0.1:443/apis/batch/v1/namespaces/default/jobs

However, I have not been able to convert this to a bash script. I've tried building the command in sections as individual variables that I then concatenate, I've tried build it as one long string, I've also tried putting the YAML into a file and using --data @filename but haven't been able to make any of these work. Any and all suggestions will be greatly appreciated.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Joe Goldberg
  • 38
  • 1
  • 4
  • These links may help you : https://stackoverflow.com/questions/17029902/using-curl-post-with-variables-defined-in-bash-script-functions https://unix.stackexchange.com/questions/386127/curl-with-variables-on-bash-script – nullPointer Feb 04 '19 at 08:27
  • Putting the command in a file and adding `#!/bin/bash` as the first line and marking it executable will trivially produce a functioning script. It's not clear what exactly you are having trouble with, though it sounds like probably you want some of the static text to be replaced with variables. Please [edit] your question to show us what exactly you tried and what you expected it to do. – tripleee Feb 04 '19 at 08:59
  • Please post the code of the bash script that did not work. The command you have posted seems to be 100% valid as a script. – brunorey Feb 04 '19 at 12:30

0 Answers0