Skip to content

Commit d002796

Browse files
authored
doc:update how to build istio proxyv2 image (#210)
1 parent 8f5d020 commit d002796

File tree

2 files changed

+160
-95
lines changed

2 files changed

+160
-95
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: "MOSN 与 Istio 的 proxyv2 镜像 build 方法"
3+
linkTitle: "MOSN 与 Istio 的 proxyv2 镜像 build 方法"
4+
date: 2022-03-25
5+
aliases: "/zh/docs/istio"
6+
weight: 3
7+
description : >
8+
本文主要讲述 MOSN 与 Istio 的 proxyv2 镜像 build 方法,并且如何仅更新 MOSN
9+
---
10+
11+
本文的完整构建镜像方法均是基于 MacOS 和 Istio 1.10.6 版本进行的构建,在其他操作系统 Istio 版本上可能存在部分细节差异,需要进行调整。
12+
除了完整构建方式外,如果仅有 MOSN 代码发生变化,还可以使用 单独更新 MOSN 版本 的方式构建镜像。
13+
14+
**通常情况下,您不需要额外构建镜像,可直接用我们提供的镜像 `mosnio/proxyv2:${MOSN-VERSION}-${ISTIO_VERSION}`,如`docker pull mosnio/proxyv2:v1.0.0-1.10.6`**
15+
16+
完整的镜像构建(基于 MacOS 和 Istio 1.10.6)
17+
==========
18+
19+
1、下载完整的 istio 源代码,并且切换到对应的版本
20+
21+
```bash
22+
git clone [email protected]:istio/istio.git
23+
cd istio
24+
git checkout 1.10.6
25+
```
26+
27+
2、由于目前 Istio 默认会加载 wasm,我们需要将相关逻辑注释掉,再重新编译镜像,避免一些不必要的错误。详细的改动可见 [istio-diff](../istio/istio-diff)
28+
29+
3、编译 MOSN 二进制,MOSN 提供了镜像编译的方式可直接编译 linux 的二进制;同时由于在 MacOS 上构建的过程中,Istio 还会下载一个 MacOS 版本,因此还需要编译一个 MacOS 的二进制
30+
31+
4、将编译好的二进制,使用 tar 方式进行打包,并且打包路径需要是 `usr/local/bin`
32+
33+
```bash
34+
cd ${MOSN Project Path}
35+
mkdir -p usr/local/bin
36+
make build # build mosn binary on linux
37+
cp build/bundles/${MOSN VERSION}/binary/mosn usr/local/bin
38+
tar -zcvf mosn.tar.gz usr/local/bin/mosn
39+
cp mosn.tar.gz mosn-centos.tar.gz # copy a renamed tar.gz file
40+
41+
make build-local # build mosn binary on macos
42+
cp build/bundles/${MOSN VERSION}/binary/mosn usr/local/bin
43+
tar -zcvf mosn-macos.tar.gz usr/local/bin/mosn
44+
```
45+
46+
5、将生成的`mosn-macos.tar.gz` `mosn-centos.tar.gz` `mosn.tar.gz` 上传到一个编译环境可访问的存储服务中,可用 Go 语言简单快速在本地环境搭建一个
47+
48+
```Go
49+
func main() {
50+
address := "" // an address can be reached when proxyv2 image build. for example, 0.0.0.0:8080
51+
filespath := "" // where the .tar.gz files stored.
52+
http.ListenAndServe(address, http.FileServer(http.Dir(filespath)))
53+
}
54+
```
55+
56+
6、指定参数,开始编译 proxyv2 镜像
57+
58+
```bash
59+
address=$1 # your download service address
60+
export ISTIO_ENVOY_VERSION=$2 # MOSN Version, can be any value.
61+
export ISTIO_ENVOY_RELEASE_URL=http://$address/mosn.tar.gz
62+
export ISTIO_ENVOY_CENTOS_RELEASE_URL=http://$address/mosn-centos.tar.gz
63+
export ISTIO_ENVOY_MACOS_RELEASE_URL=http://$address/mosn-macos.tar.gz
64+
export ISTIO_ENVOY_MACOS_RELEASE_NAME=mosn-$2 # can be any value
65+
export SIDECAR=mosn
66+
67+
make clean # clean the cache
68+
make docker.proxyv2 \
69+
SIDECAR=$SIDECAR \
70+
ISTIO_ENVOY_VERSION=$ISTIO_ENVOY_VERSION \
71+
ISTIO_ENVOY_RELEASE_URL=$ISTIO_ENVOY_RELEASE_URL \
72+
ISTIO_ENVOY_CENTOS_RELEASE_URL=$ISTIO_ENVOY_CENTOS_RELEASE_URL \
73+
ISTIO_ENVOY_MACOS_RELEASE_URL=$ISTIO_ENVOY_MACOS_RELEASE_URL \
74+
ISTIO_ENVOY_MACOS_RELEASE_NAME=$ISTIO_ENVOY_MACOS_RELEASE_NAME
75+
```
76+
77+
7、编译完成以后,可以将镜像打上新的 Tag 并且上传(如个人测试 dockerhub 的地址),确保 istio 使用时可访问即可
78+
79+
80+
单独更新 MOSN 版本
81+
==========
82+
83+
84+
1、重新编译 MOSN 二进制
85+
86+
```bash
87+
cd ${MOSN Project Path}
88+
make build # build mosn binary on linux
89+
```
90+
91+
2、直接基于现有 MOSN 的 proxyv2 镜像更新二进制
92+
93+
```Dockerfile
94+
FROM mosnio/proxyv2:v1.0.0-1.10.6
95+
COPY build/bundles/${MOSN VERSION}/binary/mosn /usr/local/bin/mosn
96+
```
97+
98+
```bash
99+
docker build --no-cache --rm -t ${your image tag}
100+
```
101+
102+
3、将新镜像上传,确保 istio 使用时可访问即可
103+
104+
```bash
105+
istioctl manifest apply --set .values.global.proxy.image=${MOSN IMAGE} --set meshConfig.defaultConfig.binaryPath="/usr/local/bin/mosn"
106+
```

content/zh/docs/user-guide/start/istio/_index.md

Lines changed: 54 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ MOSN 从 v1.0.0 版本开始 已通过 Istio 1.10.6 的 `Bookinfo` 测试,关
1515
本文介绍的内容将包括 :
1616

1717
- MOSN 与 Istio 的关系
18-
- MOSN 与 Istio 的 proxyv2 镜像 build 方法
1918
- 部署 Istio 与 MOSN
2019
- Bookinfo 实验
2120

@@ -27,138 +26,98 @@ MOSN 从 v1.0.0 版本开始 已通过 Istio 1.10.6 的 `Bookinfo` 测试,关
2726

2827
<div align=center><img src="mosn-with-service-mesh.svg" width = "450" height = "400" alt="MOSN 介绍" /></div>
2928

30-
## MOSN 与 Istio 的 proxyv2 镜像 build 方法
3129

32-
本文的完整构建镜像方法均是基于 MacOS 和 Istio 1.10.6 版本进行的构建,在其他操作系统 Istio 版本上可能存在部分细节差异,需要进行调整。
33-
除了完整构建方式外,如果仅有 MOSN 代码发生变化,还可以使用仅更新 MOSN 的方式构建镜像。
34-
通常情况下,您不需要额外构建镜像,可直接用我们提供的镜像 `mosnio/proxyv2:${MOSN-VERSION}-${ISTIO_VERSION}`,如`docker pull mosnio/proxyv2:v1.0.0-1.10.6`
30+
## 部署 Istio 与 MOSN
31+
注意:Istio 1.10.6 不支持在 arm64 上运行 Kubernetes 的集群 。 [Istio Issues]([(https://github.com/istio/istio/issues/32841)])
3532

36-
完整的镜像构建(基于 MacOS 和 Istio 1.10.6)
37-
==========
38-
1、下载完整的 istio 源代码,并且切换到对应的版本
33+
### 安装 kubectl 命令行工具
3934

40-
```
41-
git clone [email protected]:istio/istio.git
42-
cd istio
43-
git checkout 1.10.6
44-
```
35+
kubectl 是用于针对 Kubernetes 集群运行命令的命令行接口,安装参考 [kubectl doc](https://kubernetes.io/docs/tasks/tools/install-kubectl)
4536

46-
2、由于目前 Istio 默认会加载 wasm,我们需要将相关逻辑注释掉,再重新编译镜像,避免一些不必要的错误。详细的改动可见 [istio-diff](./istio-diff)
37+
### 安装 Kubernetes 平台
4738

48-
3、编译 MOSN 二进制,MOSN 提供了镜像编译的方式可直接编译 linux 的二进制;同时由于在 MacOS 上构建的过程中,Istio 还会下载一个 MacOS 版本,因此还需要编译一个 MacOS 的二进制
39+
安装 Istio,首先需要根据实际需求选择安装平台,可参考 Istio 官方文档推荐的方式 [Platform Setup](https://istio.io/latest/docs/setup/platform-setup/)
40+
后文中,我们假定选择的是`minikube`的安装方式,方便进行介绍。
4941

50-
4、将编译好的二进制,使用 tar 方式进行打包,并且打包路径需要是`usr/local/bin`
42+
安装minikube 流程:
43+
44+
1、根据本机环境选择下载地址 [Minikube 官网](https://minikube.sigs.k8s.io/docs/start/),下面用的系统是`macOS x86`系统。
5145

5246
```bash
53-
cd ${MOSN Project Path}
54-
mkdir -p usr/local/bin
55-
make build # build mosn binary on linux
56-
cp build/bundles/${MOSN VERSION}/binary/mosn usr/local/bin
57-
tar -zcvf mosn.tar.gz usr/local/bin/mosn
58-
cp mosn.tar.gz mosn-centos.tar.gz # copy a renamed tar.gz file
59-
60-
make build-local # build mosn binary on macos
61-
cp build/bundles/${MOSN VERSION}/binary/mosn usr/local/bin
62-
tar -zcvf mosn-macos.tar.gz usr/local/bin/mosn
47+
$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64
48+
$ sudo install minikube-darwin-amd64 /usr/local/bin/minikube
6349
```
6450

65-
5、将生成的`mosn-macos.tar.gz` `mosn-centos.tar.gz` `mosn.tar.gz` 上传到一个编译环境可访问的存储服务中,可用 Go 语言简单快速在本地环境搭建一个
66-
67-
```Go
68-
func main() {
69-
address := "" // an address can be reached when proxyv2 image build. for example, 0.0.0.0:8080
70-
filespath := "" // where the .tar.gz files stored.
71-
http.ListenAndServe(address, http.FileServer(http.Dir(filespath)))
72-
}
51+
2、启动 minikube
52+
```bash
53+
$ minikube start --memory=7851 --cpus=4 --image-mirror-country='cn'
7354
```
55+
注意:内存必须大于4GB,且镜像为`cn`(国内)
7456

75-
6、指定参数,开始编译 proxyv2 镜像
57+
3、安装成功后,查看Pod情况
7658

7759
```bash
78-
address=$1 # your download service address
79-
export ISTIO_ENVOY_VERSION=$2 # MOSN Version, can be any value.
80-
export ISTIO_ENVOY_RELEASE_URL=http://$address/mosn.tar.gz
81-
export ISTIO_ENVOY_CENTOS_RELEASE_URL=http://$address/mosn-centos.tar.gz
82-
export ISTIO_ENVOY_MACOS_RELEASE_URL=http://$address/mosn-macos.tar.gz
83-
export ISTIO_ENVOY_MACOS_RELEASE_NAME=mosn-$2 # can be any value
84-
export SIDECAR=mosn
85-
86-
make clean # clean the cache
87-
make docker.proxyv2 \
88-
SIDECAR=$SIDECAR \
89-
ISTIO_ENVOY_VERSION=$ISTIO_ENVOY_VERSION \
90-
ISTIO_ENVOY_RELEASE_URL=$ISTIO_ENVOY_RELEASE_URL \
91-
ISTIO_ENVOY_CENTOS_RELEASE_URL=$ISTIO_ENVOY_CENTOS_RELEASE_URL \
92-
ISTIO_ENVOY_MACOS_RELEASE_URL=$ISTIO_ENVOY_MACOS_RELEASE_URL \
93-
ISTIO_ENVOY_MACOS_RELEASE_NAME=$ISTIO_ENVOY_MACOS_RELEASE_NAME
60+
$ minikube kubectl -- get pods -A
61+
NAMESPACE NAME READY STATUS RESTARTS AGE
62+
kube-system coredns-64897985d-vw7b8 1/1 Running 2 (16h ago) 7d20h
63+
kube-system etcd-minikube 1/1 Running 2 (16h ago) 7d20h
64+
kube-system kube-apiserver-minikube 1/1 Running 2 (16h ago) 7d20h
65+
kube-system kube-controller-manager-minikube 1/1 Running 2 (16h ago) 7d20h
66+
kube-system kube-proxy-cmjcq 1/1 Running 2 (16h ago) 7d20h
67+
kube-system kube-scheduler-minikube 1/1 Running 2 (16h ago) 7d20h
68+
kube-system storage-provisioner 1/1 Running 5 (16h ago) 7d20h
9469
```
9570

96-
7、编译完成以后,可以将镜像打上新的 Tag 并且上传(如个人测试 dockerhub 的地址),确保 istio 使用时可访问即可
97-
98-
99-
单独更新 MOSN 版本
100-
==========
101-
71+
### 安装 Istio,使用 MOSN 作为数据面
10272

103-
1、重新编译 MOSN 二进制
73+
1、下载对应的 Istio Release 版本,可以在 [Istio release](https://github.com/istio/istio/releases/tag/1.10.6) 页面下载与您操作系统匹配的压缩文件,或者使用官方提供的下载方式
10474

10575
```bash
106-
cd ${MOSN Project Path}
107-
make build # build mosn binary on linux
76+
VERSION=1.10.6 # istio version
77+
export ISTIO_VERSION=$VERSION && curl -L https://istio.io/downloadIstio | sh -
10878
```
109-
2、直接基于现有 MOSN 的 proxyv2 镜像更新二进制
11079

111-
```Dockerfile
112-
FROM mosnio/proxyv2:v1.0.0-1.10.6
113-
COPY build/bundles/${MOSN VERSION}/binary/mosn /usr/local/bin/mosn
114-
```
80+
2、下载完成以后(或者解压完成),切换到对应的目录,同时可以设置对应的 `istioctl` 命令行工具到环境变量,方便配置自定义 Istio 控制平面和数据平面配置参数。
11581

11682
```bash
117-
docker build --no-cache --rm -t ${your image tag}
83+
$ cd istio-$ISTIO_VERSION/
84+
$ export PATH=$PATH:$(pwd)/bin
11885
```
11986

120-
3、将新镜像上传,确保 istio 使用时可访问即可
87+
3、执行默认安装 ```istioctl install```
12188

89+
```bash
90+
$ istioctl install
12291

123-
## 部署 Istio 与 MOSN
124-
125-
### 安装 kubectl 命令行工具
126-
127-
kubectl 是用于针对 Kubernetes 集群运行命令的命令行接口,安装参考 [kubectl doc](https://kubernetes.io/docs/tasks/tools/install-kubectl)
128-
129-
### 安装 Kubernetes 平台
130-
131-
安装 Istio,首先需要根据实际需求选择安装平台,可参考 Istio 官方文档推荐的方式 [Platform Setup](https://istio.io/latest/docs/setup/platform-setup/)
132-
后文中,我们假定选择的是`minikube`的安装方式,方便进行介绍。
133-
134-
### 安装 Istio,使用 MOSN 作为数据面
92+
This will install the Istio 1.14.1 default profile with ["Istio core" "Istiod" "Ingress gateways"] components into the cluster. Proceed? (y/N) y
93+
✔ Istio core installed
94+
✔ Istiod installed
95+
✔ Ingress gateways installed
96+
✔ Installation complete
97+
Making this installation the default for injection and validation.
13598

136-
1、下载对应的 Istio Release 版本,可以在 [Istio release](https://github.com/istio/istio/releases/tag/1.10.6) 页面下载与您操作系统匹配的压缩文件,或者使用官方提供的下载方式
137-
138-
```bash
139-
VERSION=1.10.6 # istio version
140-
export ISTIO_VERSION=$VERSION && curl -L https://istio.io/downloadIstio | sh -
99+
Thank you for installing Istio 1.14. Please take a few minutes to tell us about your install/upgrade experience! https://forms.gle/yEtCbt45FZ3VoDT5A
141100
```
142101

143-
2、下载完成以后(或者解压完成),切换到对应的目录,同时可以设置对应的`istioctl`命令行工具到环境变量,方便配置自定义 Istio 控制平面和数据平面配置参数。
102+
4、创建 istio 命名空间,并且设置 MOSN proxyv2 镜像为数据面镜像
103+
104+
下载 MOSN proxyv2 的镜像,并设置其为 Istio 的 proxy 镜像。
105+
`--set .values.global.proxy.image=${MOSN IMAGE}`
106+
也可以通过手动去创建 proxy 镜像 ([MOSN 与 Istio 的 proxyv2 镜像 build 方法介绍](../images))。
107+
以下将使用我们提供的镜像版本 `mosnio/proxyv2:v1.0.0-1.10.6`
144108

145109
```bash
146-
cd istio-$ISTIO_VERSION/
147-
export PATH=$PATH:$(pwd)/bin
110+
$ kubectl create namespace istio-system
111+
$ istioctl manifest apply --set .values.global.proxy.image= mosnio/proxyv2:v1.0.0-1.10.6 --set meshConfig.defaultConfig.binaryPath="/usr/local/bin/mosn"
148112
```
149113

150-
3、创建 istio 命名空间,并且设置 MOSN proxyv2 镜像为数据面镜像
114+
注意:当你失败时,可以通过 ```minikube ssh``` 进入虚机所构建的集群内部,并通过 ```docker pull mosnio/proxyv2:v1.0.0-1.10.6 ``` 来获取镜像
151115

152-
```bash
153-
kubectl create namespace istio-system
154-
istioctl manifest apply --set .values.global.proxy.image=${MOSN IMAGE} --set meshConfig.defaultConfig.binaryPath="/usr/local/bin/mosn"
155-
```
156116

157-
4、验证 Istio 相关 POD 服务是否部署成功
117+
5、验证 Istio 相关 POD 服务是否部署成功
158118

159119
```bash
160-
kubectl get pod -n istio-system
161-
120+
$ kubectl get pod -n istio-system
162121
NAME READY STATUS RESTARTS AGE
163122
istio-ingressgateway-6b7fb88874-rgmrj 1/1 Running 0 102s
164123
istiod-65c9767c55-vjppv 1/1 Running 0 109s

0 commit comments

Comments
 (0)