Search code examples
kubernetesnginxtraefik

Kubernetes with 2 ingress controller like Traefik and nginx


Greeting , everyone:

I confused about ingress controller. I want to clarify concenpt about ingress controller. So I do a lab in my minikube with docker .

I want to build ingress controller by helm . No with minikube command minikube addons ingress because I wanted to deploy to AWS EKS or Google GKE.

This is the step I did .

  1. minikube start

  2. install nginx ingress controller

# Follow with this document
# https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-helm/#installing-via-helm-repository

helm install my-release nginx-stable/nginx-ingress

NAME: my-release
LAST DEPLOYED: Mon May  1 10:34:42 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The NGINX Ingress Controller has been installed.

  1. install Traefik ingress controller
# Follow with this document ( I am for sure is it controller install or only traefik)
# https://doc.traefik.io/traefik/getting-started/install-traefik/#use-the-helm-chart
helm repo add traefik https://traefik.github.io/charts
helm install traefik traefik/traefik
Error: INSTALLATION FAILED: cannot re-use a name that is still in use. ( I've been install it)

I show my k get pod command

❯ k get pod
NAME                                                  READY   STATUS    RESTARTS   AGE
my-release-nginx-ingress-controller-878db74f7-bjg52   1/1     Running   0          7m43s
nginx-deployment-7fb96c846b-kfwdt                     1/1     Running   0          34m
nginx-deployment1-5754bdfcfc-pb6bg                    1/1     Running   0          34m
nginx-deployment2-cc857c8d4-bkdpv                     1/1     Running   0          34m
traefik-6c66967f99-wmngz                              1/1     Running   0          34m

❯ k get svc
NAME                                  TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
kubernetes                            ClusterIP      10.96.0.1       <none>        443/TCP                      40m
my-release-nginx-ingress-controller   LoadBalancer   10.105.231.87   <pending>     80:32042/TCP,443:31549/TCP   12m
service                               ClusterIP      10.103.135.57   <none>        80/TCP                       39m
service1                              ClusterIP      10.96.38.123    <none>        80/TCP                       39m
service2                              ClusterIP      10.99.144.61    <none>        80/TCP                       39m
traefik                               LoadBalancer   10.99.244.191   <pending>     80:31990/TCP,443:32004/TCP   39m

  1. Now I'am confuse How to use ingress configure with two different ingress controller.

I wanted to set an ingress with Traefik to my nginx-deployment with domain a.example.com I wanted to set an ingress with Nginx to my nginx-deployment1 with domain b.example.com or you can show my with /Path example.

When I saw the document. I still confuse. refer: https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules

What situation shoud I use IngressClass and annotations ? I saw a lot of blog use annotations in ingress configure. ( in document. This is not command to use)

But when I first time to try nginx controller . I don't remember I set a Ingressclass . and ingress also work.


Solution

  • Here listing few term you have to take care

    • Ingress - Resource on K8s contain routing rule, hostname, SSL details, path etc
    • Ingress Controller - Manages the ingress Rule above one and based on matching request do request routing (Nginx, Trafik controller)
    • IngressClass - This is the thing which connect ingress & ingress controller
    • Annotation - Extending the options with existing ingress rule, attach cert and extend ingress

    Each controller might be having different ways the attach SSL cert, defining the Routes, host and annotations.