惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

www.infosecurity-magazine.com
www.infosecurity-magazine.com
Security Archives - TechRepublic
Security Archives - TechRepublic
TaoSecurity Blog
TaoSecurity Blog
Cloudbric
Cloudbric
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
N
News and Events Feed by Topic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Securelist
The Cloudflare Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
S
Schneier on Security
L
LangChain Blog
Jina AI
Jina AI
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements
T
Tenable Blog
B
Blog RSS Feed
V
Visual Studio Blog
Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
T
The Exploit Database - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
WordPress大学
WordPress大学
W
WeLiveSecurity
I
InfoQ
The Hacker News
The Hacker News
雷峰网
雷峰网
月光博客
月光博客
P
Privacy & Cybersecurity Law Blog
O
OpenAI News
Hacker News: Ask HN
Hacker News: Ask HN
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
The Last Watchdog
The Last Watchdog
P
Privacy International News Feed
Cyberwarzone
Cyberwarzone
S
SegmentFault 最新的问题
L
Lohrmann on Cybersecurity
人人都是产品经理
人人都是产品经理
V
V2EX
V
Vulnerabilities – Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
Cybersecurity and Infrastructure Security Agency CISA
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Troy Hunt's Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
阮一峰的网络日志
阮一峰的网络日志
SecWiki News
SecWiki News
Microsoft Azure Blog
Microsoft Azure Blog

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19) 使用 Velero 备份 Kubernetes 集群 Kubernetes Cheat Sheet 开发 Tips(18) 如何构建一个 Java 工程 开发 Tips(17) KubeSpray 安装 Kubernetes 报错 ip in ansible_all_ipv4_addresses 基于 Kubernetes 和 Jenkins 搭建自动化测试系统 在 Kubernetes 上动态创建 Jenkins Slave 使用 Jenkins 进行服务拨测 开发 Tips(16) Kubernetes 签发 Ingress 证书及日常故障运维 Kubernetes 中 Deployment 的基本操作 Kubernetes 中的证书 如何使用 KubeBuilder 开发一个 Operator Kubernetes 1.6.0 安装问题汇总 镜像管理工具 -- Harbor 开发 Tips(15) Docker 如何拉取镜像 开发 Tips(14) 使用 Helm 安装 harbor 开发 Tips(13) 使用 S2I 构建云原生应用 在 Kubernetes 中使用 emptyDir、hostPath、localVolume 开发 Tips(12) 开发 Tips(11) 代码质量分析工具 SonarQube 使用 Kubeadm 安装 Kubernetes 集群 一起来学 Go --(4)常用函数 Kubernetes 中的 Ceph Kubernetes 之 Volumes Kubernetes 之 Labels、Selectors 开发 Tips(10) 开源正在重构商业模式 Kubernetes 之网络 Kubernetes 之 API 使用 Helm 和 Operator 快速部署 Prometheus Kubernetes 复杂有状态应用管理框架 -- Operator Kubernetes 的包管理器 -- Helm 一起来学 Go --(3)Go Modules 如何一步一步地优化博客方案 kubectl 实用指南 Kubernetes 中的基本概念 搭建远程 Kubernetes 开发环境 大公司和小公司的 ToB 思路 开发 Tips(9) Go 入门指南 一起来学 Go --(2)数据与逻辑结构 如何预防 Web 富文本中的 XSS 攻击 django-xss-cleaner 云工作时代 一起来学 Go --(1)背景与特点 SaaS 开发团队的不同阶段 你不知道的 Git 使用技巧 输出既服务 微服务设计 继续奔跑 开发 Tips(8) 从账户安全到二次验证 Django 性能之数据库查询优化 Django 性能之分库分表 敏捷开发之研发流程 打造一致性的团队 开发 Tips(7) Pytest 进阶学习之 Mock PaaS 部署之 buildpack Go 开发配置 领域输出才是 PaaS 的核心竞争力 Pytest 入门学习 开发 Tips(6) 如何使用 Jenkins、Docker、GitLab 搭建 Django 自动化部署流程
如何在 CentOS 8 下编译 istio 项目
微信公众号 · 2021-04-08 · via 陈少文的网站

Please enable Javascript to view the contents

本文主要描述在 CentOS 8.2 下,如何使用本地工具编译 https://github.com/istio/istio 项目。另外一种方法是通过 BUILD_WITH_CONTAINER 参数控制,使用容器编译,仅依赖于 make 和 docker。

1. 安装并升级 Ruby >= 2.6

  • 安装 Ruby
  • 查看 Ruby 版本
1
2
3
ruby -v

ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
  • 安装 RVM
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
  • 安装 Ruby 2.6
  • 查看 Ruby 版本
1
2
3
ruby -v

ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]

2. 安装 FPM

FPM 是一个打包工具, 能将源码打包成 rpm、deb、pkg 等格式的包。istio 目前使用的就是 FPM 。

  • 安装依赖
1
yum install -y ruby-devel gcc make rpm-build rubygems
  • 安装 FPM
1
gem install --no-document fpm

3. 安装并升级 Go >= 1.16

  • 安装 Go
  • 查看 Go 版本
1
2
3
go version

go version go1.14.12 linux/amd64
  • 低版本 Go 编译会报错
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

可查看 go.mod 文件检查 istio 对 Go 版本的要求。

  • 安装 gvm
1
2
yum install -y git
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

重新打开 Terminal 或者执行一下提示命令将 gvm 添加到 PATH 中。

  • 查看可选的 Go 版本
1
2
3
4
gvm listall

...
go1.16.3
  • 安装 Go
  • 设置版本
1
gvm use go1.16.3 --default
  • 查看版本
1
2
3
go version

go version go1.16.3 linux/amd64

4. 安装 Docker

  • 添加 Docker 源
1
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
  • 安装 Docker
1
dnf install docker-ce --nobest -y
  • 启动 Docker
1
2
systemctl enable docker
systemctl start docker

5. 编译 istio

  • 安装依赖
1
yum install -y make vim
  • 克隆代码

这里指定一个固定的版本,方便复现,也可以直接使用 master 分支。

1
2
git clone https://github.com/istio/istio.git -b release-1.10
cd istio
  • 修改 Makefile 文件屏蔽 BUILD_WITH_CONTAINER=1 等参数
vim Makefile

# -include Makefile.overrides.mk

如果不想修改 Makefile 文件,也可以在每条 make 命令前加上 BUILD_WITH_CONTAINER=0 不使用容器进行构建。

否则,默认会使用容器环境进行构建。

  • [可选]定制参数

这一步主要用于设置镜像的格式,默认是 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
  • 编译某个组件及其镜像

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

下面以 istioctl 为例:

  • 查看编译结果
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
  • 推送镜像到 DockerHub

推送之前需要登陆 DockerHub。

1
make push.docker.istioctl

6. 总结

建议使用 CentOS 8 进行编译,因为 CentOS 7.6 下编译 app_sidecar_centos 镜像时会卡主,下面是截取的日志。

 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

经过上面一系列操作之后 Docker 也假死,具体原因有待排查。

CentOS 8 使用 Podman 替代了 Docker CLI ,GLIBC 也不用升级,很容易编译成功。

7. 参考


微信公众号