mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-08-19 04:06:24 +00:00
Update Makefile to support compile journald support
This commit is contained in:
@@ -1 +1,2 @@
|
||||
/bin/node-problem-detector
|
||||
/Dockerfile
|
||||
|
||||
@@ -12,8 +12,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM alpine:3.4
|
||||
FROM @BASEIMAGE@
|
||||
MAINTAINER Random Liu <lantaol@google.com>
|
||||
|
||||
# Avoid symlink of /etc/localtime.
|
||||
RUN test -h /etc/localtime && rm -f /etc/localtime && cp /usr/share/zoneinfo/UTC /etc/localtime || true
|
||||
|
||||
ADD ./bin/node-problem-detector /node-problem-detector
|
||||
ADD config /config
|
||||
ENTRYPOINT ["/node-problem-detector", "--kernel-monitor=/config/kernel-monitor.json"]
|
||||
@@ -1,24 +1,73 @@
|
||||
.PHONY: all build-container build-tar build push-container push-tar push clean vet fmt version
|
||||
# Copyright 2017 The Kubernetes Authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Build the node-problem-detector image.
|
||||
|
||||
.PHONY: all build-container build-tar build push-container push-tar push clean vet fmt version Dockerfile
|
||||
|
||||
all: build
|
||||
|
||||
VERSION := $(shell git describe --tags --dirty)
|
||||
# VERSION is the version of the binary.
|
||||
VERSION:=$(shell git describe --tags --dirty)
|
||||
|
||||
TAG ?= $(VERSION)
|
||||
# TAG is the tag of the container image, default to binary version.
|
||||
TAG?=$(VERSION)
|
||||
|
||||
UPLOAD_PATH ?= gs://kubernetes-release
|
||||
# PROJ is the image project.
|
||||
PROJ?=gcr.io/google_containers
|
||||
|
||||
# UPLOAD_PATH is the cloud storage path to upload release tar.
|
||||
UPLOAD_PATH?=gs://kubernetes-release
|
||||
# Trim the trailing '/' in the path
|
||||
UPLOAD_PATH := $(shell echo $(UPLOAD_PATH) | sed '$$s/\/*$$//')
|
||||
UPLOAD_PATH:=$(shell echo $(UPLOAD_PATH) | sed '$$s/\/*$$//')
|
||||
|
||||
PROJ ?= google_containers
|
||||
# PKG is the package name of node problem detector repo.
|
||||
PKG:=k8s.io/node-problem-detector
|
||||
|
||||
PKG := k8s.io/node-problem-detector
|
||||
# PKG_SOURCES are all the go source code.
|
||||
PKG_SOURCES:=$(shell find pkg cmd -name '*.go')
|
||||
|
||||
PKG_SOURCES := $(shell find pkg cmd -name '*.go')
|
||||
# TARBALL is the name of release tar. Include binary version by default.
|
||||
TARBALL:=node-problem-detector-$(VERSION).tar.gz
|
||||
|
||||
TARBALL := node-problem-detector-$(VERSION).tar.gz
|
||||
# IMAGE is the image name of the node problem detector container image.
|
||||
IMAGE:=$(PROJ)/node-problem-detector:$(TAG)
|
||||
|
||||
IMAGE := gcr.io/$(PROJ)/node-problem-detector:$(TAG)
|
||||
# ENABLE_JOURNALD enables build journald support or not. Building journald support needs libsystemd-dev
|
||||
# or libsystemd-journal-dev.
|
||||
# TODO(random-liu): Build NPD inside container.
|
||||
ENABLE_JOURNALD?=1
|
||||
|
||||
# TODO(random-liu): Support different architectures.
|
||||
BASEIMAGE:=alpine:3.4
|
||||
|
||||
# Disable cgo by default to make the binary statically linked.
|
||||
CGO_ENABLED:=0
|
||||
|
||||
# NOTE that enable journald will increase the image size.
|
||||
ifeq ($(ENABLE_JOURNALD), 1)
|
||||
# Enable journald build tag.
|
||||
BUILD_TAGS:=-tags journald
|
||||
# Use fedora because it has newer systemd version (229) and support +LZ4. +LZ4 is needed
|
||||
# on some os distros such as GCI.
|
||||
BASEIMAGE:=fedora
|
||||
# Enable cgo because sdjournal needs cgo to compile. The binary will be dynamically
|
||||
# linked if CGO_ENABLED is enabled. This is fine because fedora already has necessary
|
||||
# dynamic library. We can not use `-extldflags "-static"` here, because go-systemd uses
|
||||
# dlopen, and dlopen will not work properly in a statically linked application.
|
||||
CGO_ENABLED:=1
|
||||
endif
|
||||
|
||||
vet:
|
||||
go list ./... | grep -v "./vendor/*" | xargs go vet
|
||||
@@ -30,14 +79,17 @@ version:
|
||||
@echo $(VERSION)
|
||||
|
||||
./bin/node-problem-detector: $(PKG_SOURCES)
|
||||
GOOS=linux go build -o bin/node-problem-detector \
|
||||
-ldflags '-w -extldflags "-static" -X $(PKG)/pkg/version.version=$(VERSION)' \
|
||||
cmd/node_problem_detector.go
|
||||
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux go build -o bin/node-problem-detector \
|
||||
-ldflags '-w -X $(PKG)/pkg/version.version=$(VERSION)' \
|
||||
$(BUILD_TAGS) cmd/node_problem_detector.go
|
||||
|
||||
Dockerfile: Dockerfile.in
|
||||
sed -e 's|@BASEIMAGE@|$(BASEIMAGE)|g' $< >$@
|
||||
|
||||
test: vet fmt
|
||||
go test -timeout=1m -v -race ./pkg/...
|
||||
go test -timeout=1m -v -race ./pkg/... $(BUILD_TAGS)
|
||||
|
||||
build-container: ./bin/node-problem-detector
|
||||
build-container: ./bin/node-problem-detector Dockerfile
|
||||
docker build -t $(IMAGE) .
|
||||
|
||||
build-tar: ./bin/node-problem-detector
|
||||
|
||||
@@ -12,6 +12,7 @@ spec:
|
||||
- name: node-problem-detector
|
||||
command:
|
||||
- /node-problem-detector
|
||||
- --logtostderr
|
||||
- --kernel-monitor=/config/kernel-monitor.json
|
||||
image: gcr.io/google_containers/node-problem-detector:v0.2
|
||||
imagePullPolicy: Always
|
||||
|
||||
Reference in New Issue
Block a user