Skip to content

Commit 8fefe1c

Browse files
authored
refactor!: new cloud native approach for reconciliation (#150)
* refactor!: new cloud native approach for reconciliation * ci: remove old script * fix: lint errors * fix: makefile
1 parent adbb61d commit 8fefe1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+20154
-713
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*.dylib
88
bin
99
manager
10+
proxy/proxy
1011

1112
# Test binary, build with `go test -c`
1213
*.test

.goreleaser.yaml

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,22 @@ builds:
77
- linux
88
env:
99
- CGO_ENABLED=0
10+
- id: proxy
11+
binary: proxy
12+
goos:
13+
- linux
14+
env:
15+
- CGO_ENABLED=0
1016

1117
archives:
1218
- id: manager
1319
name_template: "manager_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
1420
builds:
1521
- manager
22+
- id: proxy
23+
name_template: "proxy_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
24+
builds:
25+
- proxy
1626

1727
checksum:
1828
name_template: 'checksums.txt'
@@ -35,8 +45,6 @@ dockers:
3545
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-amd64
3646
dockerfile: Dockerfile
3747
use: buildx
38-
extra_files:
39-
- assets
4048
ids:
4149
- manager
4250
build_flag_templates:
@@ -54,8 +62,6 @@ dockers:
5462
goarch: arm64
5563
dockerfile: Dockerfile
5664
use: buildx
57-
extra_files:
58-
- assets
5965
ids:
6066
- manager
6167
build_flag_templates:
@@ -68,6 +74,39 @@ dockers:
6874
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
6975
- --label=org.opencontainers.image.revision={{ .FullCommit }}
7076
- --label=org.opencontainers.image.licenses=Apache-2.0
77+
- image_templates:
78+
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-amd64
79+
dockerfile: proxy/Dockerfile
80+
use: buildx
81+
ids:
82+
- proxy
83+
build_flag_templates:
84+
- --platform=linux/amd64
85+
- --label=org.opencontainers.image.title={{ .ProjectName }}
86+
- --label=org.opencontainers.image.description={{ .ProjectName }}
87+
- --label=org.opencontainers.image.url=https://github.com/doodlescheduling/{{ .ProjectName }}
88+
- --label=org.opencontainers.image.source=https://github.com/doodlescheduling/{{ .ProjectName }}
89+
- --label=org.opencontainers.image.version={{ .Version }}
90+
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
91+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
92+
- --label=org.opencontainers.image.licenses=Apache-2.0
93+
- image_templates:
94+
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-arm64v8
95+
goarch: arm64
96+
dockerfile: proxy/Dockerfile
97+
use: buildx
98+
ids:
99+
- proxy
100+
build_flag_templates:
101+
- --platform=linux/arm64/v8
102+
- --label=org.opencontainers.image.title={{ .ProjectName }}
103+
- --label=org.opencontainers.image.description={{ .ProjectName }}
104+
- --label=org.opencontainers.image.url=https://github.com/doodlescheduling/{{ .ProjectName }}
105+
- --label=org.opencontainers.image.source=https://github.com/doodlescheduling/{{ .ProjectName }}
106+
- --label=org.opencontainers.image.version={{ .Version }}
107+
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
108+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
109+
- --label=org.opencontainers.image.licenses=Apache-2.0
71110

72111
docker_manifests:
73112
- name_template: ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}
@@ -78,6 +117,14 @@ docker_manifests:
78117
image_templates:
79118
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-amd64
80119
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-arm64v8
120+
- name_template: ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}
121+
image_templates:
122+
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-amd64
123+
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-arm64v8
124+
- name_template: ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:latest
125+
image_templates:
126+
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-amd64
127+
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-arm64v8
81128

82129
signs:
83130
- cmd: cosign

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
FROM amazoncorretto:17.0.8
1+
FROM gcr.io/distroless/static:nonroot
22
WORKDIR /
33
COPY manager manager
44
USER 65532:65532
5-
COPY assets /assets
6-
ENV ASSETS_PATH="/assets"
7-
ENV USER keycloak-controller
85

96
ENTRYPOINT ["/manager"]

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
# Image URL to use all building/pushing image targets
3+
PROXY_IMG ?= keycloak-controller-proxy:latest
34
IMG ?= keycloak-controller:latest
45
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
56
ENVTEST_K8S_VERSION = 1.27
@@ -72,6 +73,7 @@ test: manifests generate fmt vet tidy envtest ## Run tests.
7273
.PHONY: build
7374
build: generate fmt vet tidy ## Build manager binary.
7475
CGO_ENABLED=0 go build -o manager main.go
76+
CGO_ENABLED=0 go build -o proxy/proxy ./proxy/
7577

7678
.PHONY: run
7779
run: manifests generate fmt vet tidy ## Run a controller from your host.
@@ -90,10 +92,12 @@ api-docs: gen-crd-api-reference-docs
9092
.PHONY: docker-build
9193
docker-build: build
9294
docker build -t ${IMG} .
95+
docker build -t ${PROXY_IMG} proxy
9396

9497
.PHONY: docker-push
9598
docker-push: ## Push docker image with the manager.
9699
docker push ${IMG}
100+
docker push ${PROXY_IMG}
97101

98102
##@ Deployment
99103

@@ -123,10 +127,10 @@ CLUSTER=kind
123127

124128
.PHONY: kind-test
125129
kind-test: ## Deploy including test
126-
kustomize build config/base/crd | kubectl --context kind-${CLUSTER} apply -f -
130+
kustomize build config/base/crd | kubectl --context kind-${CLUSTER} apply --server-side=true -f -
127131
kubectl --context kind-${CLUSTER} -n keycloak-system delete pods --all
128132
kind load docker-image ${IMG} --name ${CLUSTER}
129-
kustomize build config/tests/cases/${TEST_PROFILE} --enable-helm | kubectl --context kind-${CLUSTER} apply -f -
133+
kustomize build config/tests/cases/${TEST_PROFILE} --enable-helm | kubectl --context kind-${CLUSTER} apply --server-side=true -f -
130134
kubectl --context kind-${CLUSTER} -n keycloak-system wait --for=condition=Ready pods -l control-plane=controller-manager -l app.kubernetes.io/managed-by!=Helm,verify!=yes --timeout=3m
131135
kubectl --context kind-${CLUSTER} -n keycloak-system wait --for=jsonpath='{.status.conditions[1].reason}'=PodCompleted pods -l app.kubernetes.io/managed-by!=Helm,verify=yes --timeout=3m
132136

0 commit comments

Comments
 (0)