Skip to content

Instantly share code, notes, and snippets.

@brakmic
Created April 27, 2023 10:12
Show Gist options
  • Save brakmic/18eab5d5ff34b7355fe69e9fcf078ce0 to your computer and use it in GitHub Desktop.
Save brakmic/18eab5d5ff34b7355fe69e9fcf078ce0 to your computer and use it in GitHub Desktop.
Create TLS key and cert without CA
  • Create keys
openssl req -newkey rsa:2048 -nodes -keyout tls.key -x509 -days 365 -out tls.crt -subj "/CN=localhost"
  • Create environment variables
TLS_KEY=$(cat tls.key | base64 | tr -d '\n')
TLS_CRT=$(cat tls.crt | base64 | tr -d '\n')
echo $TLS_KEY
echo $TLS_CRT
  • Copy/paste contents of TLS_KEY and TLS_CERT into your Secret YAML.
apiVersion: v1
kind: Secret
metadata:
  name: keycloak-tls-secret
type: kubernetes.io/tls
data:
  tls.key: COPIED_TLS_KEY_CONTENT_HERE
  tls.crt: COPIED_TLS_CRT_CONTENT_HERE
  • Create Secret with: kubectl apply -f FILE_NAME.yaml -n YOUR_NAMESPACE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment