安装golang
yum install -y golang
修改/etc/profile,创建环境变量GOPATH
echo 'export GOPATH="/home/rancher/go" ' >> /etc/profile
source /etc/profile
获取代码切换到对应版本
mkdir -p $GOPATH/src/github.com/rancher
cd $GOPATH/src/github.com/rancher
git clone https://github.com/rancher/rancher.git
cd rancher
git checkout v2.2.3-rc9
编译
cd $GOPATH/src/github.com/rancher/rancher
./scripts/build
打成docker image
./scripts/package
打包镜像的过程中会报错,由于
curl -sLf https://storage.googleapis.com/kubernetes-release/release/v1.12.7/bin/linux/${ARCH}/kubectl > /usr/bin/kubectl
需要访问google的服务器,因为特定原因,会访问失败
所以先要手动下载https://storage.googleapis.com/kubernetes-release/release/v1.12.7/bin/linux/amd64/kubectl这个文件,在把它放到本地的apache的/var/www/html/v1.12.7/目录下,将package/Dockerfile.agent中的 https://storage.googleapis.com/kubernetes-release/release/v1.12.7/bin/linux/${ARCH}/kubectl改为http://localhost/v1.12.7/kubectl
再重新编译即可生成docker镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
rancher/rancher-agent dev 076d4c7483ec 8 minutes ago 289.8 MB
rancher/rancher dev 966385b1a912 27 minutes ago 477.1 MB