Kubernetes Opaque Secret

Joshua Callis
May 10, 2022

--

This will be quick and to the point.

previously when we wanted to create an Opaque secret manually we would have to encode and decode the data like so:

apiVersion: v1kind: Secretmetadata:  name: log-level  namespace: namespacetype: Opaquedata:  LOG_LEVEL: ZXJyb3IK# must encode values# encode#  echo "error" | base64# ZXJyb3IK# # decode# echo "ZXJyb3IK==" | base64 -d# error

Which wasn’t the end of the world, however added extra steps. In February 2022, the api was updated and the values no longer needed to be encoded/decoded. This is because of the key stringData

and can be used like so:

apiVersion: v1kind: Secretmetadata:  name: log-level  namespace: exampletype: OpaquestringData:  LOG_LEVEL: "error"

Then to apply

kubectl apply -f log-level-secret.yaml

--

--

Joshua Callis
Joshua Callis

Written by Joshua Callis

Converted DevOps Engineer at oso.sh, Previously a Senior Software Engineer.

No responses yet