Rancher arm64环境编译

Rancher arm64环境编译

一、go开发环境安装

  1. 下载golang安装包、并解压
wget https://studygolang.com/dl/golang/go1.13.3.linux-arm64.tar.gz
tar -C /usr/local -xzf go1.13.3.linux-arm64.tar.gz
  1. 配置环境变量
echo "export GOROOT=/usr/local/go" >> /etc/profile
echo "export PATH=$PATH:$GOROOT/bin" >> /etc/profile
  1. 设置 GOPATH 编译目录,需要编译的项目都应该放到该目录
mkdir -p /test
echo "export GOPATH=/test" >> /etc/profile

4.生效环境配置

source /etc/profile

5.验证go环境是否生效

go version
go env

二、Rancher编译

  1. 获取代码
#以防万一重新设置一次gopath路径
export GOPATH=/test
mkdir -p $GOPATH/src/github.com/rancher/
cd $GOPATH/src/github.com/rancher/
git clone https://github.com/rancher/rancher
cd rancher
  1. 做适当修改
#检出最新的tag版本
git checkout v2.3.1

修改对应 version
vim scripts/version

#!/bin/bash
shopt -s extglob

if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
    DIRTY="-dirty"
fi

COMMIT=$(git rev-parse --short HEAD)
COMMIT_DATE=$(git --no-pager log -1 --format='%ct')
COMMIT_BRANCH=$(git rev-parse --abbrev-ref HEAD | sed -E 's/[^a-zA-Z0-9]+/-/g')
GIT_TAG=${DRONE_TAG:-$(git tag -l --contains HEAD | head -n 1)}
LAST_TAG=${GIT_TAG:-'v0.0.0'}

if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
    VERSION=$GIT_TAG
else
    VERSION=$GIT_TAG
fi

# Chart tag.
if [[ -z "${DIRTY}" && -n "${GIT_TAG}" ]]; then
    CHART_VERSION="${GIT_TAG}"
elif [[ "$DIRTY" ]]; then
    CHART_VERSION="${GIT_TAG}"
else
    CHART_VERSION="${GIT_TAG}"
fi

# Drop the v prefix for Chart Version to follow existing pattern.
CHART_VERSION="$(echo ${CHART_VERSION} | sed -E 's/^v//' | sed -e 's/^\(.\{55\}\).*/\1/')"

# Chart Repo - Target Repo for releases.
case $CHART_VERSION in
    *-alpha*) # All alpha tags
        CHART_REPO="alpha" ;;
    *-rc*) # All rc tags
        CHART_REPO="latest" ;;
    +([0-9]).+([0-9]).+([0-9])) # All release tags
        CHART_REPO="latest" ;;
    *) # Anything else - Future use
        CHART_REPO="dev" ;;
esac

if [ -z "$ARCH" ]; then
    ARCH=arm64
fi

echo "ARCH: $ARCH"
echo "CHART_REPO: $CHART_REPO"
echo "CHART_VERSION: $CHART_VERSION"
echo "VERSION: $VERSION"
  1. 编译
    ./scripts/build
  2. 验证二进制包
ls bin/
bin/rancher -h
bin/agent -h
  1. 打包
    打包需要为镜像Dockerfile做一些必要的修改
    mkdir dist
    由于不可描述的网络问题,因此加入必要的http和https的proxy。
sed -i '1a ARG https_proxy=http://xxx.xxx.xxx.xxx:xxxxx' package/Dockerfile
sed -i '1a ARG http_proxy=http://xxx.xxx.xxx.xxx:xxxxx' package/Dockerfile
sed -i '1a ARG https_proxy=http://xxx.xxx.xxx.xxx:xxxxx' package/Dockerfile.agent
sed -i '1a ARG http_proxy=http://xxx.xxx.xxx.xxx:xxxxx' package/Dockerfile.agent

#开始执行
./scripts/package
  1. 查看docker镜像
    docker ps
  2. 运行rancher
docker run -d \
	--restart=unless-stopped \
	--name rancherdev \
	-p 10080:80 -p 10443:443 \
	-v /rancherdev:/var/lib/rancher/ \
	-e AUDIT_LEVEL=3 \
	rancher/rancher:v2.3.1_arm64
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值