Step 8: Setting up the Ingress Controller (Traefik)
- Role of an Ingress Controller: to route external traffic to the services within the cluster.
- Traefik, a French project launched in 2015 for dynamic environments.
- Installation and routing tests.
- The cluster becomes fully operational.
Legacy version of the Kubernetes cookbook
This article is part of the first version of the cookbook (VMware and PhotonOS). A new version, on XCP-ng and Rocky Linux, is being published: the application exposure section has not yet been released; in the meantime, the Gateway API and Traefik article presents the approach used. The article remains online for reference.
Introduction
To finalize the Kubernetes cluster, we will deploy an Ingress Controller to it.
By default, K8S offers the Ingress object, which is responsible for managing external access to services hosted within the cluster. It defines routing rules to direct traffic to the appropriate services based on the URL path or other parameters.
The Ingress Controller will monitor these objects and use them to provide a reverse proxy service.
There are several Ingress Controllers, each offering its own set of features. We can mention NGINX, or even HAProxy, which we already use as an external load balancer.
For this article, we will be using Traefik.
Designed by Émile Vaugue, founder of the French company "Containous", now "Traefik Labs", the project was initiated in 2015 to meet the needs of traffic management in dynamic environments, particularly containers.
Available in a free version and, at the time of this article, in its third version, Traefik is experiencing growing adoption and integrates perfectly into a Kubernetes architecture.
Traefik is deployed as containers directly on the Kubernetes cluster.
It is important to remember that in our case, we will need to deploy two instances consisting of several iterations of Traefik. One dedicated to applications exposed in the LAN, and the other for applications exposed in the DMZ.
Indeed, the architecture I am proposing leverages the logical segmentation capabilities of a Kubernetes cluster to host applications within the same cluster that are intended to be accessible through two network zones.
Remember that we previously deployed two external HAProxy servers: the first, prdk8snlb501, configured to forward traffic to the control planes, and prdk8snlb511, configured to forward traffic to the nodes in the DMZ.
Since K8S allows multiple classes of Ingress Controller, we will simply install a class named traefik-lan and a class named traefik-dmz.
Each of these classes has its own service account.
This is how Traefik interacts with the K8S API, monitors provisioned Ingress objects, and applies routing rules accordingly.

Click the image to enlarge.
Finally, it is important to note that while Traefik can work with basic Ingress objects, it also provides its own objects that can be installed or not.
These additional objects extend the Kubernetes API and allow Traefik to offer additional features, such as URL rewriting or password-protected access.
While it is often recommended to stay as close as possible to the native objects of the API in order to ensure maximum reversibility, we will also need to work with Traefik objects for certain needs.
Installation
Before starting, we always check the health of the cluster using the following command:
kubectl get pod

Click the image to enlarge.
If all nodes are operational, we can proceed.
Deploying the LAN instance
As a prerequisite, we will label our control planes with the tag traefik-lan=yes. This is to enable the automatic deployment of Traefik pods dedicated to the LAN, and only on these specific control planes.
kubectl label nodes prdk8sctp501 traefik-lan=yes
kubectl label nodes prdk8sctp502 traefik-lan=yes
kubectl label nodes prdk8sctp503 traefik-lan=yes

Click the image to enlarge.
It is customary not to give Control Planes more roles than they already have in a cluster.
But for a small infrastructure like mine, not optimizing the resources allocated to these nodes would be a shame.
As shown during the architecture definition, the control planes will also serve as entry points for the Traefik instance in the LAN (and not in the DMZ, of course).
We continue with the declaration of a dedicated namespace.
kubectl create ns inf-traefik-lan

Click the image to enlarge.
Then we register the service account reserved for this instance of Traefik.
To do this, navigate to the directory ~/kub.coolcorp.priv/traefik of the first control plane created during the Ansible playbook launch, where all Traefik configuration files have been provisioned.

Click the image to enlarge.
The service account is described in the file svc-traefik-lan.yaml:
apiVersion: v1
kind: ServiceAccount
metadata:
name: "svc-prd-traefik"
namespace: "inf-traefik-lan"
It's very basic; we only need to specify a few things besides the name of the service account svc-prd-traefik.
Apply the service account using the following command:
kubectl apply -f svc-traefik-lan.yaml

