Let's secure OpenShift 4.x ingress with letsencrypt certificates that are renewed on the fly through a cronjob running within OpenShift itself. We are using AWS Rout53 for our DNS. As such our example here will use AWS as an example. However you can easily alter the behavior to fit your particular setup. We will get to that in a bit.
Let’s Encrypt is a free, automated, and open certificate authority (CA), run for the public’s benefit. It is a service provided by the Internet Security Research Group (ISRG) with its goal defined as follows
We give people the digital certificates they need in order to enable HTTPS (SSL/TLS) for websites, for free, in the most user-friendly way we can. We do this because we want to create a more secure and privacy-respecting Web.
That's is perfect for us. The key principles behind Let’s Encrypt are:
Here is what you need to get started. First of you will need bash, docker on your workstation.
You got bash and docker already installed? Wonderful! Next we need to source the bashrc of this repository for easy of use. You can either do it manually via
source ./bashrc
Or you can put it in your ~/.bashrc file like this
[ -f /PATH/TO/GEPARDEC/OPENSHIFT/LETSENCRYPT/bashrc ] && source /PATH/TO/GEPARDEC/OPENSHIFT/LETSENCRYPT/bashrc
and source your ~/.bashrc again in order to enable the changes in your current session.
Some commands require openshift and/or aws credentials. In order to not repeat the login proecedures over and over in the following sections we have added them here in the preflight section.
From your workstation log in to the OpenShift cluster via
oc login
If you do not have the oc binary on your machine you can execute
openshift-letsencrypt oc login
instead.
In our example we will use AWS Route 53 api to create the certificate. For this purpose we need to login to aws via cli. From your workstation simply execute
aws configure
If you do not have the aws binary on your machine you can execute
openshift-letsencrypt aws configure
instead.
openshift-letsencrypt
openshift-letsencrypt-build
openshift-letsencrypt-issue
openshift-letsencrypt-install
openshift-letsencrypt-renew
openshift-letsencrypt-cron
openshift-letsencrypt-setup
Hint: do not forget to source the bashrc
To create a new certificte for your OpenShift cluster you need to be logged in with a user that has access to the openshift-ingress-operator namespace. If you are using aws Route 53 like us you need to login to aws as well. Please check the preflights section on how to login to OpenShift and AWS via the cli.
Once you are logged in via the cli to OpenShift and AWS you can execute
openshift-letsencrypt-issue --dns dns_aws
The command will create a certificate folder next to the openshift-letsencrypt/bashrc file populated with the certificate files.
To install a certificte created in the previous step cluster you need to be logged in with a user that has access to the openshift-ingress and openshift-ingress-operator namespace. Please check the preflights section on how to login to OpenShift and AWS via the cli.
openshift-letsencrypt-install
To renew a new certificte for your OpenShift cluster you need to be logged in with a user that has access to the openshift-ingress-operator namespace. If you are using aws Route 53 like us you need to login to aws as well. Please check the preflights section on how to login to OpenShift and AWS via the cli.
openshift-letsencrypt-renew --dns dns_aws
In order to automate the process of certificate renewal a cronjob can be deployed within openshift to check certificate health, renew certificates and install new certificates if necessary.
Disclaimer: cronjob currently only supports aws as dns backend.
openshift-letsencrypt-cron
The image is available on dockerhub via gepardec/openshift-letsencrypt. If you want to build it locally or modify the image you can execute the build easily via
openshift-letsencrypt-build
/
├── CODE_OF_CONDUCT.md
├── Dockerfile
├── LICENSE
├── README.md
├── bashrc
├── resources
│ └── letsencrypt
│ ├── cronjob.yml
│ ├── imagestream-letsencrypt.yml
│ ├── project.yml
│ ├── role-openshift-ingress-operator.yml
│ ├── role-openshift-ingress.yml
│ ├── role-project.yml
│ └── serviceaccount.yml
└── scripts
├── bash-script-collection
│ └── functions
│ ├── check_for_pull_request.sh
│ ├── cmp_regex.sh
│ ├── docker_login.sh
│ ├── echo_stderr.sh
│ └── execute.sh
├── letsencrypt-cron
├── letsencrypt-entrypoint
├── letsencrypt-install
├── letsencrypt-issue
└── letsencrypt-renew
/
├── usr/local/bin
│ ├── acme.sh/acme.sh
│ ├── aws
│ ├── functions
│ │ ├── check_for_pull_request.sh
│ │ ├── cmp_regex.sh
│ │ ├── docker_login.sh
│ │ ├── echo_stderr.sh
│ │ └── execute.sh
│ ├── googlechat-send-notification.sh
│ ├── jp.py
│ ├── letsencrypt-cron
│ ├── letsencrypt-entrypoint
│ ├── letsencrypt-install
│ ├── letsencrypt-issue
│ ├── letsencrypt-renew
│ └── oc
└── mnt
└── openshift <- Repo folder structure
Content type
Image
Digest
Size
195.9 MB
Last updated
over 5 years ago
docker pull gepardec/openshift-letsencrypt