1

编译了一个arm的kustomize

 2 years ago
source link: https://www.bboy.app/2022/01/14/%E7%BC%96%E8%AF%91%E4%BA%86%E4%B8%80%E4%B8%AAarm%E7%9A%84kustomize/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

编译了一个arm的kustomize

发表于 2022-01-14

更新于 2022-01-27

分类于

kubernetes

20220114-1.png

貌似kustomize是没有arm版本的,我说的是32位的,所以那就自己编译一个吧

首先clone仓库

git clone https://github.com/bboysoulcn/kustomize.git

之后看到了他的dockerfile

# build
FROM golang:alpine as builder
ARG VERSION
ARG COMMIT
ARG DATE
RUN mkdir /build
ADD . /build/
WORKDIR /build/kustomize
RUN CGO_ENABLED=0 GO111MODULE=on go build \
-ldflags="-s -X sigs.k8s.io/kustomize/api/provenance.version=${VERSION} \
-X sigs.k8s.io/kustomize/api/provenance.gitCommit=${COMMIT} \
-X sigs.k8s.io/kustomize/api/provenance.buildDate=${DATE}"

# only copy binary
FROM alpine
# install dependencies
RUN apk add --no-cache git openssh
COPY --from=builder /build/kustomize/kustomize /app/
WORKDIR /app
ENV PATH "$PATH:/app"
ENTRYPOINT ["/app/kustomize"]

也就是编译的话就是下面这个命令

CGO_ENABLED=0 GO111MODULE=on go build \
-ldflags="-s -X sigs.k8s.io/kustomize/api/provenance.version=${VERSION} \
-X sigs.k8s.io/kustomize/api/provenance.gitCommit=${COMMIT} \
-X sigs.k8s.io/kustomize/api/provenance.buildDate=${DATE}"

在此之前需要找到这三个变量${VERSION},${COMMIT},${DATE}

找了一下,在

releasing/cloudbuild_kustomize_image.yaml

下面有编译的脚本,主要是下面几行

args:
- -c
- >
docker
build
-t
gcr.io/$PROJECT_ID/kustomize:${_GIT_TAG}
-t
gcr.io/$PROJECT_ID/kustomize:latest
-f
kustomize.Dockerfile
--build-arg
VERSION=${_PULL_BASE_REF}
--build-arg
COMMIT=$(git rev-parse HEAD)
--build-arg
DATE=$(date -u +%FT%TZ)
.

VERSION=${_PULL_BASE_REF}

COMMIT=$(git rev-parse HEAD)

DATE=$(date -u +%FT%TZ)

那么编译的命令就如下

CGO_ENABLED=0 GO111MODULE=on go build \
-ldflags="-s -X sigs.k8s.io/kustomize/api/provenance.version=v3.3.1 \
-X sigs.k8s.io/kustomize/api/provenance.gitCommit=91284782c4f11114362fcd94f6b0ad7eed2bfd8f \
-X sigs.k8s.io/kustomize/api/provenance.buildDate=2022-01-13T05:57:00Z"

树莓派上跑一个容器作为我们的编译环境

docker run -itd -v /data/trash/kustomize:/app golang:alpine sh

进入kustomize这个目录运行编译的命令就好了

欢迎关注我的博客www.bboy.app

Have Fun


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK