Generate CRDs with controller-gen instead

This commit is contained in:
2026-04-03 03:10:20 +08:00
parent 1ce15e9ac5
commit 53f9f9376a
13 changed files with 137 additions and 145 deletions

View File

@@ -1,17 +1,20 @@
# Should be the same as upstream version in prodution
# Should be the same as upstream version in production
VERSION ?= dev
# Target kube version
KUBE_VERSION ?= v1.35.1
GIT_REV=$(shell git rev-parse HEAD)
GIT_REV := $(shell git rev-parse HEAD)
BIN_DIR := bin
OUT_DIR := out
BUILDINFO_FILE := pkg/buildinfo/buildinfo_gen.go
CRD_PATHS := ./pkg/apis/...
# Never cache this
.buildinfo:
@mkdir -p $(dir $(BUILDINFO_FILE))
@printf '%s\n' \
'package buildinfo' \
'' \
@@ -24,8 +27,9 @@ BUILDINFO_FILE := pkg/buildinfo/buildinfo_gen.go
> $(BUILDINFO_FILE)
build: .buildinfo
mkdir -p $(BIN_DIR)
GOOS=linux GOARCH=arm64 go build -o $(BIN_DIR)/ctl-linux-aarch64-$(VERSION) ./cmd/ctl/
mkdir -p $(BIN_DIR) $(OUT_DIR)/crds
controller-gen crd paths=$(CRD_PATHS) output:crd:dir=$(OUT_DIR)/crds
GOOS=linux GOARCH=arm64 go build -o $(BIN_DIR)/ctl-linux-aarch64-$(VERSION) ./cmd/ctl
build-agent: build
docker build \
@@ -34,15 +38,17 @@ build-agent: build
-t localhost/monok8s/control-agent:$(VERSION) .
build-local: .buildinfo
mkdir -p $(BIN_DIR)
go build -o $(BIN_DIR)/ctl-$(VERSION) ./cmd/ctl
run:
go run ./cmd/ctl
clean:
docker image rm localhost/monok8s/control-agent:$(VERSION)
-docker image rm localhost/monok8s/control-agent:$(VERSION)
rm -rf $(BIN_DIR) \
$(BUILDINFO_FILE)
$(BUILDINFO_FILE) \
$(OUT_DIR)/crds
all: build build-agent build-local