I’m new to Kubernetes and wanted to use the NGINX Ingress Controller for the project I’m currently working on. I read some of the docs and watched some tutorials but I haven’t really understood the:
- installation process (should I use Helm, the git repo???)
- how to properly configure the Ingress. For example, the Kubernetes docs say to use a nginx.conf file (https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/#creating-the-frontend) which is never mentioned in the actual NGINX docs. They say to use ConfigMaps or annotations
Does anybody know of a blog post or tutorial that makes these things clear. Out of everything I’ve learned so far (both frontend and backend) developing and deploying to a cloud environment has got me lost. I’ve been stuck on a problem for a week and want to figure out it Ingress can help me.
Thanks!
2
Answers
The most straightforward process of installing nginx ingress controller (or any other for that matter) would be using
helm
. This would need basic understanding ofhelm
and how to work withhelm charts
.Here’s the repo: https://github.com/kubernetes/ingress-nginx/tree/master/charts/ingress-nginx
Follow the instructions in there – quite straightforward if you use the default values. For the configuration, you can customize the chart too before installing. Look at the Readme to see how to get all the configurable options.
Hope this helps as a starting point.
Answering:
There is no one correct way to install
nginx-ingress
. Each way has its own advantages/disadvantages, each Kubernetes cluster could require different treatment (for example: cloud managed Kubernetes and minikube) and you will need to determine which option is best suited for you.You can choose from running:
$ kubectl apply -f ...
,$ helm install ...
,terraform apply ...
(helm provider),Citing the official documentation:
Basically
Ingress
is a resource that tells yourIngress controller
how it should handle specificHTTP
/HTTPS
traffic.Speaking specifically about the
nginx-ingress
, it’s entrypoint that yourHTTP
/HTTPS
traffic should be sent to is aService
of typeLoadBalancer
named:ingress-nginx-controller
(in aingress-nginx
namespace). In Docker with Kubernetes implementation it will bind to the localhost of your machine.The modified example from the documentation will tell your
Ingress
controller to pass the traffic with anyHost
and withpath: /
(everypath
) to a service namednginx
on port80
.The above configuration after applying will be reflected by
ingress-nginx
in the/etc/nginx/nginx.conf
file.On how your specific
Ingress
manifest should look like you’ll need to consult the documentation of the software that you are trying to send your traffic to and ingress-nginx docs.Addressing the part:
You typically don’t modify
nginx.conf
that theIngress controller
is using by yourself. You write anIngress
manifest and rest is taken byIngress controller
andKubernetes
.nginx.conf
in thePod
responsible for routing (yourIngress controller
) will reflect yourIngress
manifests.Configmaps
andAnnotations
can be used to modify/alter the configuration of yourIngress controller
. With theConfigmap
you can say to enablegzip2
compression and with annotation you can say to use a specificrewrite
.To make things clearer. The guide that is referenced here is a frontend
Pod
withnginx
installed that passes the request to abackend
. This example apart from usingnginx
and forwarding traffic is not connected with the actualIngress
. It will not acknowledge theIngress
resource and will not act accordingly to the manifest you’ve passed.This example speaking from personal perspective is more of a guide how to connect
frontend
andbackend
and not aboutIngress
.Additional resources:
The guide that I wrote some time ago should help you with the idea on how you can configure basic
Ingress
(it could be little outdated):