Click the image to enlarge.
Next, register the Traefik Helm repository, as this is how we will install the product.
As a reminder, Helm is a package manager for Kubernetes. We automatically deployed the Helm binary with Ansible.
The commands to run are as follows:
helm repo add traefik https://helm.traefik.io/traefik
helm repo update

Click the image to enlarge.
Now, proceed with installing the Traefik instance for the LAN using the following command:
helm install --namespace=inf-traefik-lan traefik-lan traefik/traefik -f traefik-config-lan.yaml --set nodeSelector.traefik-lan=yes --set tolerations[0].key=node-role.kubernetes.io/control-plane --set tolerations[0].operator=Exists --set tolerations[0].effect=NoSchedule

Click the image to enlarge.
This command allows you to specify the namespace and the configuration file traefik-config-lan.yaml to use in order to override the default parameters.
The remaining arguments enable deployment on the control planes. Using a label alone is not sufficient, because by default, the control planes are marked with certain characteristics that must be tolerated by the pods in order to run on the associated servers.
The contents of the file traefik-config-lan.yaml are as follows:
image:
name: traefik
tag: "3.0.1"
pullPolicy: IfNotPresent
deployment:
enabled: true
kind: DaemonSet
labels:
network: lan
podLabels:
network: lan
providers:
kubernetesIngress:
labelSelector: network=lan
kubernetesCRD:
enabled: true
allowCrossNamespace: false
allowExternalNameServices: false
allowEmptyServices: false
namespaces:
- inf-traefik-lan
serviceAccount:
name: "svc-prd-traefik"
logs:
level: ERROR
hostNetwork: true
ports:
web:
port: 80
ports.web.redirectTo.port: websecure
websecure:
port: 443
securityContext:
capabilities:
drop: [ALL]
add: [NET_BIND_SERVICE]
readOnlyRootFilesystem: true
runAsGroup: 0
runAsNonRoot: false
runAsUser: 0
updateStrategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
type: RollingUpdate
additionalArguments:
- "--providers.kubernetesingress.ingressclass=traefik-lan"
- "--serversTransport.insecureSkipVerify=true"
Remember that its content was generated from a template via Ansible.
I will not detail each line, but some points are important to understand.
tag: "3.0.1": This is the version of Traefik to deploykind: DaemonSet: A DaemonSet is a specific type of Deployment. It corresponds to running an instance of a pod on each node that meets the requested characteristics. In our case, a control plane. This allows us to automatically add a Traefik pod to a new control plane that is added to the cluster later.labelSelector: network=lan: Here, we tell Traefik to consider any object of type Ingress that is labeled network=lan. If not, it will ignore it.kubernetesCRD: enabled: true: CRD for Custom Resource Definition. We enable the use of additional Traefik objects by requesting that they be registered in the K8S API.name: "svc-prd-traefik": The name of the service account to use, which we deployed previously.hostNetwork: true: This indicates that we are mapping Traefik to the server's network. In fact, except for a few exceptions, Traefik pods are the only pods that can be directly exposed through the server's ports.-
ports: web: port: 80 ports.web.redirectTo.port: websecure websecure: port: 443These lines are important. They define all the entry points on which Traefik should listen. Here, the web point on port 80 and the websecure point on port 443. We can also add an automatic redirection from port 80 to port 443 using the option ports.web.redirectTo.port: websecure
Traefik is not limited to HTTP and HTTPS ports; it can also work on more exotic ports and on layer three of the OSI model. Therefore, we can add as many ports as we want and name them as we see fit (web and websecure were chosen completely arbitrarily, but you will often find them in Traefik examples).
- "--providers.kubernetesingress.ingressclass=traefik-lan": This allows you to name the Ingress Controller class associated with this Traefik instance.
If everything is working correctly, you can check the status of the deployment using the following command:
kubectl get pod -n inf-traefik-lan -o wide

