Kind: Secret - timowang1991/kubernetes-docs GitHub Wiki
- Create secret file
apiVersion: v1
kind: Secret
metadata:
name: mysecret
type: Opaque
data:
USER_NAME: YWRtaW4=
PASSWORD: MWYyZDFlMmU2N2Rm
- Execute
kubectl apply -f mysecret.yaml
- Use the secret
apiVersion: v1
kind: Pod
metadata:
name: secret-test-pod
spec:
containers:
- name: test-container
image: k8s.gcr.io/busybox
command: [ "/bin/sh", "-c", "env" ]
envFrom:
- secretRef:
name: mysecret
restartPolicy: Never
- also see medium blogs as reference
- Deploying Kubernetes Secrets with CircleCI: uses python script to generate secret yaml files
- [Kubernetes / K8s]機密數據藏起來- Secret| Kubernetes Secrets let you store and manage sensitive information
kubectl create secret generic pgpassword --from-literal PGPASSWORD=password123
kubectl get secrets