Skip to content

Instantly share code, notes, and snippets.

@Odilhao
Created March 9, 2020 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Odilhao/0df6a910dd3dbb1c4f67cab97945bfa9 to your computer and use it in GitHub Desktop.
Save Odilhao/0df6a910dd3dbb1c4f67cab97945bfa9 to your computer and use it in GitHub Desktop.
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: script
spec:
schedule: "*/2 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: tempo
image: fedora
args:
- /bin/bash
- -c
- /script/script.sh
volumeMounts:
- name: script
mountPath: /script/script.sh
subPath: script.sh
restartPolicy: OnFailure
volumes:
- name: script
configMap:
name: script-cm
defaultMode: 0777
@GoingOffRoading
Copy link

This is excellent!

Can I get a look at how you setup your configMap "script"?

@Odilhao
Copy link
Author

Odilhao commented Mar 9, 2020

@GoingOffRoading

cat <<'EOF' >> script.sh
#!/bin/bash
weather=$(curl -s wttr.in/Brasilia?format="%l:+%c+%t")
echo $weather
exit
EOF

$ kubectl create cm script-cm --from-file=script.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment