I have questions about my basic understanding about the setup of my k8s cluster.
I have a K8s running on Hetzner-cloud and allocated a "physical" Loadbalancer
(which can be controlled via annotations
on a Service.)
I use a nginx (or traefik) as my ingress-controller
.
Please correct me if I am wrong:
Loadbalancer
with the annotations
in the same namespace
of my ingress-controller
right?ingress
with label kubernetes.io/ingress-controller=nginx
in my default
namespace with the settings to point to my services in the default
namespace (one for frontend, one for backend)Is this the correct way to set this up?
I create the service Loadbalancer with the annotations in the same namespace of my ingress-controller right?
No ideally your ingress controller will be running in different namespace in which your workload must not be running.
You should be keeping only the Nginx service with type : Loadbalancer
other services of your workload should be ClusterIP
.
So all your traffic comes inside the cluster from one point. Your flow will be something like
DNS > LB > Ingress > Service > Pods > Container
Then I create an ingress with label kubernetes.io/ingress-controller=nginx in my default namespace with the settings to point to my services in the default namespace (one for frontend, one for backend)
You mentioned label ideally, it should be an annotation kubernetes.io/ingress-controller=nginx
.
Yes, it's perfect. You can create different ingress with different annotation rules as per requirements for different services that you want to expose publicly.
Keep your workload in default namespace for the controller you can use different namespaces like ingress-controller
in future also if you have any requirement of setting up the Monitoring tools also you can create namespace and use it for monitoring only.
1.- No. Ingress Controller and your workload doesn't have to be in the same namespace. In fact, you will have the Ingress Controller running in a separate namespace than your workload.
2.-Yes. Generally speaking your Ingress
rules, meaning your Ingress
object, meaning your Ingress
yaml and your Service
must be in the same namespace. So Ingress
can't transpass a namespace.
Note: There is a way to have an Ingress
object to send trafffic to a Service
in a different namespace.