Skip to content

Instantly share code, notes, and snippets.

@fauberso
Created May 11, 2020 16:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save fauberso/f6304adf1213176180aedf70170713d1 to your computer and use it in GitHub Desktop.
Save fauberso/f6304adf1213176180aedf70170713d1 to your computer and use it in GitHub Desktop.
Generates self-signed tls secrets for kubernetes. Run this with e.g. 'kubernetes-gencerts microk8s.local', then install the secrets with 'kubectl apply -f microk8s.local.yaml'
#!/bin/bash
HOSTNAME=${1:-localhost}
openssl req -newkey rsa:2048 -nodes -keyout $HOSTNAME.key -x509 -days 3650 -out $HOSTNAME.crt
echo "apiVersion: v1
kind: Secret
metadata:
name: $HOSTNAME.tls
namespace: default
type: kubernetes.io/tls
data:
tls.crt: `cat $HOSTNAME.crt | base64 -w0`
tls.key: `cat $HOSTNAME.key | base64 -w0`
" > $HOSTNAME.yaml
@fauberso
Copy link
Author

Thanks to Daniel Watrous' instructions ""Generate TLS Secret for kubernetes"" for this. FInd his article here: https://software.danielwatrous.com/generate-tls-secret-for-kubernetes/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment