This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
app-job-1-secrets.yaml
81 lines (81 loc) · 2.41 KB
/
app-job-1-secrets.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
apiVersion: v1
kind: ServiceAccount
metadata:
name: job-sa
namespace: default
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: job-pod-status
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: job-pod-status
subjects:
- kind: ServiceAccount
name: job-sa
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: job-pod-status
---
apiVersion: batch/v1
kind: Job
metadata:
name: app-job
namespace: default
spec:
backoffLimit: 1
template:
metadata:
annotations:
sidecar.vault.talend.org/inject: "true"
sidecar.vault.talend.org/mode: "job" # Enable 'job' mode (will also enable 'secrets' mode)
# Vault Sidecar Injector receive the pod spec: don't know whether it is a job or a deployment.
# Annotation below is deprecated, use 'sidecar.vault.talend.org/mode' instead.
#sidecar.vault.talend.org/workload: "job"
labels:
com.talend.application: test
com.talend.service: test-app-svc
spec:
restartPolicy: Never
# custom serviceAccountName with role allowing to perform GET on pods (needed to poll for job's pod status)
serviceAccountName: job-sa
containers:
- name: app-job-container
image: busybox:1.28
command:
- "sh"
- "-c"
- |
set -e
while true; do
echo "Wait for secrets file before running job..."
if [ -f "/opt/talend/secrets/secrets.properties" ]; then
echo "Secrets available"
break
fi
sleep 2
done
echo "Job started"
echo "I am a job... still working - 1"
cat /opt/talend/secrets/secrets.properties
sleep 5
echo "I am a job... still working - 2"
cat /opt/talend/secrets/secrets.properties
sleep 5
echo "I am a job... still working - 3"
cat /opt/talend/secrets/secrets.properties
sleep 5
echo "I am a job... still working - 4"
cat /opt/talend/secrets/secrets.properties
sleep 5
echo "I am a job... still working - 5"
cat /opt/talend/secrets/secrets.properties
echo "Job stopped"