Created
May 12, 2021 23:33
-
-
Save dawncold/2c90bc83ac5b674edb35ac7de11addbc to your computer and use it in GitHub Desktop.
k8s secret and cronjob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: app-secret | |
type: Opaque | |
stringData: | |
dbconnstr: this-is-db-connection-string-in-secret | |
username: admin | |
password: KuBeRnEtEs | |
--- | |
apiVersion: batch/v1beta1 | |
kind: CronJob | |
metadata: | |
name: hello | |
spec: | |
schedule: "*/1 * * * *" | |
jobTemplate: | |
spec: | |
template: | |
spec: | |
containers: | |
- name: hello | |
image: busybox | |
env: | |
- name: DBCONNECTIONSTRING | |
valueFrom: | |
secretKeyRef: | |
name: app-secret | |
key: dbconnstr | |
- name: USERNAME | |
valueFrom: | |
secretKeyRef: | |
name: app-secret | |
key: username | |
- name: PASSWORD | |
valueFrom: | |
secretKeyRef: | |
name: app-secret | |
key: password | |
command: | |
- /bin/sh | |
- -c | |
- date; echo db:$DBCONNECTIONSTRING user:$USERNAME pass:$PASSWORD | |
restartPolicy: OnFailure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment