I am learning kubernetes and got into a point where I am very confused. I have installed metallb and ingress-nginx so it is possible to access content from outside. I saw several examples that are using nginx image running in pod despite they are also using ingress-nginx.
Isn't ingress-nginx capable to do all work as nginx image? Otherwise what roles those two play?
I need to deploy express server where I would like to utilize some nginx features like gzip so it is where reverse proxy comes.
So do I need to make it work on ingress-nginx level or from nginx image? And if I need nginx image does it mean that I need to run separately nginx image and my built node image with my express app?
Short answer: No
But it's complicated.
nginx
image you mentioned is one of the most popular images (5th on the Docker Hub, by the time of this writing), is relatively small (133MB), and is easy to remember. That's why it is widely used as an example in many tutorials.
Isn't ingress-nginx capable to do all work as nginx image?
To some extent.
Pod and Ingress are different Kubernetes resources, and they act differently. nginx
image is usually deployed as a container inside a pod.
In case of nginx ingress controller, similiar image is used for both Pod and Ingress (mentioned below).
Whenever you deploy (for example) a rewrite rule in ingress controller
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
corresponding entry is being created in nginx.conf
file in nginx-ingress
image (again, mentioned below).
You can read more here.
That being said, there is nginx/nginx-ingress
image that is being deployed when you create Ingress Controller resource.
You can even pull it from Docker Hub
$ docker image pull nginx; docker image pull nginx/nginx-ingress
Using default tag: latest
latest: Pulling from library/nginx
69692152171a: Pull complete
30afc0b18f67: Pull complete
596b1d696923: Pull complete
febe5bd23e98: Pull complete
8283eee92e2f: Pull complete
351ad75a6cfa: Pull complete
Digest: sha256:6d75c99af15565a301e48297fa2d121e15d80ad526f8369c526324f0f7ccb750
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
Using default tag: latest
latest: Pulling from nginx/nginx-ingress
69692152171a: Already exists
30afc0b18f67: Already exists
596b1d696923: Already exists
febe5bd23e98: Already exists
8283eee92e2f: Already exists
351ad75a6cfa: Already exists
ff0027f23312: Pull complete
18361787d4a4: Pull complete
e1aba8353cbb: Pull complete
f9a4438768c4: Pull complete
Digest: sha256:a57fc7835c14b7294180f5c11ae6b81f2745189ef2adb57a5188952bf8aaa17a
Status: Downloaded newer image for nginx/nginx-ingress:latest
docker.io/nginx/nginx-ingress:latest
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx/nginx-ingress latest 1bc8d3e90493 2 weeks ago 177MB
nginx latest d1a364dc548d 2 weeks ago 133MB
As you can see nginx
and nginx-ingress
are two different images.
In fact, you can even build the image yourself.