How can I automate the removal of kubernetes secrets from a yaml file?
yq
can do this (and jq
underneath)
pip install yq
yq --yaml-output 'select(.kind != "Secret")' input.yaml
You might need to remove the null document at the end of your example, it caused a little bit of weirdness in the output
Note that there is also a different yq
utility that doesn't seem to do what jq
does so I'm not sure how to make that one work.
What about a shell script that splits the file at every occurrence of ---
by using the command awk? (See sections 5 and 6 of this link for an example of that.) In this way, the script can evaluate each part separately and send those who do not correspond to Secret
to a new output file.