In this post, I will share how to install TLS/SSL on Kubernetes using a private certificate
Steps
Before you follow this post, make sure your cert and a private key are valid. If you don’t have any cert and private key yet, you should generate it. After that, create a Kubernetes secret by executing the command below
$ kubectl create secret tls (tls secret name) --key (private key filename) --cert (certificate filename)
Add the secret name to the ingress configuration. The name should be matched with a secret name in the previous step
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tls-example-ingress
spec:
tls:
- hosts:
- example.com
secretName: (tls secret name)
rules:
- host: example.com
http:
paths:
- path: /
backend:
service:
name: service1
port:
number: 80
Optional
if you already have ingress installed, there are two ways you can implement TLS/SSL :
- Edit the YAML configuration file of ingress, then you re-apply that using kubectl
$ kubectl apply -f (name-file).yaml
2. Edit the existing configuration on the cluster by executing the command below
$ kubectl edit secret (tls name secret)
To validate the TLS/SSL is installed, you should check on your browser.