Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@brianredbeard
Last active July 23, 2019 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianredbeard/6b40ed2fa86ff36f51f0e071f0adf790 to your computer and use it in GitHub Desktop.
Save brianredbeard/6b40ed2fa86ff36f51f0e071f0adf790 to your computer and use it in GitHub Desktop.
Script to get Let's Encrypt public facing certs for an OpenShift v4 cluster
#!/bin/sh
DOMAIN="${1}"
EMAIL="${2}"
if [ "${#}" -ne 2 ]; then
echo "USAGE: os4-acme-certs.sh clustername.basedomain.tld email@example.com"
echo "QUITTING"
exit 1
fi
OUT="$(env | grep ^AWS | wc -l)"
if [ ${?} -ne 0 ]; then
echo "Please set the correct AWS environment variables to proceed"
echo "QUITTING"
exit 1
fi
OUT="$(which lego)"
if [ ${?} -ne 0 ]; then
echo "You must download lego from https://github.com/go-acme/lego/releases to proceed"
echo "QUITTING"
exit 1
fi
if [ -f .lego/certificates/apps.${DOMAIN}.crt ] || [ -f .lego/certificates/apps.${DOMAIN}.certs ]; then
echo "Found previously issued lego certs, attempting to apply them"
else
echo "No issued lego certs found. Requesting them now"
lego --dns route53 -a -m bharrington@redhat.com -d apps.${DOMAIN} -d *.apps.${DOMAIN} run
fi
oc project openshift-ingress
oc delete secret router-certs-default
oc create secret tls router-certs-default --cert=.lego/certificates/apps.${DOMAIN}.crt --key=.lego/certificates/apps.${DOMAIN}.key
oc delete pods -l ingresscontroller.operator.openshift.io/deployment-ingresscontroller=default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment