Skip to content

Instantly share code, notes, and snippets.

@stevenklar
Created July 22, 2019 09:51
Show Gist options
  • Select an option

  • Save stevenklar/fa9ae9bae3a1dd8d44427983bf96531a to your computer and use it in GitHub Desktop.

Select an option

Save stevenklar/fa9ae9bae3a1dd8d44427983bf96531a to your computer and use it in GitHub Desktop.
update-kubernetes-certificate
#!/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