Click the image to enlarge.
Each control plane has a Traefik pod (deployed via DaemonSet).
Before moving on to the DMZ, we will add the ability for Traefik to expose a monitoring dashboard.
This is a very useful option. The dashboard does not allow any actions, but it displays the status of Traefik and, most importantly, describes the routing provided by it.
For security reasons, we will want to protect access to the dashboard with a password. This will allow us to use the first custom object of Traefik: the Middleware.
This will be based on a Secret object containing a username/password in Apache format to request authentication before displaying the page.
You can use the htpasswd tool to generate the username and password.
For example, you can do this through your WSL instance and your Windows terminal.
Otherwise, there are online sites for this (but be careful not to use a website to generate critical passwords... without being paranoid, you are never certain of how they are used behind the scenes).
The command for the tool is:
htpasswd -Bbn vote_login votre_password

Click the image to enlarge.
Simply place the output of this command in a file named sec-traefik-dashboard-lan-password at the level of the first control plane.

Click the image to enlarge.
Then, run the following command to generate a Secret from the file.
kubectl create secret generic sec-traefik-dashboard-lan-password --from-file=traefik-dashboard-lan-password --namespace inf-traefik-lan

Click the image to enlarge.
It is recommended to delete the file afterwards.
Since the dashboard is accessible via HTTPS, it is also necessary to associate a certificate with it.
Several approaches are possible, and everything will depend on what you have available for generating certificates.
In my case, I have my own internal PKI (under Windows) integrated into my domain, which allows me to generate certificates that are recognized on all of my internal devices.
You can use what I propose as a basis and adapt it to your needs; the idea here is not to create a tutorial on certificates.
But in general, I use the standard process:
- 1: Generation of a private key
- 2: Generation of a certificate request (a CSR for Certificate Signing Request) including the hostname and DNS name that will be associated with my certificate.
- 3: I submit my certificate to a PKI (in this case, a Windows PKI).
- 4: I obtain a certificate.
From my WSL instance on my workstation, I generate my private key (4096 bits) and my certificate request (a CSR), using OpenSSL.
openssl req -new -nodes -sha256 -keyout traefik-k8s-lan.coolcorp.priv.key -out traefik-k8s-lan.coolcorp.priv.csr -newkey rsa:4096 -subj "/C=FR/ST=Ile-de-France/L=Paris/O=OFI/OU=Infrastructure/CN=traefik-k8s-lan.coolcorp.priv" -reqexts SAN -config <(printf "[req]\ndistinguished_name = req_distinguished_name\n[req_distinguished_name]\n[SAN]\nsubjectAltName=DNS:traefik-k8s-lan.coolcorp.priv")

Click the image to enlarge.

Click the image to enlarge.
I copy my CSR to my PKI and ask it to obtain a certificate based on the TPL-SRV-WEB-DEFAULT template (which groups the characteristics of a certificate used by a web service).

Click the image to enlarge.
certreq -attrib "CertificateTemplate:TPL-SRV-WEB-DEFAULT" -submit traefik-k8s-lan.coolcorp.priv.csr

Click the image to enlarge.
In the end, I obtain a certificate and a private key.

Click the image to enlarge.
These two components will be copied to the first control plane (their content can be easily copied; they are text files).

Click the image to enlarge.

Click the image to enlarge.
These two files will be used to create another Secret.
kubectl create secret generic sec-certif-traefik-k8s-lan --from-file=tls.crt=traefik-k8s-lan.coolcorp.priv.cer --from-file=tls.key=traefik-k8s-lan.coolcorp.priv.key --namespace inf-traefik-lan

Click the image to enlarge.
Now that we have a secret sec-traefik-dashboard-lan-password containing the authentication information for accessing the dashboard, and a secret sec-certif-traefik-k8s-lan for the certificate, we can run the following command:
kubectl apply -f traefik-lan-dashboard.yaml

Click the image to enlarge.
We will use the file traefik-lan-dashboard.yaml, which contains the following:
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: traefik-lan-dashboard
namespace: "inf-traefik-lan"
spec:
entryPoints:
- websecure
routes:
- kind: Rule
match: Host(`traefik-k8s-lan.coolcorp.priv`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))
services:
- name: api@internal
kind: TraefikService
middlewares:
- name: traefik-dashboard-lan-auth # Referencing the BasicAuth middleware
namespace: inf-traefik-lan
tls:
secretName: sec-certif-traefik-k8s-lan
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: traefik-dashboard-lan-auth
namespace: inf-traefik-lan
spec:
basicAuth:
secret: sec-traefik-dashboard-lan-password
It contains two objects. Both are specific to Traefik and added to the K8S API in the traefik.io/v1alpha1 branch
The first one is named IngressRoute. It's a kind of enhanced Ingress. We find the expected entry point (websecure) and the associated URL (traefik-k8s-lan.coolcorp.priv), with the requirement to add the prefix /api or /dashboard.
If a request coming from outside matches these rules, it will be redirected to an internal Traefik service api@internal, which is the dashboard.
It also includes the reference to the middleware for secure access, as well as the secret sec-certif-traefik-k8s-lan, in the TLS section for certificate association.
The second object is the famous Middleware itself, referenced in the previous object. It simply takes the secret containing the login/password as input.
In summary, when you access https://traefik-k8s-lan.coolcorp.priv/dashboard/, you will reach the websecure entry point, and the URL will match the routing rule.
Traefik will apply the certificate contained in the secret sec-certif-traefik-k8s-lan, but before exposing the dashboard, it will first call the Middleware, which will then request authentication.
If the authentication matches the connection information present in the secret sec-traefik-dashboard-lan-password, then the request is redirected to the service api@internal.
Let's see if this actually happens. Of course, beforehand, you need to ensure that you have a DNS alias that redirects the name traefik-k8s-lan.coolcorp.priv to the HAProxy load balancer in the LAN (prdk8snlb501), which will then relay it to one of the control planes, and is subsequently intercepted by the Traefik instance running on it.

Click the image to enlarge.
As a reminder, HAproxy was configured during a previous step
We do see an authentication prompt, and when you enter the correct login and password, you are successfully redirected to the Traefik dashboard.

Click the image to enlarge.

Click the image to enlarge.
If you look further down in the display, you will find that the CRDs are enabled in the list of providers, in addition to the native Ingress objects (KubernetesIngress). Therefore, Traefik can rely on both types of objects, native and custom, to manage routing. We will have the opportunity to explore this dashboard further later in the article.

Click the image to enlarge.
Deploying the DMZ instance
Regarding the installation of the instance in the DMZ, we will repeat exactly the same operations. I will not necessarily provide the same level of detail again.
We start in the same way, which is to label the nodes that will run the Traefik pods.
I invite you to review the infrastructure definition, but for the DMZ, it is the two workers present there that will have this task.
We therefore label them as follows:
kubectl label nodes prdk8snod511 traefik-dmz=yes
kubectl label nodes prdk8snod512 traefik-dmz=yes

Click the image to enlarge.
Then we create the dedicated namespace
kubectl create ns inf-traefik-dmz

Click the image to enlarge.
As before, in the first control plane within the directory ~/kub.coolcorp.priv/traefik, you can find the file svc-traefik-dmz.yaml, which was generated during the Ansible playbook.
Its content is as follows:
apiVersion: v1
kind: ServiceAccount
metadata:
name: "svc-prd-traefik-dmz"
namespace: "inf-traefik-dmz"
As with the LAN, Traefik will use a service account, but different from the one created previously.
You can apply the YAML file using the following command:
kubectl apply -f svc-traefik-dmz.yaml

Click the image to enlarge.
Next, we proceed with installing Traefik, again using Helm. Since the repositories are already added, you need to use the following command:
helm install --namespace=inf-traefik-dmz traefik-dmz traefik/traefik -f traefik-config-dmz.yaml --set nodeSelector.traefik-dmz=yes --set tolerations[0].key=node-role.kubernetes.io/worker-dmz --set tolerations[0].operator=Exists --set tolerations[0].effect=NoSchedule

