Created
July 22, 2019 09:51
-
-
Save stevenklar/fa9ae9bae3a1dd8d44427983bf96531a to your computer and use it in GitHub Desktop.
update-kubernetes-certificate
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
| #!/bin/bash | |
| # Setup variables | |
| secret="default --namespace default" | |
| fullchain="/etc/letsencrypt/live/example.com/fullchain.pem" | |
| privkey="/etc/letsencrypt/live/example.com//privkey.pem" | |
| privkey_rsa="/etc/letsencrypt/live/example.com/privkey-rsa.pem" | |
| # Generate rsa privkey | |
| openssl rsa -in $privkey > $privkey_rsa | |
| # Base64 encode and trail trim certs | |
| fullchain_encoded=$(printf "%s" "$(< $fullchain)" | base64 -w0) | |
| privkey_encoded=$(printf "%s" "$(< $privkey_rsa)" | base64 -w0) | |
| # Apply patch | |
| kubectl patch secret $secret -p "{\"data\": {\"tls.crt\": \"$fullchain_encoded\", \"tls.key\": \"$privkey_encoded\"}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment