1
0
Files
monitor/Makefile
dragonflylee 696f6ba425 update demo
Signed-off-by: dragonflylee <dragonflylee@outlook.com>
2023-12-22 16:55:35 +08:00

53 lines
1.6 KiB
Makefile

# Image URL to use all building/pushing image targets
IMG ?= localhost:5000/monitor
# Makefile
CONTROLLER_GEN = bin/controller-gen
CI_COMMIT ?= $(shell git rev-parse --short HEAD)
CI_BRANCH ?= $(shell git describe --tags)
LDFLAGS = -s -w -X 'main.version=$(CI_BRANCH)' -X 'main.commit=$(CI_COMMIT)'
all: build
##@ Development
manifests: $(CONTROLLER_GEN) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=role crd webhook paths=./pkg/...
generate: $(CONTROLLER_GEN) ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object paths=./pkg/apis/...
fmt: ## Run go fmt against code.
go fmt ./...
vet: ## Run go vet against code.
go vet ./...
##@ Build
build: generate ## Build manager binary.
CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "$(LDFLAGS)" -o bin/manager -v cmd/main.go
run: generate
go run cmd/main.go
dockerx:
# docker buildx create --use --driver-opt network=host
docker buildx build --platform linux/amd64,linux/arm64 --build-arg "LDFLAGS=$(LDFLAGS)" -t $(IMG) --push .
docker:
docker build --network host -t $(IMG) --build-arg TARGETARCH=$(shell go env GOARCH) --build-arg "LDFLAGS=$(LDFLAGS)" .
docker push $(IMG)
docker rmi $(IMG)
install: manifests
kubectl kustomize config | kubectl create -f -
clean:
kubectl kustomize config | kubectl delete --ignore-not-found=true -f -
$(CONTROLLER_GEN): ## Download controller-gen locally if necessary.
@[ -f $@ ] || GOBIN=$(shell pwd)/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.4