01. September 2023
Solution TP 14
TP14 : TLS ingress
Create the kubernetes secret using the command line :
kubectl create secret tls training-tls –key=“server.key” –cert=“server.crt”
then update the two ingresses. You must add the host in the rules and add a block TLS using the secret we create before.
1apiVersion: networking.k8s.io/v1
2kind: Ingress
3metadata:
4 name: app-ingress
5spec:
6 tls:
7 - hosts:
8 - k8s-training-pip-trainee-X.westeurope.cloudapp.azure.com
9 secretName: training-tls
10 rules:
11 - host: 'k8s-training-pip-trainee-X.westeurope.cloudapp.azure.com'
12 http:
13 paths:
14 - path: /
15 pathType: Prefix
16 backend:
17 service:
18 name: front-training-app
19 port:
20 number: 80
&
1apiVersion: networking.k8s.io/v1
2kind: Ingress
3metadata:
4 name: app-ingress-back
5 annotations:
6 nginx.ingress.kubernetes.io/rewrite-target: /$1
7spec:
8 tls:
9 - hosts:
10 - k8s-training-pip-trainee-X.westeurope.cloudapp.azure.com
11 secretName: training-tls
12 rules:
13 - host: 'k8s-training-pip-trainee-X.westeurope.cloudapp.azure.com'
14 http:
15 paths:
16 - path: /api/(.*)
17 pathType: ImplementationSpecific
18 backend:
19 service:
20 name: back-training-app
21 port:
22 number: 80