mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-08-19 04:06:24 +00:00
Merge pull request #684 from acumino/multi-arch-image
Create multi-arch image
This commit is contained in:
+19
-3
@@ -11,6 +11,22 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
ARG BASEIMAGE
|
||||
|
||||
FROM golang:1.17.7 as builder
|
||||
LABEL maintainer="Andy Xie <andy.xning@gmail.com>"
|
||||
|
||||
ENV GOPATH /gopath/
|
||||
ENV PATH $GOPATH/bin:$PATH
|
||||
|
||||
RUN apt-get update && apt-get --yes install libsystemd-dev
|
||||
RUN go version
|
||||
RUN go get github.com/tools/godep
|
||||
RUN godep version
|
||||
|
||||
COPY . /gopath/src/k8s.io/node-problem-detector/
|
||||
WORKDIR /gopath/src/k8s.io/node-problem-detector
|
||||
RUN make bin/node-problem-detector bin/health-checker bin/log-counter
|
||||
|
||||
ARG BASEIMAGE
|
||||
FROM ${BASEIMAGE}
|
||||
@@ -22,10 +38,10 @@ RUN clean-install util-linux libsystemd0 bash systemd
|
||||
# Avoid symlink of /etc/localtime.
|
||||
RUN test -h /etc/localtime && rm -f /etc/localtime && cp /usr/share/zoneinfo/UTC /etc/localtime || true
|
||||
|
||||
COPY ./bin/node-problem-detector /node-problem-detector
|
||||
COPY --from=builder /gopath/src/k8s.io/node-problem-detector/bin/node-problem-detector /node-problem-detector
|
||||
|
||||
ARG LOGCOUNTER
|
||||
COPY ./bin/health-checker ${LOGCOUNTER} /home/kubernetes/bin/
|
||||
COPY --from=builder /gopath/src/k8s.io/node-problem-detector/bin/health-checker /gopath/src/k8s.io/node-problem-detector/${LOGCOUNTER} /home/kubernetes/bin/
|
||||
|
||||
COPY config /config
|
||||
COPY --from=builder /gopath/src/k8s.io/node-problem-detector/config/ /config
|
||||
ENTRYPOINT ["/node-problem-detector", "--config.system-log-monitor=/config/kernel-monitor.json"]
|
||||
|
||||
@@ -23,6 +23,7 @@ all: build
|
||||
|
||||
# PLATFORMS is the set of OS_ARCH that NPD can build against.
|
||||
LINUX_PLATFORMS=linux_amd64 linux_arm64
|
||||
DOCKER_PLATFORMS=linux/amd64,linux/arm64
|
||||
PLATFORMS=$(LINUX_PLATFORMS) windows_amd64
|
||||
|
||||
# VERSION is the version of the binary.
|
||||
@@ -74,7 +75,7 @@ endif
|
||||
# The debian-base:v1.0.0 image built from kubernetes repository is based on
|
||||
# Debian Stretch. It includes systemd 232 with support for both +XZ and +LZ4
|
||||
# compression. +LZ4 is needed on some os distros such as COS.
|
||||
BASEIMAGE:=k8s.gcr.io/debian-base-amd64:v2.0.0
|
||||
BASEIMAGE:=k8s.gcr.io/debian-base:v2.0.0
|
||||
|
||||
# Disable cgo by default to make the binary statically linked.
|
||||
CGO_ENABLED:=0
|
||||
@@ -239,8 +240,9 @@ $(NPD_NAME_VERSION)-%.tar.gz: $(ALL_BINARIES) test/e2e-install.sh
|
||||
|
||||
build-binaries: $(ALL_BINARIES)
|
||||
|
||||
build-container: build-binaries Dockerfile
|
||||
docker build -t $(IMAGE) --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg LOGCOUNTER=$(LOGCOUNTER) .
|
||||
build-container: clean Dockerfile
|
||||
docker buildx create --use
|
||||
docker buildx build --platform $(DOCKER_PLATFORMS) -t $(IMAGE) --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg LOGCOUNTER=$(LOGCOUNTER) .
|
||||
|
||||
$(TARBALL): ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker ./test/bin/problem-maker
|
||||
tar -zcvf $(TARBALL) bin/ config/ test/e2e-install.sh test/bin/problem-maker
|
||||
@@ -252,7 +254,7 @@ build-tar: $(TARBALL) $(ALL_TARBALLS)
|
||||
build: build-container build-tar
|
||||
|
||||
docker-builder:
|
||||
docker build -t npd-builder ./builder
|
||||
docker build -t npd-builder . --target=builder
|
||||
|
||||
build-in-docker: clean docker-builder
|
||||
docker run \
|
||||
@@ -260,8 +262,13 @@ build-in-docker: clean docker-builder
|
||||
-c 'cd /gopath/src/k8s.io/node-problem-detector/ && make build-binaries'
|
||||
|
||||
push-container: build-container
|
||||
# So we can push to docker hub by setting REGISTRY
|
||||
ifneq (,$(findstring gcr.io,$(REGISTRY)))
|
||||
gcloud auth configure-docker
|
||||
docker push $(IMAGE)
|
||||
endif
|
||||
# Build should be cached from build-container
|
||||
docker buildx create --use
|
||||
docker buildx build --push --platform $(DOCKER_PLATFORMS) -t $(IMAGE) --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg LOGCOUNTER=$(LOGCOUNTER) .
|
||||
|
||||
push-tar: build-tar
|
||||
gsutil cp $(TARBALL) $(UPLOAD_PATH)/node-problem-detector/
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
# Copyright 2018 The Kubernetes Authors. All rights reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM golang:1.11.0
|
||||
LABEL maintainer="Andy Xie <andy.xning@gmail.com>"
|
||||
|
||||
ENV GOPATH /gopath/
|
||||
ENV PATH $GOPATH/bin:$PATH
|
||||
|
||||
RUN apt-get update && apt-get --yes install libsystemd-dev
|
||||
RUN go version
|
||||
RUN go get github.com/tools/godep
|
||||
RUN godep version
|
||||
CMD ["/bin/bash"]
|
||||
Reference in New Issue
Block a user