Nginx as reverse proxy in Openshift Cluster

Aleksandar Lazic al-nginx at none.at
Mon Jun 29 23:32:13 UTC 2020


Hi,

On 29.06.20 21:50, siva.pannier wrote:
> Hi,
> 
> I am new to Nginx and I could validate some of the reverse proxy scenarios
> in Windows and Ubuntu machine successfully. However I am facing challenges
> on validating them on Openshift cluster platform.
> 
> I am new to Docker/Kubernetes/Openshift. I am able to deploy the below Nginx
> image in Openshift  and hit the welcome page url successfully.
> 
> "https://github.com/sclorg/nginx-ex"
> 
> Now I want to achieve the below things on the image.
> 
> 1) Want to know what is the nginx version deployed on the above image.

You can see the image version in this line in the template.
https://github.com/sclorg/nginx-ex/blob/master/openshift/templates/nginx.json#L232-L236

When you deployed nginx whith the README command the will you have nginx 1.12
`oc new-app centos/nginx-112-centos7~https://github.com/sclorg/nginx-ex`
                    ^^^^^^^^^^

> 2) Want to customize the nginx.conf file frequently and update my container
> with the latest changes.

My suggestion is to use a configmap and mount it to the nginx conf dir.

The command are for the version abouve:

oc create configmap nginx-conf--from-file=nginx.conf=/path/to/your/local/nginx.conf
oc set volume dc/<YOUR-nginx-DC> --add --name=nginx-conf \
   --mount-path=/etc/opt/rh/rh-nginx112/nginx/nginx.conf --type=configmap \
   --configmap-name=nginx-conf


> 3) Want to use the latest version of nginx.

This requires some more tasks.
My suggestion:
* Create a Dockerfile with a "FROM nginx"
* Create a nginx conf and a configmap as described above.
* put everything into a git repository
* call ` oc new-app git-repo`

OpenShift will the create a BC/DC/SVC for you.
It is necessary to create a route to access the nginx setup.

`oc create route edge nginx --service=<Your-Service>`

https://docs.okd.io/3.11/dev_guide/routes.html

This could be a good start point for further adoption.

> 4) Want to know how to locate the nginx.conf file and other nginx files
> deployed through the above image.

This could be done via configmaps. The configmaps are limited to ~1MB afaik.

> 5) When I open a POD terminal, I can see Nginx 1.12 files are deployed in
> /etc/nginx, can I upgrade this to latest version? are these files created by
> the deployment of the above image?

As describe above I would recommend to create your own image with your requirements.

> Please clarify & help me on the above queries.

OpenShift have a quite detailed documentation. I strongly recommend to take a look there.
https://docs.okd.io/3.11/dev_guide/index.html
https://docs.openshift.com/container-platform/3.11/dev_guide/index.html
https://docs.openshift.com/container-platform/4.4/builds/understanding-image-builds.html


> Posted at Nginx Forum: https://forum.nginx.org/read.php?2,288492,288492#msg-288492
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
> 



More information about the nginx mailing list