Skip to content

Instantly share code, notes, and snippets.

@aybabtme
Last active November 23, 2020 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aybabtme/cde951bd572ff9e785c03d5286334999 to your computer and use it in GitHub Desktop.
Save aybabtme/cde951bd572ff9e785c03d5286334999 to your computer and use it in GitHub Desktop.
Snippet to edit the value of a key in a k8s secret using a file as source for that value.
local namespace=""
local secret=""
local data_key=""
local filename=""
kubectl get secret -n ${namespace} ${secret} -o json \
| jq --arg datakey ${data_key} --argjson value <(base64 -w 0 < ${filename} | jq -R -s '.') '.data[$datakey] = $value' \
| kubectl apply -f -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment