Skip to content

Building Kind

linuxonz edited this page Dec 30, 2024 · 2 revisions

Building Kind

The instructions provided below specify the steps to build Kind 0.25.0 on Linux on IBM Z for the following distributions:

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

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.

Note: Kind(0.25.0) was verified with docker version 27.1.2 at the time of creation of these instructions.

1. Build environment set up

  • Ensure the current user belongs to group docker:

Use the below command to add group docker if it does not exist:

sudo groupadd docker

Use the below command to add current user to group docker if it has not been done:

sudo usermod -aG docker $USER && newgrp docker

2. Build using script

If you want to build Kind using manual steps, go to STEP 3.

Use the following commands to build Kind using the build script. Please make sure you have wget installed.

wget https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Kind/0.25.0/build_kind.sh

# Build Kind
bash build_kind.sh   [Provide -t option for executing build with tests]

If the build and tests complete successfully, go to STEP 6. In case of error, check logs at <source_root>/logs/ for more details or go to STEP 3 to follow manual build steps.

3. Install Dependencies

export SOURCE_ROOT=/<source_root>/
export PATCH_URL="https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Kind/0.25.0/patch"

3.1. Install Basic Dependencies

  • RHEL (8.8, 8.10, 9.2, 9.4)

    sudo yum remove -y podman buildah
    sudo yum install -y yum-utils
    sudo yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
    sudo yum install -y curl git make wget tar gcc glibc.s390x docker-ce docker-ce-cli containerd.io make which patch
    export CC=gcc
  • SLES (15 SP6)

    sudo zypper install -y curl git make wget tar gcc glibc-devel-static make which patch docker containerd docker-buildx
    export CC=gcc
  • Ubuntu (20.04, 22.04, 24.04, 24.10)

    sudo apt-get update
    sudo apt-get install -y ca-certificates curl gnupg
    sudo install -m 0755 -d /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    sudo chmod a+r /etc/apt/keyrings/docker.gpg
    echo \
        "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
    "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" |
       sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
    sudo apt-get update
    sudo apt-get install -y patch git curl make tar gcc wget make docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin clang

3.2. Install Go 1.23.0

cd $SOURCE_ROOT
export GO_VERSION="1.23.0"
wget -q https://storage.googleapis.com/golang/go"$GO_VERSION".linux-s390x.tar.gz
chmod ugo+r go"$GO_VERSION".linux-s390x.tar.gz
sudo tar -C /usr/local -xzf go"$GO_VERSION".linux-s390x.tar.gz
sudo ln -sf /usr/local/go/bin/go /usr/bin/
sudo ln -sf /usr/local/go/bin/gofmt /usr/bin/
sudo ln -sf /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc # (Only on RHEL and SLES)
go version

3.3. Export Go path

mkdir $SOURCE_ROOT/go
export GOPATH=$SOURCE_ROOT/go

4. Build Kind binary and images

4.1. Start docker service

sudo service docker start

4.2. Download Kind source code and apply patches

cd $SOURCE_ROOT
git clone -b v0.25.0 https://github.com/kubernetes-sigs/kind.git
cd $SOURCE_ROOT/kind
curl -s $PATCH_URL/kind.patch | git apply --ignore-whitespace -

4.3. Build Kind binaries

cd $SOURCE_ROOT/kind
make build
export PATH=${SOURCE_ROOT}/kind/bin:$PATH

4.4. Build Kind base images

cd $SOURCE_ROOT/kind
make -C images/base quick

5. Testing (Optional)

cd $SOURCE_ROOT/kind
make test
make unit
make integration

6. Verification (Optional)

6.1. Build cross image

cd $SOURCE_ROOT
git clone -b v0.17.10 https://github.com/kubernetes/release.git
cd release
curl -s $PATCH_URL/release.patch | git apply --ignore-whitespace -
export REGISTRY=<registry-url>
docker buildx inspect
cd images/build/cross/
TARGETPLATFORM=s390x make container
docker inspect ${REGISTRY}/kube-cross-s390x:v1.31.0-go1.23.0-bullseye.0 | grep Arch

6.2. Build Node image

cd $SOURCE_ROOT
git clone -b v1.31.0 https://github.com/kubernetes/kubernetes.git
cd Kubernetes
sed -i 's,${KUBE_CROSS_IMAGE}:${KUBE_CROSS_VERSION}, ${REGISTRY}/kube-cross-s390x:v1.31.0-go1.23.0-bullseye.0, g' build/build-image/Dockerfile
sed -i 's,v1.31.0-go1.22.5-bullseye.0, v1.31.0-go1.23.0-bullseye.0, g' build/build-image/cross/VERSION
docker buildx use default
kind build node-image
docker images | grep node
docker tag kindest/node:latest ${REGISTRY}/kindest/node:latest

6.3. Create K8s cluster

kind create cluster --image=<node image>

Following example shows logs for a successful cluster creation:

Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:latest) 🖼
 ✓ Preparing nodes 📦
 ✓ Writing configuration 📜
 ✓ Starting control-plane 🕹️
 ✓ Installing CNI 🔌
 ✓ Installing StorageClass 💾
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Have a nice day! 👋

References:

Clone this wiki locally