I’m managing Kubernetes + nginx.
I’d like to install dynamic modules on nginx that are provided by Nginx Ingress Controller.
Those dynamic modules are not offered by Nginx Ingress Controller official configmap (https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/)
So I believe, I need to build my own Docker container of Nginx Ingress Controller.
(Could be added at this? https://github.com/kubernetes/ingress-nginx/blob/8951b7e22ad3952c549150f61d7346f272c563e1/images/nginx/rootfs/build.sh#L618-L632 )
Do you know how we can customize the controller and manage it by helm chart? I’m thinking about making a Fork branch from the controller master repo on Github.
But I don’t have any idea on how we install a customized version of the controller on terraform + helm chart.
However, I would prefer to use a non-customizable solution (because of some annotation settings)
Environment:
Kubernetes
Nginx Ingress Controller is installed by helm chart + terraform
Nginx Ingress Controller -> https://github.com/kubernetes/ingress-nginx/tree/main/charts/ingress-nginx
Terraform:
resource "helm_release" "nginx-ingress-controller" {
name = "nginx-ingress-controller"
chart = "ingress-nginx/ingress-nginx"
namespace = "kube-system"
version = "3.34.0"
}
dynamic modules
https://docs.nginx.com/nginx/admin-guide/dynamic-modules/dynamic-modules/
(install process might be using --add-dynamic-module
option, and set load_module modules/something.so
on nginx.conf
via ingress.yaml
)
Thank you.
2
Answers
Please take a look at Cloud Native Buildpacks.
Images can be built directly from application source without additional instructions.
Maybe this nginx-buildpack solves your problem:
PS. https://12factor.net/build-release-run
TL;DR
Extend the official image with the dynamic modules, and update the
helm_release
terraform
resource toset
thecontroller.image.registry
,controller.image.image
,controller.image.tag
,controller.image.digest
, andcontroller.image.digestChroot
for your custom image along with acontroller.config.main-snippet
to load the dynamic module(s) in the main context.This is similar to my previous answer for building modules using the official nginx image. You can extend the
ingress-nginx/controller
image, build the modules in one stage, extend the official image with the dynamic modules in another stage, and use the image in yourhelm_release
. An example for extending theingress-nginx/controller
with theecho-nginx-module
e.g.:Docker
… build and push the image e.g.:
docker build --rm -t myrepo/ingress-nginx/controller:v1.5.1-echo --build-arg INGRESS_NGINX_CONTROLLER_VERSION=v1.5.1 . && docker push myrepo/ingress-nginx/controller:v1.5.1-echo
Terraform
Update the
terraform
helm_release
resource to install the charts using the custom image and adding amain-snippet
to set theload_module
directive in themain
context:The
controller.image.digest
is the imageRepoDigest
:docker inspect myrepo/ingress-nginx/controller:v1.5.1-echo --format '{{range .RepoDigests}}{{println .}}{{end}}' |cut -d'@' -f2
The
controller.image.digestChroot
is theParent
sha:docker inspect myrepo/ingress-nginx/controller:v1.5.1-echo --format {{.Parent}}
Test
nginx
pod:kubectl run nginx --image=nginx
kubectl expose pod nginx --port 80 --target-port 80
server-snippet
:curl
: