Skip to content

Instantly share code, notes, and snippets.

@27Bslash6
Created May 9, 2019 00:24
Show Gist options
  • Save 27Bslash6/7021fb618862b427d0a9c7c6f68dfa65 to your computer and use it in GitHub Desktop.
Save 27Bslash6/7021fb618862b427d0a9c7c6f68dfa65 to your computer and use it in GitHub Desktop.
Mounting a Kubernetes secret file into an existing directory
[thing]
stuff=flibbleAndPtang
foo=bar!@$@
apiVersion: v1
kind: Pod
metadata:
name: secret-test-pod
spec:
containers:
- name: test-container
image: nginx
volumeMounts:
- name: secret-volume
mountPath: /etc/config.toml
subPath: config.toml
volumes:
- name: secret-volume
secret:
secretName: secret-test
apiVersion: v1
kind: Secret
metadata:
name: secret-test
data:
config.toml: W3RoaW5nXQpzdHVmZj1mbGliYmxlQW5kUHRhbmcKZm9vPWJhciFAJEAK
@27Bslash6
Copy link
Author

Note the contents of the secret data.config.toml must be base64 encoded, eg via openssl enc -base64 < config.toml

kubectl apply -f secret-test.yaml
kubectl apply -f secret-test-pod.yaml
kubectl exec secret-test-pod cat /etc/config.toml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment