This article mainly describes how to build the https://github.com/istio/istio project on CentOS 8.2 using local tools. Another approach is to use the BUILD_WITH_CONTAINER parameter to build inside a container, which depends only on make and docker.
1. Install and Upgrade Ruby >= 2.6
1
2
3
| ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
|
1
2
3
4
| yum install -y tar
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
|
1
2
3
| ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
|
2. Install FPM
FPM is a packaging tool that can package source code into rpm, deb, pkg, and other formats. istio currently uses FPM.
1
| yum install -y ruby-devel gcc make rpm-build rubygems
|
1
| gem install --no-document fpm
|
3. Install and Upgrade Go >= 1.16
1
2
3
| go version
go version go1.14.12 linux/amd64
|
- An older Go version fails at build time
1
2
3
4
5
6
| make docker
...
manifests/manifest.go:18:2: package embed is not in GOROOT (/usr/lib/golang/src/embed)
operator/pkg/helm/renderer.go:19:2: package io/fs is not in GOROOT (/usr/lib/golang/src/io/fs)
make: *** [build-linux] Error 1
|
You can look at the go.mod file to check istio’s Go version requirement.
1
2
| yum install -y git
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
|
Reopen the terminal, or run the command it prints, to add gvm to PATH.
- List the available Go versions
1
2
3
4
| gvm listall
...
go1.16.3
|
1
| gvm use go1.16.3 --default
|
1
2
3
| go version
go version go1.16.3 linux/amd64
|
4. Install Docker
- Add the Docker repository
1
| dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
|
1
| dnf install docker-ce --nobest -y
|
1
2
| systemctl enable docker
systemctl start docker
|
5. Build istio
1
| yum install -y make vim
|
A fixed version is specified here to make reproduction easy; you can also use the master branch directly.
1
2
| git clone https://github.com/istio/istio.git -b release-1.10
cd istio
|
- Modify the Makefile to comment out parameters such as
BUILD_WITH_CONTAINER=1
vim Makefile
# -include Makefile.overrides.mk
If you do not want to modify the Makefile, you can also prefix every make command with BUILD_WITH_CONTAINER=0 to build without containers.
Otherwise, the container environment is used for the build by default.
- [Optional] Custom parameters
This step is mainly used to set the image format; the default is docker.io/istio/xxx:tag-or-sha1.
1
2
3
| export USER="shaowenchen"
export HUB="docker.io/$USER"
export TAG="dev"
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| docker images|grep shaowenchen
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
docker.io/shaowenchen/install-cni dev 8a9c31c0c4a7 10 seconds ago 286 MB
docker.io/shaowenchen/operator dev b71597601723 27 seconds ago 240 MB
docker.io/shaowenchen/istioctl dev 5d65d14fd7e4 37 seconds ago 242 MB
docker.io/shaowenchen/app_sidecar_centos_7 dev 26f3a9648acc 47 seconds ago 559 MB
docker.io/shaowenchen/app_sidecar_centos_8 dev 2b0c1152137a About a minute ago 548 MB
docker.io/shaowenchen/app_sidecar_debian_10 dev fef52d04e703 2 minutes ago 353 MB
docker.io/shaowenchen/app_sidecar_debian_9 dev 389d00724d36 3 minutes ago 337 MB
docker.io/shaowenchen/app_sidecar_ubuntu_focal dev 572f901273f1 3 minutes ago 314 MB
docker.io/shaowenchen/app_sidecar_ubuntu_bionic dev f8cce2842939 4 minutes ago 317 MB
docker.io/shaowenchen/app_sidecar_ubuntu_xenial dev 7e5622aacfa1 4 minutes ago 371 MB
docker.io/shaowenchen/app dev 69c061680f8e 5 minutes ago 189 MB
docker.io/shaowenchen/proxyv2 dev a09e64c4e01f 5 minutes ago 305 MB
docker.io/shaowenchen/pilot dev 047f2d849519 5 minutes ago 241 MB
|
- Build a single component and its image
The build process for each component image is defined in tools/istio-docker.mk.
1
2
3
4
| DOCKER_TARGETS ?= docker.pilot docker.proxyv2 docker.app docker.app_sidecar_ubuntu_xenial \
docker.app_sidecar_ubuntu_bionic docker.app_sidecar_ubuntu_focal docker.app_sidecar_debian_9 \
docker.app_sidecar_debian_10 docker.app_sidecar_centos_8 docker.app_sidecar_centos_7 \
docker.istioctl docker.operator docker.install-cni
|
Taking istioctl as an example:
1
2
3
4
| ls out/linux_amd64
bug-report docker_build envoy-centos istio-cni istio-cni-taint istio-iptables logs pilot-agent release
client envoy install-cni istio-cni-repair istioctl istio_is_init operator pilot-discovery server
|
1
2
3
4
| docker images|grep istioctl
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
docker.io/shaowenchen/istioctl dev f55daa65098d 7 seconds ago 242 MB
|
- Push the image to DockerHub
You need to log in to DockerHub before pushing.
1
| make push.docker.istioctl
|
6. Summary
Building on CentOS 8 is recommended, because on CentOS 7.6 the build hangs while building the app_sidecar_centos image. Below is an excerpt from the logs.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| Step 1/14 : ARG VM_IMAGE_NAME=ubuntu
Step 2/14 : ARG VM_IMAGE_VERSION=bionic
Step 3/14 : ARG BASE_VERSION=latest
Step 4/14 : FROM gcr.io/istio-release/app_sidecar_base_${VM_IMAGE_NAME}_${VM_IMAGE_VERSION}:${BASE_VERSION}
---> 697dbc6cd975
Step 5/14 : COPY certs/ /var/lib/istio/
---> Using cache
---> 725e4acd0342
Step 6/14 : COPY certs/default/* /var/run/secrets/istio/
---> Using cache
---> a1f2cd8f8596
Step 7/14 : COPY istio-sidecar.deb /tmp/istio-sidecar.deb
---> a1a01e6e9993
Step 8/14 : RUN dpkg -i /tmp/istio-sidecar.deb && rm /tmp/istio-sidecar.deb
---> Running in 28c5abc9a6a0
|
After the sequence of operations above, Docker also hangs, and the exact cause remains to be investigated.
CentOS 8 replaced the Docker CLI with Podman, and GLIBC does not need to be upgraded, so the build succeeds easily.
7. References