Skip to content

Commit

Permalink
refactor!: new cloud native approach for reconciliation (#150)
Browse files Browse the repository at this point in the history
* refactor!: new cloud native approach for reconciliation

* ci: remove old script

* fix: lint errors

* fix: makefile
  • Loading branch information
raffis authored Dec 6, 2023
1 parent adbb61d commit 8fefe1c
Show file tree
Hide file tree
Showing 45 changed files with 20,154 additions and 713 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*.dylib
bin
manager
proxy/proxy

# Test binary, build with `go test -c`
*.test
Expand Down
55 changes: 51 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ builds:
- linux
env:
- CGO_ENABLED=0
- id: proxy
binary: proxy
goos:
- linux
env:
- CGO_ENABLED=0

archives:
- id: manager
name_template: "manager_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
builds:
- manager
- id: proxy
name_template: "proxy_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
builds:
- proxy

checksum:
name_template: 'checksums.txt'
Expand All @@ -35,8 +45,6 @@ dockers:
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-amd64
dockerfile: Dockerfile
use: buildx
extra_files:
- assets
ids:
- manager
build_flag_templates:
Expand All @@ -54,8 +62,6 @@ dockers:
goarch: arm64
dockerfile: Dockerfile
use: buildx
extra_files:
- assets
ids:
- manager
build_flag_templates:
Expand All @@ -68,6 +74,39 @@ dockers:
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=Apache-2.0
- image_templates:
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-amd64
dockerfile: proxy/Dockerfile
use: buildx
ids:
- proxy
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/doodlescheduling/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/doodlescheduling/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=Apache-2.0
- image_templates:
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-arm64v8
goarch: arm64
dockerfile: proxy/Dockerfile
use: buildx
ids:
- proxy
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/doodlescheduling/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/doodlescheduling/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=Apache-2.0

docker_manifests:
- name_template: ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}
Expand All @@ -78,6 +117,14 @@ docker_manifests:
image_templates:
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-amd64
- ghcr.io/doodlescheduling/{{ .ProjectName }}:v{{ .Version }}-arm64v8
- name_template: ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}
image_templates:
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-amd64
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-arm64v8
- name_template: ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:latest
image_templates:
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-amd64
- ghcr.io/doodlescheduling/{{ .ProjectName }}/proxy:v{{ .Version }}-arm64v8

signs:
- cmd: cosign
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
FROM amazoncorretto:17.0.8
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY manager manager
USER 65532:65532
COPY assets /assets
ENV ASSETS_PATH="/assets"
ENV USER keycloak-controller

ENTRYPOINT ["/manager"]
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

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

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

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
docker push ${IMG}
docker push ${PROXY_IMG}

##@ Deployment

Expand Down Expand Up @@ -123,10 +127,10 @@ CLUSTER=kind

.PHONY: kind-test
kind-test: ## Deploy including test
kustomize build config/base/crd | kubectl --context kind-${CLUSTER} apply -f -
kustomize build config/base/crd | kubectl --context kind-${CLUSTER} apply --server-side=true -f -
kubectl --context kind-${CLUSTER} -n keycloak-system delete pods --all
kind load docker-image ${IMG} --name ${CLUSTER}
kustomize build config/tests/cases/${TEST_PROFILE} --enable-helm | kubectl --context kind-${CLUSTER} apply -f -
kustomize build config/tests/cases/${TEST_PROFILE} --enable-helm | kubectl --context kind-${CLUSTER} apply --server-side=true -f -
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
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

Expand Down
Loading

0 comments on commit 8fefe1c

Please sign in to comment.