Skip to content

Commit

Permalink
chore: refactor admission controller
Browse files Browse the repository at this point in the history
  • Loading branch information
azrod committed Oct 24, 2024
1 parent 9f6db5b commit c9c351b
Show file tree
Hide file tree
Showing 26 changed files with 617 additions and 779 deletions.
60 changes: 0 additions & 60 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ builds:
- arm64
env:
- CGO_ENABLED=0
- id: "kimup-admission-controller"
binary: kimup-admission-controller
main: ./cmd/admission-controller
goos:
- linux
- darwin
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0

dockers:
# * KIMUP
Expand Down Expand Up @@ -128,45 +117,6 @@ dockers:
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}

# * KIMUP-ADMISSION-CONTROLLER
- goarch: amd64
image_templates:
- "ghcr.io/orange-cloudavenue/{{.ProjectName}}-admission-controller:v{{ .Version }}-amd64"
dockerfile: Dockerfile
use: buildx
ids:
- kimup-admission-controller
build_flag_templates:
- --platform=linux/amd64
- "--build-arg=BINNAME=kimup-admission-controller"
- --pull
- --label=org.opencontainers.image.title="kimup-admission-controller"
- --label=org.opencontainers.image.description="kube-image-updater-admission-controller"
- --label=org.opencontainers.image.url=https://github.com/orange-cloudavenue/kube-image-updater-admission-controller
- --label=org.opencontainers.image.source=https://github.com/orange-cloudavenue/kube-image-updater-admission-controller
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}

- goarch: arm64
image_templates:
- "ghcr.io/orange-cloudavenue/{{ .ProjectName }}-admission-controller:v{{ .Version }}-arm64v8"
dockerfile: Dockerfile
use: buildx
ids:
- kimup-admission-controller
build_flag_templates:
- --platform=linux/arm64/v8
- "--build-arg=BINNAME=kimup-admission-controller"
- --pull
- --label=org.opencontainers.image.title="kimup-admission-controller"
- --label=org.opencontainers.image.description="kube-image-updater-admission-controller"
- --label=org.opencontainers.image.url=https://github.com/orange-cloudavenue/kube-image-updater-admission-controller
- --label=org.opencontainers.image.source=https://github.com/orange-cloudavenue/kube-image-updater-admission-controller
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}

docker_manifests:
# * KIMUP
- name_template: "ghcr.io/orange-cloudavenue/{{ .ProjectName }}-controller:v{{ .Version }}"
Expand All @@ -187,13 +137,3 @@ docker_manifests:
image_templates:
- "ghcr.io/orange-cloudavenue/{{ .ProjectName }}-operator:v{{ .Version }}-amd64"
- "ghcr.io/orange-cloudavenue/{{ .ProjectName }}-operator:v{{ .Version }}-arm64v8"

# * KIMUP-ADMISSION-CONTROLLER
- name_template: "ghcr.io/orange-cloudavenue/{{ .ProjectName }}-admission-controller:v{{ .Version }}"
image_templates:
- "ghcr.io/orange-cloudavenue/{{ .ProjectName }}-admission-controller:v{{ .Version }}-amd64"
- "ghcr.io/orange-cloudavenue/{{ .ProjectName }}-admission-controller:v{{ .Version }}-arm64v8"
- name_template: "ghcr.io/orange-cloudavenue/{{ .ProjectName }}-admission-controller:latest"
image_templates:
- "ghcr.io/orange-cloudavenue/{{ .ProjectName }}-admission-controller:v{{ .Version }}-amd64"
- "ghcr.io/orange-cloudavenue/{{ .ProjectName }}-admission-controller:v{{ .Version }}-arm64v8"
28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,38 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
build: manifests generate fmt vet ## Build manager binary.
go build -o bin/operator cmd/operator/main.go
go build -o bin/kimup cmd/kimup/*
go build -o bin/admission-controller cmd/admission-controller/*

.PHONY: build
build-admission-controller: manifests generate fmt vet
go build -o bin/admission-controller cmd/admission-controller/*

.PHONY: build-kimup
build-kimup: manifests generate fmt vet
go build -o bin/kimup cmd/kimup/*

.PHONY: generate-mutating-config
generate-mutating-config: ## Generate the mutating webhook configuration.
go run ./tools/admission-controller/main.go

.PHONY: run-operator
run-operator: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/operator/main.go

.PHONY: run-operator-in-cluster
run-operator-in-cluster: manifests generate fmt vet ## Run a controller from your host.
kubectl -n kimup-operator delete po kimup-operator || true
kubectl create ns kimup-operator || true
kubectl apply -k manifests/crd
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.16.1/cert-manager.yaml --wait=true
kubectl -n kimup-operator apply --filename="manifests/operator/role.yaml,manifests/operator/role_binding.yaml,manifests/operator/service_account.yaml,manifests/operator/webhook-certificate.yaml,manifests/operator/service.yaml" --wait=true
kubectl wait --for=condition=Available deployment/cert-manager -n cert-manager --timeout=300s
kubectl wait --for=condition=Ready certificate/kimup-webhook-serving-cert -n kimup-operator
kurun apply -f tools/env-dev/pod-operator.yaml
kubectl wait --for=condition=Ready pod/kimup-operator -n kimup-operator
kubectl apply -f tools/env-dev/whoami-deployment.yaml || true
kubectl -n kimup-operator logs kimup-operator -f
kubectl -n kimup-operator delete po kimup-operator

.PHONY: run-kimup
run-kimup: manifests generate fmt vet ## Run the image updater from your host.
go run ./cmd/kimup

.PHONY: run-admission-controller
run-admission-controller: manifests generate fmt vet ## Run the admission-controller from your host.
go run ./cmd/admission-controller/

.PHONY: run-mkdocs
run-mkdocs: ## Run mkdocs to serve the documentation locally.
mkdocs serve
Expand Down
222 changes: 0 additions & 222 deletions cmd/admission-controller/certificate.go

This file was deleted.

Loading

0 comments on commit c9c351b

Please sign in to comment.