시크릿 (Secrets)
Argo는 쿠버네티스 파드 스펙과 동일한 시크릿 문법과 메커니즘을 지원하며, 이를 통해 시크릿을 환경 변수 또는 볼륨 마운트로 접근할 수 있습니다. 자세한 내용은 쿠버네티스 문서를 참고하세요.
본문
# 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: secret-example-
spec:
entrypoint: print-secrets
# To access secrets as files, add a volume entry in spec.volumes[] and
# then in the container template spec, add a mount using volumeMounts.
volumes:
- name: my-secret-vol
secret:
secretName: my-secret # name of an existing k8s secret
templates:
- name: print-secrets
container:
image: alpine:3.23
command: [sh, -c]
args: ['
echo "secret from env: $MYSECRETPASSWORD";
echo "secret from file: `cat /secret/mountpath/mypassword`"
']
# To access secrets as environment variables, use the k8s valueFrom and
# secretKeyRef constructs.
env:
- name: MYSECRETPASSWORD # name of env var
valueFrom:
secretKeyRef:
name: my-secret # name of an existing k8s secret
key: mypassword # 'key' subcomponent of the secret
volumeMounts:
- name: my-secret-vol # mount file containing secret at /secret/mountpath
mountPath: "/secret/mountpath"
더 알아보기 (Learn more)
- 환경 변수 방식은
valueFrom.secretKeyRef, 파일 방식은spec.volumes[]의 secret 볼륨 +volumeMounts를 사용합니다. - 시크릿 생성 예:
kubectl create secret generic my-secret --from-literal=mypassword=... - 시크릿 문법은 일반 쿠버네티스 파드 스펙과 동일하므로 K8s 문서가 그대로 적용됩니다.