mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-02-14 09:59:56 +00:00
Build Windows image
This commit is contained in:
32
Dockerfile
32
Dockerfile
@@ -1,18 +1,4 @@
|
|||||||
# Copyright 2016 The Kubernetes Authors All rights reserved.
|
# "builder-base" can be overridden using docker buildx's --build-context flag,
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# "builder-base" can be overriden using dockerb buildx's --build-context flag,
|
|
||||||
# by users who want to use a different images for the builder. E.g. if you need to use an older OS
|
# by users who want to use a different images for the builder. E.g. if you need to use an older OS
|
||||||
# to avoid dependencies on very recent glibc versions.
|
# to avoid dependencies on very recent glibc versions.
|
||||||
# E.g. of the param: --build-context builder-base=docker-image://golang:<something>@sha256:<something>
|
# E.g. of the param: --build-context builder-base=docker-image://golang:<something>@sha256:<something>
|
||||||
@@ -26,27 +12,25 @@ ARG TARGETARCH
|
|||||||
|
|
||||||
ENV GOPATH=/gopath/
|
ENV GOPATH=/gopath/
|
||||||
ENV PATH=$GOPATH/bin:$PATH
|
ENV PATH=$GOPATH/bin:$PATH
|
||||||
|
|
||||||
RUN apt-get update --fix-missing && apt-get --yes install libsystemd-dev
|
|
||||||
RUN go version
|
RUN go version
|
||||||
|
|
||||||
COPY . /gopath/src/k8s.io/node-problem-detector/
|
RUN apt-get update --fix-missing && apt-get --yes install libsystemd-dev
|
||||||
WORKDIR /gopath/src/k8s.io/node-problem-detector
|
|
||||||
|
COPY . /src/
|
||||||
|
WORKDIR /src
|
||||||
RUN GOARCH=${TARGETARCH} make bin/node-problem-detector bin/health-checker bin/log-counter
|
RUN GOARCH=${TARGETARCH} make bin/node-problem-detector bin/health-checker bin/log-counter
|
||||||
|
|
||||||
FROM registry.k8s.io/build-image/debian-base:bookworm-v1.0.6@sha256:e100119ba6cf265b29957046f178e9374f9a9419133284c9b883e64c5b463d73 AS base
|
FROM registry.k8s.io/build-image/debian-base:bookworm-v1.0.6@sha256:e100119ba6cf265b29957046f178e9374f9a9419133284c9b883e64c5b463d73 AS base
|
||||||
|
|
||||||
LABEL maintainer="Random Liu <lantaol@google.com>"
|
|
||||||
|
|
||||||
RUN clean-install util-linux bash libsystemd-dev
|
RUN clean-install util-linux bash libsystemd-dev
|
||||||
|
|
||||||
# Avoid symlink of /etc/localtime.
|
# Avoid symlink of /etc/localtime.
|
||||||
RUN test -h /etc/localtime && rm -f /etc/localtime && cp /usr/share/zoneinfo/UTC /etc/localtime || true
|
RUN test -h /etc/localtime && rm -f /etc/localtime && cp /usr/share/zoneinfo/UTC /etc/localtime || true
|
||||||
|
|
||||||
COPY --from=builder /gopath/src/k8s.io/node-problem-detector/bin/node-problem-detector /node-problem-detector
|
COPY --from=builder /src/bin/node-problem-detector /node-problem-detector
|
||||||
|
|
||||||
ARG LOGCOUNTER
|
ARG LOGCOUNTER
|
||||||
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 --from=builder /src/bin/health-checker /src/${LOGCOUNTER} /home/kubernetes/bin/
|
||||||
|
|
||||||
COPY --from=builder /gopath/src/k8s.io/node-problem-detector/config/ /config
|
COPY --from=builder /src/config/ /config
|
||||||
ENTRYPOINT ["/node-problem-detector", "--config.system-log-monitor=/config/kernel-monitor.json,/config/readonly-monitor.json"]
|
ENTRYPOINT ["/node-problem-detector", "--config.system-log-monitor=/config/kernel-monitor.json,/config/readonly-monitor.json"]
|
||||||
|
|||||||
27
Dockerfile.windows
Normal file
27
Dockerfile.windows
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# "builder-base" can be overridden using docker buildx's --build-context flag,
|
||||||
|
# by users who want to use a different images for the builder. E.g. if you need to use an older OS
|
||||||
|
# to avoid dependencies on very recent glibc versions.
|
||||||
|
# E.g. of the param: --build-context builder-base=docker-image://golang:<something>@sha256:<something>
|
||||||
|
# Must override builder-base, not builder, since the latter is referred to later in the file and so must not be
|
||||||
|
# directly replaced. See here, and note that "stage" parameter mentioned there has been renamed to
|
||||||
|
# "build-context": https://github.com/docker/buildx/pull/904#issuecomment-1005871838
|
||||||
|
FROM --platform=linux/$BUILDARCH golang:1.25.4-bookworm@sha256:e17419604b6d1f9bc245694425f0ec9b1b53685c80850900a376fb10cb0f70cb AS builder-base
|
||||||
|
FROM --platform=linux/$BUILDARCH builder-base AS builder
|
||||||
|
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
ENV GOPATH=/gopath/
|
||||||
|
ENV PATH=$GOPATH/bin:$PATH
|
||||||
|
RUN go version
|
||||||
|
|
||||||
|
COPY . /src/
|
||||||
|
WORKDIR /src
|
||||||
|
RUN GOARCH=${TARGETARCH} make bin/node-problem-detector.exe bin/health-checker.exe
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022-${TARGETARCH} AS base
|
||||||
|
|
||||||
|
COPY --from=builder /src/bin/node-problem-detector.exe /node-problem-detector.exe
|
||||||
|
COPY --from=builder /src/bin/health-checker.exe /etc/kubernetes/node/bin/health-checker.exe
|
||||||
|
|
||||||
|
COPY --from=builder /src/config/ /config
|
||||||
|
ENTRYPOINT ["/node-problem-detector.exe"]
|
||||||
22
Makefile
22
Makefile
@@ -65,8 +65,10 @@ TARBALL=$(NPD_NAME_VERSION).tar.gz
|
|||||||
|
|
||||||
# IMAGE_TAGS contains the image tags of the node problem detector container image.
|
# IMAGE_TAGS contains the image tags of the node problem detector container image.
|
||||||
IMAGE_TAGS=--tag $(REGISTRY)/node-problem-detector:$(TAG)
|
IMAGE_TAGS=--tag $(REGISTRY)/node-problem-detector:$(TAG)
|
||||||
|
IMAGE_TAGS_WINDOWS=--tag $(REGISTRY)/node-problem-detector-windows:$(TAG)
|
||||||
ifeq ($(REGISTRY), gcr.io/k8s-staging-npd)
|
ifeq ($(REGISTRY), gcr.io/k8s-staging-npd)
|
||||||
IMAGE_TAGS+= --tag $(REGISTRY)/node-problem-detector:$(BRANCH)
|
IMAGE_TAGS+= --tag $(REGISTRY)/node-problem-detector:$(BRANCH)
|
||||||
|
IMAGE_TAGS_WINDOWS+= --tag $(REGISTRY)/node-problem-detector-windows:$(BRANCH)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# ENABLE_JOURNALD enables build journald support or not. Building journald
|
# ENABLE_JOURNALD enables build journald support or not. Building journald
|
||||||
@@ -215,6 +217,12 @@ else
|
|||||||
echo "Warning: log-counter requires journald, skipping."
|
echo "Warning: log-counter requires journald, skipping."
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
./bin/node-problem-detector.exe: $(PKG_SOURCES)
|
||||||
|
CGO_ENABLED=0 GOOS=windows GOARCH=$(GOARCH) go build \
|
||||||
|
-o bin/node-problem-detector.exe \
|
||||||
|
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
|
||||||
|
./cmd/nodeproblemdetector
|
||||||
|
|
||||||
./bin/node-problem-detector: $(PKG_SOURCES)
|
./bin/node-problem-detector: $(PKG_SOURCES)
|
||||||
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(GOARCH) CC=$(CC) go build \
|
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(GOARCH) CC=$(CC) go build \
|
||||||
-o bin/node-problem-detector \
|
-o bin/node-problem-detector \
|
||||||
@@ -236,6 +244,12 @@ endif
|
|||||||
-tags "$(LINUX_BUILD_TAGS)" \
|
-tags "$(LINUX_BUILD_TAGS)" \
|
||||||
cmd/healthchecker/health_checker.go
|
cmd/healthchecker/health_checker.go
|
||||||
|
|
||||||
|
./bin/health-checker.exe: $(PKG_SOURCES)
|
||||||
|
CGO_ENABLED=0 GOOS=windows GOARCH=$(GOARCH) go build \
|
||||||
|
-o bin/health-checker.exe \
|
||||||
|
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
|
||||||
|
cmd/healthchecker/health_checker.go
|
||||||
|
|
||||||
test: vet fmt
|
test: vet fmt
|
||||||
go test -timeout=1m -v -race -short -tags "$(HOST_PLATFORM_BUILD_TAGS)" ./...
|
go test -timeout=1m -v -race -short -tags "$(HOST_PLATFORM_BUILD_TAGS)" ./...
|
||||||
|
|
||||||
@@ -263,6 +277,10 @@ build-container: clean Dockerfile
|
|||||||
docker buildx create --platform $(DOCKER_PLATFORMS) --use
|
docker buildx create --platform $(DOCKER_PLATFORMS) --use
|
||||||
docker buildx build --platform $(DOCKER_PLATFORMS) $(IMAGE_TAGS) --build-arg LOGCOUNTER=$(LOGCOUNTER) .
|
docker buildx build --platform $(DOCKER_PLATFORMS) $(IMAGE_TAGS) --build-arg LOGCOUNTER=$(LOGCOUNTER) .
|
||||||
|
|
||||||
|
build-container-windows: clean Dockerfile.windows
|
||||||
|
docker buildx create --platform windows/amd64 --use
|
||||||
|
docker buildx build --platform windows/amd64 $(IMAGE_TAGS_WINDOWS) -f Dockerfile.windows .
|
||||||
|
|
||||||
$(TARBALL): ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker ./test/bin/problem-maker
|
$(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
|
tar -zcvf $(TARBALL) bin/ config/ test/e2e-install.sh test/bin/problem-maker
|
||||||
sha1sum $(TARBALL)
|
sha1sum $(TARBALL)
|
||||||
@@ -284,6 +302,10 @@ push-container: build-container
|
|||||||
# Build should be cached from build-container
|
# Build should be cached from build-container
|
||||||
docker buildx build --push --platform $(DOCKER_PLATFORMS) $(IMAGE_TAGS) --build-arg LOGCOUNTER=$(LOGCOUNTER) .
|
docker buildx build --push --platform $(DOCKER_PLATFORMS) $(IMAGE_TAGS) --build-arg LOGCOUNTER=$(LOGCOUNTER) .
|
||||||
|
|
||||||
|
push-container-windows: build-container-windows
|
||||||
|
# Build should be cached from build-container
|
||||||
|
docker buildx build --push --platform windows/amdd64 $(IMAGE_TAGS_WINDOWS) -f Dockerfile.windows .
|
||||||
|
|
||||||
push-tar: build-tar
|
push-tar: build-tar
|
||||||
gsutil cp $(TARBALL) $(UPLOAD_PATH)/node-problem-detector/
|
gsutil cp $(TARBALL) $(UPLOAD_PATH)/node-problem-detector/
|
||||||
gsutil cp node-problem-detector-$(VERSION)-*.tar.gz* $(UPLOAD_PATH)/node-problem-detector/
|
gsutil cp node-problem-detector-$(VERSION)-*.tar.gz* $(UPLOAD_PATH)/node-problem-detector/
|
||||||
|
|||||||
@@ -8,9 +8,15 @@ options:
|
|||||||
substitution_option: ALLOW_LOOSE
|
substitution_option: ALLOW_LOOSE
|
||||||
steps:
|
steps:
|
||||||
- name: 'gcr.io/cloud-builders/docker'
|
- name: 'gcr.io/cloud-builders/docker'
|
||||||
|
id: linux
|
||||||
entrypoint: make
|
entrypoint: make
|
||||||
args:
|
args:
|
||||||
- push-container
|
- push-container
|
||||||
|
- name: 'gcr.io/cloud-builders/docker'
|
||||||
|
id: windows
|
||||||
|
entrypoint: make
|
||||||
|
args:
|
||||||
|
- push-container-windows
|
||||||
substitutions:
|
substitutions:
|
||||||
_GIT_TAG: 'dev'
|
_GIT_TAG: 'dev'
|
||||||
_PULL_BASE_REF: 'dev'
|
_PULL_BASE_REF: 'dev'
|
||||||
|
|||||||
Reference in New Issue
Block a user