-
apply
kubectl apply -f secret-env-var.yaml
-
check with logs
kubectl logs test-pod
-> you can see
username=admin
andpassword=xxx
in the environment variables. -
Delete
kubectl delete -f secret-env-var.yaml
data.csv
name,age,email,password
naka,1,[email protected],j4gn43g4gr
tanaka,2,[email protected],8j437fkw3v
-
Encode
data.csv
echo -n 'name,age,email,password naka,1,[email protected],j4gn43g4gr tanaka,2,[email protected],8j437fkw3v' | base64 bmFtZSxhZ2UsZW1haWwscGFzc3dvcmQKbmFrYSwxLG5ha2FAZXhhbXBsZS5jb20sajRnbjQzZzRncgp0YW5ha2EsMix0YW5ha2FAZXhhbXBsZS5jb20sOGo0Mzdma3czdg==
or
kubectl create secret generic mysecret --from-file=data.csv=data.csv -o yaml --dry-run=client apiVersion: v1 data: data.csv: bmFtZSxhZ2UsZW1haWwscGFzc3dvcmQKbmFrYSwxLG5ha2FAZXhhbXBsZS5jb20sajRnbjQzZzRncgp0YW5ha2EsMix0YW5ha2FAZXhhbXBsZS5jb20sOGo0Mzdma3czdg== kind: Secret metadata: creationTimestamp: null name: mysecret
-
Apply
kubectl apply -f secret-file.yaml
-
Check
kubectl exec -it test-pod sh
inside the container
ls ls datadir cat datadir/data.csv
-
Delete
kubectl delete -f secret-file.yaml
Create secret with --from-literal
kubectl create secret generic mysecret --from-literal=username=admin --from-literal=password=1f2d1e2e67df -o yaml --dry-run=client