How to quickly read K8S Secret Value

To get the value of a K8S SecretK8S Secret
Secrets are [[K8S Object]]s which are used to store sensitive information you can't otherwise put into a Pod spec or a [[K8S ConfigMap]].

Secrets are very similar to ConfigMaps, the biggest differ...
, all you need to know is the secret name and the name of the key that you want to read.

What I would normally do before is:

  • kubectl get secret mysecret -o yaml
  • copy the (often very long) base64 string under the key i wish to read
  • echo "million_character_base64_string_here" | base64 -d

While this works, there is an easier way:

kubectl get secret $SECRET_NAME -o 'go-template={{ index .data "$KEY_NAME" }}' | base64 -d

Neat - now it's a one-liner and i don't have to copy anything!


Status: #🌲