Building NGINX Ingress Controller - linux-on-ibm-z/docs GitHub Wiki

Building NGINX Ingress Controller

The instructions provided below specify the steps to build NGINX Ingress Controller version 1.11.1 on Linux on IBM Z for following distributions:

  • RHEL (8.8, 8.10, 9.2, 9.4)
  • SLES (12 SP5, 15 SP5, 15 SP6)
  • Ubuntu (20.04, 22.04, 24.04)

Prerequisites:

  • Docker 19.03+ is required to build the NGINX Ingress Controller Docker image.
  • Docker packages are provided for Ubuntu, RHEL and SLES and in their respective repositories. You can also use the static binaries provided here. More information about Docker CE can be found here.

General Notes:

  • When following the steps below, please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referenced in these instructions. This directory is temporary and writable, and you can place it anywhere you like.
  • You may need to manage Docker as a non-root user to build the NGINX Ingress Controller. See here for instructions if needed.

Note: When these build instructions were created, the NGINX Ingress Controller was verified with the following Docker versions: SLES 12 SP5 : v25.0.5 and RHEL, SLES 15 and Ubuntu : v27.1.1

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/1.11.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 for test execution. 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/1.11.1/patch
  • RHEL (8.8, 8.10, 9.2, 9.4)

    sudo yum install -y curl git make wget
    
  • SLES 12 SP5

    sudo zypper install -y curl git make which wget libcurl-devel nghttp2-devel 
    
  • SLES (15 SP5, 15 SP6)

    sudo zypper install -y curl git make which wget
    
  • Ubuntu (20.04, 22.04, 24.04)

    sudo apt-get update
    sudo apt-get install -y curl git make wget
    

Step 3: Install Go

cd $SOURCE_ROOT
PRESERVE_ENVARS=~/.bash_profile  
wget https://go.dev/dl/go1.22.0.linux-s390x.tar.gz
chmod ugo+r go1.22.0.linux-s390x.tar.gz
sudo tar -C /usr/local -xzf go1.22.0.linux-s390x.tar.gz
echo "export PATH=/usr/local/go/bin:$PATH" >> $PRESERVE_ENVARS
export PATH=/usr/local/go/bin:$PATH
echo "export GOPATH=$(go env GOPATH)" >> $PRESERVE_ENVARS

Step 4: 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 -b controller-v1.11.1 https://github.com/kubernetes/ingress-nginx.git
    cd ingress-nginx/
    
  • Apply the patch. This patch is used to build the 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 test-runner image

     cd $GOPATH/src/k8s.io/ingress-nginx/images/test-runner/
     make build
     docker tag local/e2e-test-runner:"v$(date +%Y%m%d)-7b37df8" gcr.io/ingress-nginx/e2e-test-runner:v1.11.1
    
  • Build NGINX Ingress Controller image

    cd $GOPATH/src/k8s.io/ingress-nginx
    
    # On Ubuntu and RHEL
    sudo make build image
    
    # On SLES
    sudo make build image PKG=k8s.io/ingress-nginx ARCH=s390x COMMIT_SHA=$(git rev-parse --short HEAD) REPO_INFO=$(git config --get remote.origin.url) TAG=v1.11.1
    

    After executing the above steps, these docker images should have been created:

    gcr.io/ingress-nginx/e2e-test-runner
    gcr.io/k8s-staging-ingress-nginx/controller
    

Step 5: Testing (Optional)

cd $GOPATH/src/k8s.io/ingress-nginx/
sudo make test

References: