forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
secrets.yaml
46 lines (46 loc) · 1.91 KB
/
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
# This example demonstrates how to reference kubernetes secrets in a workflow.
# Secrets should be stored externally from the workflow as kubernetes secrets,
# and accessed using normal kubernetes facilities, such as volume mounting the
# secret, or as an environment variable. This example shows both approaches.
# For more details, see kubernetes documentation on secrets:
# https://kubernetes.io/docs/concepts/configuration/secret/
#
# To run this example, first create the secret by running:
# kubectl create secret generic my-secret --from-literal=mypassword=S00perS3cretPa55word
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: secrets-
spec:
entrypoint: print-secret
# To use a secret as files, it is exactly the same as mounting secrets as in
# a pod spec. First add an volume entry in the spec.volumes[]. Name the volume
# anything. spec.volumes[].secret.secretName should match the name of the k8s
# secret, which was created using kubectl. In any container template spec, add
# a mount to volumeMounts referencing the volume name and a mount path.
volumes:
- name: my-secret-vol
secret:
secretName: my-secret
templates:
- name: print-secret
container:
image: alpine:3.7
command: [sh, -c]
args: ['
echo "secret from env: $MYSECRETPASSWORD";
echo "secret from file: `cat /secret/mountpath/mypassword`"
']
# To use a secret as an environment variable, use the valueFrom with a
# secretKeyRef. valueFrom.secretKeyRef.name should match the name of the
# k8s secret, which was created using kubectl. valueFrom.secretKeyRef.key
# is the key you want to use as the value of the environment variable.
env:
- name: MYSECRETPASSWORD
valueFrom:
secretKeyRef:
name: my-secret
key: mypassword
volumeMounts:
- name: my-secret-vol
mountPath: "/secret/mountpath"