Last active
April 27, 2021 12:44
-
-
Save carlessanagustin/a5dfca85a95233fe525bcebfcb2d3cb5 to your computer and use it in GitHub Desktop.
Create SSL/TLS Certificate for Ingress Controller and push to Kubernetes
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
#!/usr/bin/env bash | |
''' | |
USAGE: | |
./create_self_signed_certificate.sh <expiry_days> <namespace> <secret_name> | |
EXAMPLE: | |
./create_self_signed_certificate.sh 3650 ingress ingress-tls | |
SOURCE: | |
https://www.learnitguide.net/2020/06/create-ssl-tls-certificate-ingress.html | |
DELETE: | |
delete: kubectl -n $NAMESPACE delete secrets $SECRETNAME | |
''' | |
DAYS=$1 | |
NAMESPACE=$2 | |
SECRETNAME=$3 | |
Country_Name=ES | |
State_Name=Catalunya | |
Locality=Barcelona | |
Organization="Example Co" | |
Common_Name=www.example.com | |
openssl req -x509 -nodes \ | |
-days $DAYS \ | |
-newkey rsa:2048 \ | |
-out ingress-tls.crt \ | |
-keyout ingress-tls.key \ | |
-subj "/C=$Country_Name/ST=$State_Name/L=$Locality/O=$Organization/CN=$Common_Name" | |
kubectl --namespace $NAMESPACE create secret tls $SECRETNAME --key ingress-tls.key --cert ingress-tls.crt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment