Last active
November 23, 2020 10:49
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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