kt-connect arm64镜像制作
拉取代码:
#git clone https://github.com/alibaba/kt-connect.git
unzip kt-connect-0.3.7.zip
cd kt-connect
makefile:
# build this image before shadow
shadow-base:
docker build -t $(PREFIX)/$(SHADOW_BASE_IMAGE):$(TAG) -f build/docker/shadow/Dockerfile_base .
# build shadow image
shadow:
GOARCH=arm64 GOOS=linux go build -gcflags "all=-N -l" -o artifacts/shadow/shadow-linux-arm64 cmd/shadow/main.go
docker build -t $(PREFIX)/$(SHADOW_IMAGE):$(TAG) -f build/docker/shadow/Dockerfile .
dockerfile: xlong9527/shadow-base:0.3.7
# cat build/docker/shadow/Dockerfile_base
FROM ubuntu:22.04
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
apt-get update && \
apt-get install -y openssh-server dnsutils iputils-ping net-tools iproute2 curl lsof && \
rm -rf /var/lib/apt/lists/* && \
mkdir /var/run/sshd && \
# SSH login fix. Otherwise user is kicked off after login
sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
COPY build/docker/shadow/sshd_config /etc/ssh/sshd_config
RUN chmod +rw /etc/ssh/sshd_config
EXPOSE 22
dockerfile: xlong9527/kt-connect-shadow:0.3.7
# cat build/docker/shadow/Dockerfile
FROM xlong9527/shadow-base:0.3.7
COPY artifacts/shadow/shadow-linux-arm64 /usr/sbin/shadow
COPY build/docker/shadow/run.sh /run.sh
COPY build/docker/shadow/disconnect.sh /disconnect.sh
RUN chmod 755 /disconnect.sh && \
chmod 755 /run.sh
ENTRYPOINT ["/run.sh"]
build:
#修改Makefile
vim Makefile
PREFIX ?= xlong9527
TAG ?= 0.3.7
sed -i 's#amd64#arm64#g' Makefile build/docker/shadow/Dockerfile
# 查看golang版本
cat go.mod
docker pull golang:1.18.10
docker run -itd --name kt-connect-build \
-v /root/kt-connect-0.3.7:/data \
-v /usr/bin/docker:/usr/bin/docker \
-v /var/run/docker.sock:/var/run/docker.sock \
golang:1.18.10 bash
docker exec -it kt-connect-build bash
export TAG=0.3.7
export GOARCH=arm64
export GOOS=linux
go env -w GOPROXY=https://goproxy.cn,direct
go mod download
#编译基础镜像
TAG=0.3.7 make shadow-base
#编译shadow镜像
TAG=0.3.7 make shadow
本地启动:
ktctl -n default -c config-wes connect --image=xlong9527/kt-connect-shadow:0.3.7 --nodeSelector=kubernetes.io/hostname=master01
清理资源:
ktctl -n default -c config-wes clean --image=xlong9527/kt-connect-shadow:0.3.7 --nodeSelector=kubernetes.io/hostname=master01
评论区