Building NGINX Ingress Controller - linux-on-ibm-z/docs GitHub Wiki
Building NGINX Ingress Controller
These instructions will not be maintained. Images for Nginx Ingress Controller v1.0.1 and above are available here. Refer document here for deployment.
The instructions provided below specify the steps to build NGINX Ingress Controller version 0.48.1 on Linux on IBM Z for following distributions:
- RHEL (7.8, 7.9, 8.2, 8.3, 8.4)
- SLES (12 SP5, 15 SP2, 15 SP3)
- Ubuntu (18.04, 20.04, 21.04)
Prerequisites:
- Kubernetes. For deploying NGINX Ingress Controller, you must have Kubernetes installed. Download Kubernetes binary from Kubernetes.
- Docker 19.03+ is required to build the NGINX Ingress Controller docker image. And Kubernetes 1.19+ is required for deployment
- Docker packages are provided for RHEL, SLES and Ubuntu in their respective repositories. You can also use the static binaries provided here. More information about Docker CE can be found here.
- Additional tips on installing Docker on Linux on IBM Z can be found here.
- At the time of creation of these build instructions NGINX Ingress Controller was verified using Kubernetes version 1.21.0 and Docker 20.10.7.
General Notes:
- When following the steps below please use a standard permission user unless otherwise specified.
- A directory
/<source_root>/
will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it. - You may need to manage docker as a non-root user in order to build NGINX Ingress Controller. See here for instructions if needed.
Step 1: Build using script
If you want to build nginx-ingress-controller using manual steps, go to STEP 2.
Use the following commands to build nginx-ingress-controller using the build script. Please make sure you have wget
and Docker
installed.
wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/NGINX-ingress-controller/0.48.1/build_nginx-ingress-controller.sh
# Build nginx-ingress-controller
bash build_nginx-ingress-controller.sh [Provide -t option for executing build with tests]
If the build completes successfully, go to STEP 5. In case of error, check logs
for more details or go to STEP 2 to follow manual build steps.
Step 2: Install dependencies
export SOURCE_ROOT=/<source_root>/
export PATCH_URL=https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/NGINX-ingress-controller/0.48.1/patch
-
RHEL (7.8, 7.9)
sudo yum install -y make curl tar wget
- Build Git
Note: RHEL (7.8, 7.9) has older version of git in repo because of which commit SHA is not generated properlysudo yum groupinstall "Development Tools" sudo yum install -y gettext-devel openssl-devel perl-devel perl-CPAN zlib-devel curl-devel wget https://github.com/git/git/archive/refs/tags/v2.26.3.tar.gz tar -xvzf v2.26.3.tar.gz cd git-2.26.3 make configure ./configure --prefix=/usr/local sudo make install export PATH=/usr/local/bin:$PATH
- Build Git
-
RHEL (8.2, 8.3, 8.4)
sudo yum install -y git make curl wget
-
SLES (12 SP5, 15 SP2, 15 SP3)
sudo zypper install -y git make curl which wget
-
Ubuntu (18.04, 20.04, 21.04)
sudo apt-get update sudo apt-get install -y git make curl wget
2.1) Install Go
- Instructions for building latest Go can be found here
Step 3: Build NGINX Ingress Controller
-
Set environment variables
export GOPATH=$SOURCE_ROOT
-
Clone the
ingress-nginx
github repository.cd $SOURCE_ROOT mkdir -p $GOPATH/src/k8s.io/ cd $GOPATH/src/k8s.io/ git clone https://github.com/kubernetes/ingress-nginx.git cd ingress-nginx/ git checkout controller-v0.48.1
-
Apply patch. This patch is needed to downgrade lua modules to build
nginx
docker image.wget https://patch-diff.githubusercontent.com/raw/kubernetes/ingress-nginx/pull/7355.diff git apply 7355.diff
-
Apply patch. This patch is needed to build nginx base image which is used to build
nginx-ingress-controller-s390x
docker image.curl -o nginx_ingress_code_patch.diff $PATCH_URL/nginx_ingress_code_patch.diff git apply nginx_ingress_code_patch.diff
-
Build nginx image
cd $GOPATH/src/k8s.io/ingress-nginx/images/nginx/ make build
-
Build test-runner image
cd $GOPATH/src/k8s.io/ingress-nginx/images/test-runner/ make build docker tag local/e2e-test-runner:"v$(date +%m%d%Y)-1de9a24b2" gcr.io/ingress-nginx/e2e-test-runner:v0.48.1
-
Build NGINX Ingress Controller image
cd $GOPATH/src/k8s.io/ingress-nginx sudo make build image
After executing the above steps, these docker images should have been created:
gcr.io/k8s-staging-ingress-nginx/nginx gcr.io/ingress-nginx/e2e-test-runner gcr.io/k8s-staging-ingress-nginx/controller
Step 4: Testing (Optional)
cd $GOPATH/src/k8s.io/ingress-nginx/
sudo make test
Step 5: Deployment
cd $GOPATH/src/k8s.io/ingress-nginx/
kubectl apply -f deploy/static/provider/baremetal/deploy.yaml
Step 6: Verify NGINX Ingress controller
POD_NAMESPACE=ingress-nginx
POD_NAME=$(kubectl get pods --all-namespaces | grep ingress-nginx-controller | awk '{print $2}')
kubectl exec -it $POD_NAME -n $POD_NAMESPACE -- /nginx-ingress-controller --version
Output should be:
-------------------------------------------------------------------------------
NGINX Ingress controller
Release: v0.48.1
Build: git-1de9a24b2
Repository: https://github.com/kubernetes/ingress-nginx.git
nginx version: nginx/1.20.1
-------------------------------------------------------------------------------