47
loading...
This website collects cookies to deliver better user experience
whoami
container, along with an ingress over http
. We can use the IP address of any node, such as http://192.168.1.244/foo
, and get a response like the following:https
, we get a warning about about a self-signed certificate. Clicking View Certificate, shows a self-signed Traefik certificate, and if we accept and continue, we get a 404 Not Found.whoami
ingress doesn’t have TLS enabled and the request is falling back to Traefik’s default https
handling. We can fix this by deploying cert-manager and using it to request a certificate for the whoami
ingress.arm
images are used.curl -sL \
https://github.com/jetstack/cert-manager/releases/download/v1.3.1/cert-manager.yaml |\
sed -r 's/(image:.*):(v.*)$/\1-arm:\2/g' > cert-manager-arm.yaml
kubectl create namespace cert-manager
kubectl create -f cert-manager-arm.yaml
kubectl get pods --namespace cert-manager
NAME READY STATUS
cert-manager-webhook-7c58d9689f-74j7c 1/1 Running
cert-manager-7c5b8cb7cf-nzz64 1/1 Running
cert-manager-cainjector-67df6b6b68-lzkng 1/1 Running
Issuer
which is a namespaced resource, or a ClusterIssuer
which is a global resource. We’ll create a self-signed ClusterIssuer
using the following definition:apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: self-signed-issuer
spec:
selfSigned: {}
whoami
ingress to obtain a certificate from the ClusterIssuer
and enable TLS. This is done by adding the following annotations:cert-manager.io/cluster-issuer: self-signed-issuer
traefik.ingress.kubernetes.io/router.tls: "true"
tls
section to specify the hostname and the name of the secret that will store the certificate created by cert-manager:tls:
- hosts:
- whoami
secretName: whoami-tls
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: whoami-tls
namespace: whoami
annotations:
kubernetes.io/ingress.class: "traefik"
cert-manager.io/cluster-issuer: self-signed-issuer
traefik.ingress.kubernetes.io/router.tls: "true"
spec:
tls:
- hosts:
- whoami
secretName: whoami-tls
rules:
- host: whoami
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: whoami
port:
number: 80
- path: /foo
pathType: Prefix
backend:
service:
name: whoami
port:
number: 80
whoami-tls
secret:kubectl --namespace whoami describe secret whoami-tls
Name: whoami-tls
Namespace: whoami
Labels: <none>
Annotations: cert-manager.io/alt-names: whoami
cert-manager.io/certificate-name: whoami-tls
cert-manager.io/common-name:
cert-manager.io/ip-sans:
cert-manager.io/issuer-group: cert-manager.io
cert-manager.io/issuer-kind: ClusterIssuer
cert-manager.io/issuer-name: self-signed-issuer
cert-manager.io/uri-sans:
Type: kubernetes.io/tls
Data
====
ca.crt: 1017 bytes
tls.crt: 1017 bytes
tls.key: 1679 bytes
kubernetes.io/tls
and the data holds the CA certificate, the whoami
public certificate (tls.crt), and the whoami
private key (tls.key).whoami
service via https
, the hostname of the URL must match the hostname of the certificate, which in this case is whoami
. To make this work, we can modify /etc/hosts
so that whoami
maps to the IP address of one of our nodes.192.168.1.244 rpi-1 whoami
192.168.1.245 rpi-2
192.168.1.246 rpi-3
https://whoami/bar
in our browser, we still get a warning about a self-signed certificate, but this time the certificate is the whoami
certificate and not the default Traefik certificate.47