Skip to content

Commit c6addc9

Browse files
authored
build(object-controller): package the standalone controller (#2948)
Add object-controller to local and Linux builds, Docker image creation, KIND loading, and multi-architecture GoReleaser output. Refs: OPRUN-4774 Signed-off-by: Fabricio Aguiar <fabricio.aguiar@gmail.com> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
1 parent d2fab48 commit c6addc9

3 files changed

Lines changed: 76 additions & 3 deletions

File tree

‎.goreleaser.yml‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ before:
44
- go mod tidy
55
- go mod download
66
builds:
7+
- id: object-controller
8+
main: ./cmd/object-controller/
9+
binary: object-controller
10+
asmflags: "{{ .Env.GO_BUILD_ASMFLAGS }}"
11+
gcflags: "{{ .Env.GO_BUILD_GCFLAGS }}"
12+
ldflags: "{{ .Env.GO_BUILD_LDFLAGS }}"
13+
tags:
14+
- "{{ .Env.GO_BUILD_TAGS }}"
15+
mod_timestamp: "{{ .CommitTimestamp }}"
16+
goos:
17+
- linux
18+
goarch:
19+
- amd64
20+
- arm64
21+
- ppc64le
22+
- s390x
723
- id: operator-controller
824
main: ./cmd/operator-controller/
925
binary: operator-controller
@@ -37,6 +53,42 @@ builds:
3753
- ppc64le
3854
- s390x
3955
dockers:
56+
- image_templates:
57+
- "{{ .Env.OBJECT_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64"
58+
dockerfile: Dockerfile.object-controller
59+
goos: linux
60+
goarch: amd64
61+
use: buildx
62+
build_flag_templates:
63+
- "--platform=linux/amd64"
64+
- "--provenance=false"
65+
- image_templates:
66+
- "{{ .Env.OBJECT_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-arm64"
67+
dockerfile: Dockerfile.object-controller
68+
goos: linux
69+
goarch: arm64
70+
use: buildx
71+
build_flag_templates:
72+
- "--platform=linux/arm64"
73+
- "--provenance=false"
74+
- image_templates:
75+
- "{{ .Env.OBJECT_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-ppc64le"
76+
dockerfile: Dockerfile.object-controller
77+
goos: linux
78+
goarch: ppc64le
79+
use: buildx
80+
build_flag_templates:
81+
- "--platform=linux/ppc64le"
82+
- "--provenance=false"
83+
- image_templates:
84+
- "{{ .Env.OBJECT_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-s390x"
85+
dockerfile: Dockerfile.object-controller
86+
goos: linux
87+
goarch: s390x
88+
use: buildx
89+
build_flag_templates:
90+
- "--platform=linux/s390x"
91+
- "--provenance=false"
4092
- image_templates:
4193
- "{{ .Env.OPCON_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64"
4294
dockerfile: Dockerfile.operator-controller
@@ -110,6 +162,12 @@ dockers:
110162
- "--platform=linux/s390x"
111163
- "--provenance=false"
112164
docker_manifests:
165+
- name_template: "{{ .Env.OBJECT_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}"
166+
image_templates:
167+
- "{{ .Env.OBJECT_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64"
168+
- "{{ .Env.OBJECT_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-arm64"
169+
- "{{ .Env.OBJECT_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-ppc64le"
170+
- "{{ .Env.OBJECT_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-s390x"
113171
- name_template: "{{ .Env.OPCON_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}"
114172
image_templates:
115173
- "{{ .Env.OPCON_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64"

‎Dockerfile.object-controller‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Build the binary with make build-linux before building this image.
2+
FROM gcr.io/distroless/static:nonroot
3+
WORKDIR /
4+
COPY object-controller object-controller
5+
USER 65532:65532
6+
7+
ENTRYPOINT ["/object-controller"]

‎Makefile‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ CATD_IMAGE_REPO := $(IMAGE_REGISTRY)/catalogd
2424
endif
2525
export CATD_IMAGE_REPO
2626

27+
ifeq ($(origin OBJECT_CONTROLLER_IMAGE_REPO), undefined)
28+
OBJECT_CONTROLLER_IMAGE_REPO := $(IMAGE_REGISTRY)/object-controller
29+
endif
30+
export OBJECT_CONTROLLER_IMAGE_REPO
31+
2732
ifeq ($(origin IMAGE_TAG), undefined)
2833
IMAGE_TAG := devel
2934
endif
3035
export IMAGE_TAG
3136

3237
OPCON_IMG := $(OPCON_IMAGE_REPO):$(IMAGE_TAG)
3338
CATD_IMG := $(CATD_IMAGE_REPO):$(IMAGE_TAG)
39+
OBJECT_CONTROLLER_IMG := $(OBJECT_CONTROLLER_IMAGE_REPO):$(IMAGE_TAG)
3440

3541
# Extract Kubernetes client-go version used to set the version to the PSA labels, for ENVTEST and KIND
3642
ifeq ($(origin K8S_VERSION), undefined)
@@ -351,6 +357,7 @@ kind-cluster-%: $(KIND) #EXHELP Create a kind cluster named after the stem (%).
351357
kind-load-%: kind-cluster-% docker-build
352358
$(KIND) load docker-image $(OPCON_IMG) --name $*
353359
$(KIND) load docker-image $(CATD_IMG) --name $*
360+
$(KIND) load docker-image $(OBJECT_CONTROLLER_IMG) --name $*
354361

355362
.PHONY: kind-deploy-%
356363
kind-deploy-%: kind-load-% manifests
@@ -605,7 +612,7 @@ export GO_BUILD_LDFLAGS := -s -w \
605612
-X '$(VERSION_PATH).version=$(VERSION)' \
606613
-X '$(VERSION_PATH).gitCommit=$(GIT_COMMIT)' \
607614

608-
BINARIES=operator-controller catalogd
615+
BINARIES=operator-controller catalogd object-controller
609616

610617
.PHONY: $(BINARIES)
611618
$(BINARIES):
@@ -644,9 +651,10 @@ FLUENTBIT_NAMESPACE := fluent-bit
644651
FLUENTBIT_CHART_VERSION := 0.57.9
645652

646653
.PHONY: docker-build
647-
docker-build: build-linux #EXHELP Build docker image for operator-controller and catalog with GOOS=linux and local GOARCH.
654+
docker-build: build-linux #EXHELP Build controller images with GOOS=linux and local GOARCH.
648655
$(CONTAINER_RUNTIME) build -t $(OPCON_IMG) -f Dockerfile.operator-controller ./bin/linux
649656
$(CONTAINER_RUNTIME) build -t $(CATD_IMG) -f Dockerfile.catalogd ./bin/linux
657+
$(CONTAINER_RUNTIME) build -t $(OBJECT_CONTROLLER_IMG) -f Dockerfile.object-controller ./bin/linux
650658

651659
#SECTION Release
652660
ifeq ($(origin ENABLE_RELEASE_PIPELINE), undefined)
@@ -661,7 +669,7 @@ export GORELEASER_ARGS
661669

662670
.PHONY: release
663671
release: $(GORELEASER) #EXHELP Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release.
664-
OPCON_IMAGE_REPO=$(OPCON_IMAGE_REPO) CATD_IMAGE_REPO=$(CATD_IMAGE_REPO) $(GORELEASER) $(GORELEASER_ARGS)
672+
OPCON_IMAGE_REPO=$(OPCON_IMAGE_REPO) CATD_IMAGE_REPO=$(CATD_IMAGE_REPO) OBJECT_CONTROLLER_IMAGE_REPO=$(OBJECT_CONTROLLER_IMAGE_REPO) $(GORELEASER) $(GORELEASER_ARGS)
665673

666674
.PHONY: quickstart
667675
quickstart: export STANDARD_MANIFEST_URL := "https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/$(notdir $(STANDARD_RELEASE_MANIFEST))"

0 commit comments

Comments
 (0)