Created
September 17, 2020 16:32
-
-
Save agu3rra/03349647142591988a46026dbc3dedaf to your computer and use it in GitHub Desktop.
Quick snippet to convert values into base64 encoding for usage with Kubernetes secrets.yml files
This file contains hidden or 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
import yaml | |
import base64 | |
# Assumes sample.yml will have a data: entry | |
if __name__ == '__main__': | |
with open('sample.yml', 'r') as fh: | |
stream = fh.read() | |
data = yaml.safe_load(stream) | |
for key, value in data['data'].items(): | |
encoded = base64.b64encode(str(value).encode('utf-8')).decode('utf-8') | |
print(f"{key}: {encoded}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample yml: