Skip to content

Building NGINX Ingress Controller

aborkar-ibm edited this page Jul 15, 2020 · 33 revisions

Building NGINX Ingress Controller

These instructions will not be maintained. Images for Nginx Ingress Controller v0.33.0 and above are available here. Refer document here for deployment.

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

  • RHEL (7.5, 7.6, 7.7, 8.0, 8.1)
  • SLES (12 SP4, 15 SP1)
  • Ubuntu (16.04, 18.04, 19.10)

Prerequisites:

  • Kubernetes. For deploying NGINX Ingress Controller, you must have Kubernetes installed. Download Kubernetes binary from Kubernetes.
  • Docker packages are provided for SLES, Ubuntu and RHEL (7.5 or higher) in their respective repositories. Instructions for installing Docker on RHEL(7.3) can be found here. You may use the same instructions for RHEL (7.5, 7.6, 7.7) as the binaries are expected to be compatible. More information about Docker CE can be found here.
  • At the time of creation of these build instructions NGINX Ingress Controller was verified using Kubernetes version 1.15.1 and Docker 18.06.

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.

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.27.0/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>/
  • RHEL (7.5, 7.6, 7.7)

    sudo yum install -y git make curl
    
  • RHEL (8.0, 8.1)

    sudo yum install -y git make curl
    
  • SLES (12 SP4, 15, 15 SP1)

    sudo zypper install -y git make curl
    
  • Ubuntu (16.04, 18.04, 19.04)

    sudo apt-get update
    sudo apt-get install -y git make golang-1.10 curl
    export PATH=/usr/lib/go-1.10/bin:$PATH
    
  • Install Go - Instructions for building Go can be found here.

Step 3: Build NGINX Ingress Controller

export GOPATH=$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 nginx-0.27.0

Apply patch. This patch is needed to build nginx-ingress-controller-s390x docker image.

curl -o nginx_ingress_code_patch.diff https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/NGINX-ingress-controller/0.27.0/patch/nginx_ingress_code_patch.diff
git apply nginx_ingress_code_patch.diff
  • Build nginx image for s390x

    cd $GOPATH/src/k8s.io/ingress-nginx/images/nginx/
    make container
    
  • Build NGINX Ingress Controller with the nginx image

    cd $GOPATH/src/k8s.io/ingress-nginx/
    make build container
    

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

    quay.io/kubernetes-ingress-controller/nginx-s390x
    quay.io/kubernetes-ingress-controller/nginx-ingress-controller-s390x
    

    Note: Dockerfile commands used to build the NGINX Ingress Controller docker image requires Docker 18.06+.

Step 4: Testing (Optional)

  • Run test cases
    cd $GOPATH/src/k8s.io/ingress-nginx/
    sudo -E make test
    
    Note: The k8s.io/ingress-nginx/internal/ingress/controller/store test currency fails on both x86 and s390x.

Step 5: Deployment

  • Patch deployment files

    cd $GOPATH/src/k8s.io/ingress-nginx/
    wget https://patch-diff.githubusercontent.com/raw/kubernetes/ingress-nginx/pull/4298.diff -O deployment.patch
    git apply deployment.patch
    

    Note: This patch fixes RBAC issues with networking.k8s.io for deployment. It been merged into master and has fixed this issue.

  • Deployment

    cd $GOPATH/src/k8s.io/ingress-nginx/
    kubectl apply -f deploy/static/mandatory.yaml
    

Step 6: Verify installed version

POD_NAMESPACE=ingress-nginx
POD_NAME=$(kubectl get pods --all-namespaces | grep nginx-ingress-controller | awk '{print $2}')
kubectl exec -it $POD_NAME -n $POD_NAMESPACE -- /nginx-ingress-controller --version

Output should be:

-------------------------------------------------------------------------------
NGINX Ingress controller
  Release:    0.27.0
  Build:      git-1387f7b7e
  Repository: https://github.com/kubernetes/ingress-nginx.git
-------------------------------------------------------------------------------

References:

NGINX Ingress Controller GitHub

Clone this wiki locally