Skip to content

Commit 168bc20

Browse files
authored
Merge pull request ppc64le#1214 from MatthieuSarter/istio-1.12.0
New build script for istio 1.12.0
2 parents c614c4e + ebf6cc6 commit 168bc20

File tree

16 files changed

+1374
-8
lines changed

16 files changed

+1374
-8
lines changed

i/istio/Makefile

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Based on https://github.com/querycap/istio/blob/release-1.11/Makefile
2+
3+
# all need run on ppc64le host
4+
VERSION ?= 1.12.0
5+
HUB ?= docker.io/istio
6+
TEMP_ROOT ?= $(CWD)/.tmp
7+
ISTIO_REPO = https://github.com/istio/istio.git
8+
ISTIO_PROXY_REPO = https://github.com/istio/proxy.git
9+
ISTIO_TOOLS_REPO = https://github.com/istio/tools.git
10+
PUBLISH_IMAGES ?= no
11+
PULL_TOOLS ?= yes
12+
13+
# version tag or branch
14+
# examples: make xxx TAG=1.11.0
15+
TAG = $(VERSION)
16+
RELEASE_BRANCH = master
17+
18+
GIT_CLONE = git clone
19+
GIT_CLONE_TOOLS = git clone
20+
21+
ifneq ($(TAG),master)
22+
RELEASE_BRANCH = release-$(word 1,$(subst ., ,$(VERSION))).$(word 2,$(subst ., ,$(VERSION)))
23+
GIT_CLONE = git clone -b $(TAG)
24+
GIT_CLONE_TOOLS = git clone -b $(RELEASE_BRANCH)
25+
endif
26+
27+
PUBLISH_OPT =
28+
DOCKERX_PUSH = false
29+
ifeq ($(PUBLISH_IMAGES),yes)
30+
PUBLISH_OPT = --push
31+
DOCKERX_PUSH = true
32+
endif
33+
34+
BUILD_TOOLS_VERSION = $(RELEASE_BRANCH)-latest
35+
BUILD_TOOLS_IMAGE = $(HUB)/build-tools:$(BUILD_TOOLS_VERSION)
36+
BUILD_TOOLS_PROXY_IMAGE = $(HUB)/build-tools-proxy:$(BUILD_TOOLS_VERSION)
37+
38+
echo:
39+
@echo "TAG: $(TAG)"
40+
@echo "RELEASE_BRANCH: $(RELEASE_BRANCH)"
41+
42+
clean.build-tools:
43+
rm -rf $(TEMP_ROOT)/tools
44+
45+
clone.build-tools:
46+
$(GIT_CLONE_TOOLS) --depth=1 $(ISTIO_TOOLS_REPO) $(TEMP_ROOT)/tools
47+
patches/apply_patches.sh $(TEMP_ROOT)/tools tools ${BUILD_TOOLS_VERSION}
48+
49+
# Build build-tools && build-tools-proxy for ppc64le
50+
dockerx.build-tools: clean.build-tools clone.build-tools
51+
cd $(TEMP_ROOT)/tools/docker/build-tools \
52+
&& DRY_RUN=1 HUB=$(HUB) CONTAINER_BUILDER="buildx build $(PUBLISH_OPT) --platform=linux/ppc64le" ./build-and-push.sh; \
53+
54+
cleanup.envoy:
55+
rm -rf $(TEMP_ROOT)/proxy
56+
57+
ISTIO_ENVOY_VERSION = $(shell cat $(TEMP_ROOT)/istio/istio.deps | grep lastStableSHA | sed 's/.*"lastStableSHA": "\([a-zA-Z0-9]*\)"/\1/g')
58+
59+
# Clone istio/proxy
60+
# To checkout last stable sha from istio/istio
61+
clone.envoy: cleanup.istio clone.istio
62+
git clone $(ISTIO_PROXY_REPO) $(TEMP_ROOT)/proxy
63+
cd $(TEMP_ROOT)/proxy && git checkout $(ISTIO_ENVOY_VERSION)
64+
patches/apply_patches.sh $(TEMP_ROOT)/proxy proxy ${ISTIO_ENVOY_VERSION}
65+
66+
# Build envoy
67+
build.envoy: cleanup.envoy clone.envoy
68+
if [ '$(PULL_TOOLS)' = 'yes' ]; then docker pull $(BUILD_TOOLS_PROXY_IMAGE); fi
69+
cd $(TEMP_ROOT)/proxy && make BUILD_WITH_CONTAINER=1 IMG=$(BUILD_TOOLS_PROXY_IMAGE) build_envoy
70+
mkdir -p $(TEMP_ROOT)/envoy-linux-ppc64le && cp $(TEMP_ROOT)/proxy/bazel-bin/src/envoy/envoy $(TEMP_ROOT)/envoy-linux-ppc64le/envoy
71+
72+
cleanup.istio:
73+
rm -rf $(TEMP_ROOT)/istio
74+
75+
clone.istio:
76+
$(GIT_CLONE) --depth=1 $(ISTIO_REPO) $(TEMP_ROOT)/istio
77+
patches/apply_patches.sh $(TEMP_ROOT)/istio istio ${VERSION}
78+
79+
ISTIO_MAKE = cd $(TEMP_ROOT)/istio && IMG=$(BUILD_TOOLS_IMAGE) HUB=$(HUB) VERSION=$(VERSION) BASE_VERSION=$(TAG) TAG=$(TAG) make
80+
81+
ISTIO_LINUX_PPC64LE_RELEASE_DIR = $(TEMP_ROOT)/istio/out/linux_ppc64le/release
82+
83+
## avoid to download from google storage
84+
## envoy-centos-$(ISTIO_ENVOY_VERSION) just a hack
85+
copy.envoy: copy.envoy-ppc64le copy.wasm
86+
87+
copy.wasm:
88+
for f in $(TEMP_ROOT)/envoy-linux-ppc64le/extensions/*.wasm; do \
89+
filename=$$(basename $${f}); \
90+
cp $${f} "$(ISTIO_LINUX_PPC64LE_RELEASE_DIR)/$${filename}"; \
91+
cp $${f} "$(ISTIO_LINUX_PPC64LE_RELEASE_DIR)/$$(echo $${filename} | sed "s/-/_/g" | sed "s/_filter/-$(ISTIO_ENVOY_VERSION)/")"; \
92+
cp $${f} "$(ISTIO_LINUX_PPC64LE_RELEASE_DIR)/$${filename}"; \
93+
cp $${f} "$(ISTIO_LINUX_PPC64LE_RELEASE_DIR)/$$(echo $${filename} | sed "s/-/_/g" | sed "s/_filter/-$(ISTIO_ENVOY_VERSION)/")"; \
94+
done
95+
96+
copy.envoy-ppc64le:
97+
rm -rf $(ISTIO_LINUX_PPC64LE_RELEASE_DIR) && mkdir -p $(ISTIO_LINUX_PPC64LE_RELEASE_DIR)
98+
cp $(TEMP_ROOT)/envoy-linux-ppc64le/envoy $(ISTIO_LINUX_PPC64LE_RELEASE_DIR)/envoy
99+
cp $(TEMP_ROOT)/envoy-linux-ppc64le/envoy $(ISTIO_LINUX_PPC64LE_RELEASE_DIR)/envoy-$(ISTIO_ENVOY_VERSION)
100+
cp $(TEMP_ROOT)/envoy-linux-ppc64le/envoy $(ISTIO_LINUX_PPC64LE_RELEASE_DIR)/envoy-centos-$(ISTIO_ENVOY_VERSION)
101+
102+
# Build istio binaries and copy envoy binary for ppc64le
103+
# in github actions it will download from artifacts
104+
build.istio: cleanup.istio clone.istio copy.envoy
105+
cd $(TEMP_ROOT)/istio \
106+
&& $(ISTIO_MAKE) build-linux TARGET_ARCH=ppc64le
107+
108+
ESCAPED_HUB := $(shell echo $(HUB) | sed "s/\//\\\\\//g")
109+
110+
# Replace istio base images and pull latest BUILD_TOOLS_IMAGE
111+
# sed must be gnu sed
112+
dockerx.istio.prepare:
113+
sed -i -e 's/gcr.io\/istio-release\/\(base\|distroless\)/$(ESCAPED_HUB)\/\1/g' $(TEMP_ROOT)/istio/pilot/docker/Dockerfile.pilot
114+
sed -i -e 's/gcr.io\/istio-release\/\(base\|distroless\)/$(ESCAPED_HUB)\/\1/g' $(TEMP_ROOT)/istio/pilot/docker/Dockerfile.proxyv2
115+
sed -i -e 's/gcr.io\/istio-release\/\(base\|distroless\)/$(ESCAPED_HUB)\/\1/g' $(TEMP_ROOT)/istio/operator/docker/Dockerfile.operator
116+
sed -i -e 's/gcr.io\/istio-release\/\(base\|distroless\)/$(ESCAPED_HUB)\/\1/g' $(TEMP_ROOT)/istio/cni/deployments/kubernetes/Dockerfile.install-cni
117+
if [ '$(PULL_TOOLS)' == 'yes' ]; then docker pull $(BUILD_TOOLS_IMAGE); fi
118+
119+
# Build istio base images
120+
dockerx.istio-base:
121+
$(ISTIO_MAKE) dockerx.base DOCKERX_PUSH=$(DOCKERX_PUSH) DOCKER_ARCHITECTURES=linux/ppc64le
122+
$(ISTIO_MAKE) dockerx.distroless DOCKERX_PUSH=$(DOCKERX_PUSH) DOCKER_ARCHITECTURES=linux/ppc64le
123+
124+
COMPONENTS = proxyv2 pilot operator install-cni
125+
dockerx.istio-images: dockerx.istio.prepare dockerx.istio-base
126+
$(foreach component,$(COMPONENTS),cd $(TEMP_ROOT)/istio && $(ISTIO_MAKE) dockerx.$(component) DOCKERX_PUSH=$(DOCKERX_PUSH) DOCKER_BUILD_VARIANTS="default distroless" DOCKER_ARCHITECTURES=linux/ppc64le;)
127+
128+
# Build istio deb
129+
deb:
130+
$(ISTIO_MAKE) deb TARGET_ARCH=ppc64le
131+
mkdir -p $(TEMP_ROOT)/deb
132+
cp $(ISTIO_LINUX_PPC64LE_RELEASE_DIR)/istio-sidecar.deb $(TEMP_ROOT)/istio-sidecar.deb
133+
cp $(ISTIO_LINUX_PPC64LE_RELEASE_DIR)/istio.deb $(TEMP_ROOT)/istio.deb
134+
135+
check.istio:
136+
@echo "ISTIO_ENVOY_VERSION: $(ISTIO_ENVOY_VERSION)"
137+
docker pull --platform=linux/ppc64le $(HUB)/proxyv2:$(VERSION)-distroless
138+
docker run --rm --platform=linux/ppc64le --entrypoint=/usr/local/bin/envoy $(HUB)/proxyv2:$(VERSION)-distroless --version

i/istio/README.md

+51-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,57 @@
1-
# Build istio 1.14.3
1+
# Istio for ppc64le
22

3-
In order to build istio, please copy the contents of current directory to a directory
4-
on the build machine. Please ensure that build script and patches directory are sibblings on
5-
the build machine.
3+
This scripts allows to build istio package and docker images for ppc64le.
64

7-
Note that the patches are for istio-proxy build which is a dependency for istio build.
5+
## How to use?
86

9-
Enable execute permissions for the build script and run it as:
7+
```
8+
build.sh <version to build>
9+
```
10+
11+
### Customizing the build
12+
13+
Several environment variables can be used to customize the build :
14+
15+
* *WORK_DIR*: defines the path to the temporary working directory (default: temp directory created with mktemp)
16+
* *HUB*: defines the registry and repository to be used for the images (default: localhost:5000/istio)
17+
* *BUILD_TOOLS*: defines if the build-tools images will be built (default: yes)
18+
* *PUBLISH_TOOLS*: defines if the build-tools images will be published to the registry (default: no)
19+
* *BUILD_PROXY*: defines if the envoy binary will be built (default: yes)
20+
* *BUILD_IMAGES*: defines if the istio images will be built (default: yes)
21+
* *PUBLISH_IMAGES*: defines if the istio images will be published to the registry (default: no)
22+
* *BUILD_PACKAGES*: defines if the istio packages (*istio-[version].tar.gz* and *istioctl-[version].tar.gz*) will be built (default: yes)
23+
* *ISTIO_REPO*: defines the URL to the istio source repo (default: https://github.com/istio/istio.git)
24+
* *ISTIO_PROXY_REPO*: defines the URL to the proxy source repo (default: https://github.com/istio/proxy.git)
25+
* *ISTIO_TOOLS_REPO*: defines the URL to the build-tools source repo (default: https://github.com/istio/tools.git)
26+
* *DEBUG*: if set to yes, WORK_DIR won't be deleted once build is completed (defalult: no)
27+
28+
### Environment Requirements
29+
30+
Build can only be done on a Linux ppc64le environement, with Docker and make installed.
31+
32+
## How to install ?
33+
34+
### Install Istio Operator
35+
36+
Same as https://istio.io/latest/docs/setup/install/operator, but with `--hub` if you created a custom build.
37+
38+
```
39+
$ istioctl operator init --hub=... --tag=1.12.0
40+
```
41+
42+
### Install Istio
43+
44+
Same as https://istio.io/latest/docs/setup/install
1045

1146
```
12-
# chmod +x istio_rhel7.6.sh
13-
# ./istio_rhel7.6.sh
47+
$ kubectl create ns istio-system
48+
$ kubectl apply -f - <<EOF
49+
apiVersion: install.istio.io/v1alpha1
50+
kind: IstioOperator
51+
metadata:
52+
namespace: istio-system
53+
name: example-istiocontrolplane
54+
spec:
55+
hub: <...>
56+
profile: demo
1457
```

0 commit comments

Comments
 (0)