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.12.1 on Linux on IBM Z for following distributions:

  • RHEL (8.8, 8.10, 9.2, 9.4, 9.5)
  • SLES 15 SP6
  • Ubuntu (22.04, 24.04, 24.10)

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.4.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.12.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.

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

    sudo yum install -y --allowerasing curl git make wget
  • SLES 15 SP6

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

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

3. Install Go

cd $SOURCE_ROOT
wget https://go.dev/dl/go1.24.1.linux-s390x.tar.gz
chmod ugo+r go1.24.1.linux-s390x.tar.gz
sudo tar -C /usr/local -xzf go1.24.1.linux-s390x.tar.gz
export PATH=/usr/local/go/bin:$PATH

4. Build NGINX Ingress Controller

  • Set environment variables

     export GOPATH=$(go env GOPATH)
     export NGINX_VERSION="1.2.1"
     export TESTRUNNER_VERSION="1.3.1"
     export I_N_BUILDER_CONFIG="$GOPATH/src/k8s.io/ingress-nginx/buildx-config.toml"
  • 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.12.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 -sSL "$PATCH_URL/nginx_ingress_code_patch.diff" | git apply -
  • Create the local docker registry configuration file

    cat << EOF > "${I_N_BUILDER_CONFIG}"
[registry."localhost:5000"]
http = true
insecure = true
EOF
  • Start the local docker registry
docker run -d -p 5000:5000 --restart always --name registry registry:2
  • Build nginx image

     cd "$GOPATH/src/k8s.io/ingress-nginx/images/nginx/"
     make PLATFORMS="linux/s390x" REGISTRY="localhost:5000" I_N_BUILDER_CONFIG="${I_N_BUILDER_CONFIG}" push
  • Build test-runner image

     cd "$GOPATH/src/k8s.io/ingress-nginx/images/test-runner/"
     make PLATFORMS="linux/s390x" REGISTRY="localhost:5000" BASE_IMAGE="localhost:5000/nginx:v${NGINX_VERSION}" I_N_BUILDER_CONFIG="${I_N_BUILDER_CONFIG}" push
  • Build NGINX Ingress Controller image

     cd "$GOPATH/src/k8s.io/ingress-nginx/"
     make BASE_IMAGE="localhost:5000/nginx:v${NGINX_VERSION}" build image

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

     us-central1-docker.pkg.dev/k8s-staging-images/ingress-nginx/controller:v1.12.1
     localhost:5000/e2e-test-runner:v1.3.1

5. Testing (Optional)

cd $GOPATH/src/k8s.io/ingress-nginx/
make E2E_IMAGE="localhost:5000/e2e-test-runner:v${TESTRUNNER_VERSION}" test
make E2E_IMAGE="localhost:5000/e2e-test-runner:v${TESTRUNNER_VERSION}" lua-test

References:

⚠️ **GitHub.com Fallback** ⚠️