Skip to content

Building NGINX Ingress Controller

linuxonz edited this page Oct 30, 2024 · 25 revisions

Building NGINX Ingress Controller

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

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

Prerequisites:

  • Docker 19.03.0+ is required to build the NGINX Ingress Controller Docker image.
  • Docker packages are provided for Ubuntu, RHEL and SLES and in their respective repositories. 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: RHEL, SLES 15 and Ubuntu : v27.1.1

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.3/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.

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.3/patch
  • RHEL (8.8, 8.10, 9.2, 9.4)

    sudo yum install -y curl git make wget
  • 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

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

4. Build NGINX Ingress Controller

  • Set environment variables

    export GOPATH=$SOURCE_ROOT
  • Clone the ingress-nginx github repository.

    cd $SOURCE_ROOT
    export TAG=v1.11.3
    mkdir -p $GOPATH/src/k8s.io/
    cd $GOPATH/src/k8s.io/
    git clone -b controller-v1.11.3 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 -sSL $PATCH_URL/nginx_ingress_code_patch.diff | git apply -
  • Build test-runner image

     cd $GOPATH/src/k8s.io/ingress-nginx/images/test-runner/
     sudo make build
     sudo docker tag local/e2e-test-runner:"v$(date +%Y%m%d)-f6456ea86" gcr.io/ingress-nginx/e2e-test-runner:v1.11.3
  • 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.3

    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

5. Testing (Optional)

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

References:

Clone this wiki locally