Click the image to enlarge.
We will use labels to ensure that this time, the pods do not run on the control planes, but instead on the worker nodes in the DMZ.
The configuration file used to override the parameters and which is created via a template during the execution of Ansible, is practically identical to the one used for the LAN.
image:
name: traefik
tag: "3.0.1"
pullPolicy: IfNotPresent
deployment:
enabled: true
kind: DaemonSet
labels:
network: dmz
podLabels:
network: dmz
providers:
kubernetesIngress:
labelSelector: network=dmz
kubernetesCRD:
enabled: true
allowCrossNamespace: false
allowExternalNameServices: false
allowEmptyServices: false
namespaces:
- inf-traefik-dmz
serviceAccount:
name: "svc-prd-traefik-dmz"
logs:
level: ERROR
hostNetwork: true
ports:
web:
port: 80
ports.web.redirectTo.port: websecure
websecure:
port: 443
securityContext:
capabilities:
drop: [ALL]
add: [NET_BIND_SERVICE]
readOnlyRootFilesystem: true
runAsGroup: 0
runAsNonRoot: false
runAsUser: 0
updateStrategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
type: RollingUpdate
additionalArguments:
- "--providers.kubernetesingress.ingressclass=traefik-dmz"
- "--serversTransport.insecureSkipVerify=true"
Except for the namespace in which it runs, the name of the service account used, and the use of the keyword "dmz" to define both the class of the Ingress Controller and the label of the Ingress to be controlled, it is exactly the same logic as for the LAN.
You can verify the installation using the following command:
kubectl get pod -n inf-traefik-dmz -o wide

Click the image to enlarge.
This time, the Traefik pods are correctly deployed on the worker nodes in the DMZ.
Following the same logic as before, we will deploy the dashboard.
We start by creating a login/password combination using the htpasswd command, which you can find on your WSL installation.
htpasswd -Bbn votre_login votre_password

Click the image to enlarge.
We then use the output of this command to copy it to the first control plane in a file named traefik-dashboard-dmz-password

Click the image to enlarge.
Then, we generate the secret from this file using the following command:
kubectl create secret generic sec-traefik-dashboard-dmz-password --from-file=traefik-dashboard-dmz-password --namespace inf-traefik-dmz

Click the image to enlarge.
A new certificate is required, so we repeat the process of creating a key, generating a CSR, and obtaining a certificate from a PKI.
openssl req -new -nodes -sha256 -keyout traefik-k8s-dmz.coolcorp.priv.key -out traefik-k8s-dmz.coolcorp.priv.csr -newkey rsa:4096 -subj "/C=FR/ST=Ile-de-France/L=Paris/O=OFI/OU=Infrastructure/CN=traefik-k8s-dmz.coolcorp.priv" -reqexts SAN -config <(printf "[req]\ndistinguished_name = req_distinguished_name\n[req_distinguished_name]\n[SAN]\nsubjectAltName=DNS:traefik-k8s-dmz.coolcorp.priv")

Click the image to enlarge.
certreq -attrib "CertificateTemplate:TPL-SRV-WEB-DEFAULT" -submit traefik-k8s-dmz.coolcorp.priv.csr

Click the image to enlarge.

Click the image to enlarge.
The private key and the certificate must be copied to the first control plane, and then, using these two files, we generate the secret sec-certif-traefik-k8s-dmz.

Click the image to enlarge.

Click the image to enlarge.
kubectl create secret generic sec-certif-traefik-k8s-dmz --from-file=tls.crt=traefik-k8s-dmz.coolcorp.priv.cer --from-file=tls.key=traefik-k8s-dmz.coolcorp.priv.key --namespace inf-traefik-dmz

Click the image to enlarge.
Finally, you just need to apply the YAML file traefik-dmz-dashboard.yaml, which was generated by Ansible in ~/kub.coolcorp.priv/traefik on the first control plane, to deploy the dashboard.
kubectl apply -f traefik-dmz-dashboard.yaml

Click the image to enlarge.
The content is as follows:
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: traefik-dmz-dashboard
namespace: "inf-traefik-dmz"
spec:
entryPoints:
- websecure
routes:
- kind: Rule
match: Host(`traefik-k8s-dmz.coolcorp.priv`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))
services:
- name: api@internal
kind: TraefikService
middlewares:
- name: traefik-dashboard-dmz-auth # Referencing the BasicAuth middleware
namespace: inf-traefik-dmz
tls:
secretName: sec-certif-traefik-k8s-dmz
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: traefik-dashboard-dmz-auth
namespace: inf-traefik-dmz
spec:
basicAuth:
secret: sec-traefik-dashboard-dmz-password
Except for the references to the DMZ instead of the LAN, the file is exactly the same as for the LAN.
You can test access to the dashboard via the URL https://traefik-k8s-dmz.coolcorp.priv/dashboard/.
Of course, a correctly configured DNS alias is also required here, but this time it will point to the IP address of the HAProxy load balancer in the DMZ prdk8snlb511 (configured in a previous step to forward requests to one of the nodes in the DMZ).

Click the image to enlarge.
As with the dashboard in the LAN, we first see an authentication prompt, and then we access the dashboard, but this time it is specific to the Traefik instance in the DMZ.

Click the image to enlarge.

Click the image to enlarge.
Testing
As we did when deploying the persistent storage layer via CSI vSphere, we will test the proper functioning of our operations with a test application.
As I usually do, I create a folder named after the namespace that I will use to store my files.

Click the image to enlarge.
I create this same namespace dev-demotraefik-lan declaratively using the following command:
kubectl create ns dev-demotraefik-lan

Click the image to enlarge.
The first YAML file is 01-deploy-demotraefik-front.yaml.
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-demotraefik-front
namespace: dev-demotraefik-lan
labels:
environment: dev
network: lan
application: demotraefik
spec:
strategy:
type: Recreate
selector:
matchLabels:
environment: dev
network: lan
application: demotraefik
template:
metadata:
labels:
environment: dev
network: lan
application: demotraefik
spec:
nodeSelector:
network: lan
containers:
- name: demo-nginx-traefik-lan
image: nginx:1.27
resources:
requests:
memory: "8Mi"
cpu: "250m"
limits:
memory: "256Mi"
cpu: 1
livenessProbe:
initialDelaySeconds: 5
periodSeconds: 5
exec:
command:
- ls /usr/share/nginx/html
ports:
- containerPort: 80
It creates a Deployment object named deploy-demotraefik-front, which in turn deploys a pod demo-nginx-traefik-lan based on the nginx 1.27 image.
The pod will therefore contain a single container that listens on port 80.
Once the file is applied using the command:
kubectl apply -f 01-deploy-demotraefik-front.yaml

Click the image to enlarge.
We can verify that the deployment is correct with the following command:
kubectl get pod -n dev-demotraefik-lan -o wide

Click the image to enlarge.
We can now move on to the second file 02-svc-demotraefik-front.yaml.
---
kind: Service
apiVersion: v1
metadata:
name: svc-demotraefik-front
namespace: dev-demotraefik-lan
labels:
environment: dev
network: lan
application: demotraefik
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
environment: dev
network: lan
application: demotraefik
This describes a Service object. I won't go into detail at this level, but this object will allow us to expose the previously created pod, and therefore the NGINX container within it, inside the cluster.
To do this, the service forwards requests that it receives on port 80 to port 80 of any pod that matches the label contained in the selector section.
If you look back at the previous file, you will see that these are the labels assigned to the pod attached to the Deployment.
We execute the creation of the service with the following command:
kubectl apply -f 02-svc-demotraefik-front.yaml

Click the image to enlarge.
We check that the service has been created correctly with the following command:
kubectl get svc -n dev-demotraefik-lan -o wide

Click the image to enlarge.
Before moving on to the last file, we need to generate a certificate again. Our goal is to test the exposure of the NGINX container outside the cluster via a test URL. Therefore, a certificate is required if we want to expose the application over HTTPS.
I won't re-explain the logic, but as with the dashboards in the DMZ and LAN, we generate a key, using a CSR, submit the CSR to a PKI, and retrieve a certificate.
openssl req -new -nodes -sha256 -keyout demotraefik-lan.coolcorp.priv.key -out demotraefik-lan.coolcorp.priv.csr -newkey rsa:4096 -subj "/C=FR/ST=Ile-de-France/L=Paris/O=OFI/OU=Infrastructure/CN=demotraefik-lan.coolcorp.priv" -reqexts SAN -config <(printf "[req]\ndistinguished_name = req_distinguished_name\n[req_distinguished_name]\n[SAN]\nsubjectAltName=DNS:demotraefik-lan.coolcorp.priv")

Click the image to enlarge.
certreq -attrib "CertificateTemplate:TPL-SRV-WEB-DEFAULT" -submit demotraefik-lan.coolcorp.priv.csr

Click the image to enlarge.
The key and certificate are copied to the first control plane.

Click the image to enlarge.

Click the image to enlarge.
We generate the associated secret using the following command:
kubectl create secret generic sec-certificate-demotraefik-lan --from-file=tls.crt=demotraefik-lan.coolcorp.priv.cer --from-file=tls.key=demotraefik-lan.coolcorp.priv.key --namespace dev-demotraefik-lan

Click the image to enlarge.
We can now move on to the last file, 03-ing-demotraefik-front.yaml.
Its content is as follows:
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ing-nginxnfs-default
namespace: dev-demotraefik-lan
labels:
environment: dev
network: lan
application: demotraefik
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
ingressClassName: traefik-lan
traefik.ingress.kubernetes.io/router.tls: "true"
spec:
ingressClassName: traefik-lan
tls:
- hosts:
- demotraefik-lan.coolcorp.priv
secretName: sec-certificate-demotraefik-lan
rules:
- host: demotraefik-lan.coolcorp.priv
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: svc-demotraefik-front
port:
number: 80
Unlike the Traefik dashboards, this time we use a native Ingress object for the K8S API.
Indeed, there is no need for advanced functions as before, and we are not redirecting to the internal Traefik API.
Therefore, the Ingress object is sufficient.
It is thanks to what is included in the annotations that Traefik will be able to know how to behave.
For the rest of the file, we remain on the definition of an Ingress as described in the Kubernetes API.
We specify the class of Ingress Controller that we want to use, here traefik-lan.
Then we provide the associated URL, the service to use, and the port to which requests should be forwarded.
In this example, we have an Ingress ing-nginxnfs-default that uses the Ingress Controller traefik-lan, which will allow all received traffic with the URL demotraefik-lan.coolcorp.priv to be redirected to port 80 of the service svc-demotraefik-front, applying the certificate contained in the secret sec-certificate-demotraefik-lan.
We apply the configuration with the following command:
kubectl apply -f 03-ing-demotraefik-front.yaml

Click the image to enlarge.
As with any K8S object, we want to check the status of the Ingress deployment:
kubectl get ing -n dev-demotraefik-lan

Click the image to enlarge.
Let's now verify that the site is accessible. For this, a DNS alias must exist so that the test URL redirects to the IP address of the LAN load balancer, so that it relays to one of the control planes for the Traefik instance located there, which can then process the request.

Click the image to enlarge.
Let's try accessing it.
We do have a certificate attached and recognized.

Click the image to enlarge.
If we now connect to the Traefik dashboard of the LAN instance, we will be able to find the details of our configuration in the HTTP menu.

Click the image to enlarge.
The entire routing path is visible. The presence of the shield indicates that we are indeed using TLS with a certificate.

Click the image to enlarge.

Click the image to enlarge.
Note that this example takes advantage of Traefik on the LAN, but we could very well apply the same thing to the DMZ; it would simply be necessary to change the references from traefik-lan to traefik-dmz.
In this case, we could even do without the certificate, because in the DMZ, the application is accessible from the WEB.
This means we can use external certificate request services based on the ACME protocol, supported by Traefik, such as Let's Encrypt, for example.
In this case, everything is done automatically, but we will discuss this point in another article when we detail the deployment of an application. (And eventually, even on a LAN, we might reach this level of automation...but we'll see that later).
Conclusion
We have now reached the end of this article. I hope it has helped you understand how to deploy an Ingress Controller, primarily Traefik.
The idea was also to show you how to use both a standard Ingress object and custom objects added to the K8S API.
Once again, sticking as closely as possible to the basic objects is a good practice, but sometimes we are forced to extend the API to benefit from advanced features.
Note that Ingress objects are tending to be replaced by Gateway objects, which can take over functions provided by custom Traefik objects. As of the date of this article, I don't have enough experience to talk about it in more detail, but I will definitely write about the subject once I know a little more on my end.
However, we can now say that the cluster is fully operational and capable of supporting many uses.
All that remains is to deploy a real application...but that's for the final article in this Cookbook. But before that, I suggest we talk about Certificates.