Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor admission controller #78

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/59.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:breaking-change
`kimup-admission-controller` - Remove component admission controller. This component is moved to `kimup-operator`, the `kimup-admission-controller` is no longer available.
```

```release-note:feature
`kimup-operator` - Now the `kimup-operator` allow to set scope of the image-tag mutation. The scope can be set to `Namespaced` or `Pod`.
```
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"
29 changes: 20 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,39 @@ 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 get node docker-desktop
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
18 changes: 9 additions & 9 deletions api/v1alpha1/image_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ type (
)

var (
// ImageStatusLastSyncSuccess is the status of the image when it is last sync success.
// Status of the image when it is last sync success.
ImageStatusLastSyncSuccess ImageStatusLastSync = "Success"

// ImageStatusLastSyncScheduled is the status of the image when it is last sync is scheduled.
// Status of the image when it is last sync is scheduled.
ImageStatusLastSyncScheduled ImageStatusLastSync = "Scheduled"

// ImageStatusError is the status of the image when an error occurred.
// Status of the image when an error occurred.
ImageStatusLastSyncError ImageStatusLastSync = "Error"

// ImageStatusLastSyncGetError is the status of the image when it is last sync get error.
// Status of the image when it is last sync get error.
ImageStatusLastSyncErrorGetImage ImageStatusLastSync = "GetImageError"

// ImageStatusLastSyncErrorSecrets is the status of the image when it is last sync error secrets.
// Status of the image when it is last sync error secrets.
ImageStatusLastSyncErrorPullSecrets ImageStatusLastSync = "PullSecretsError"

// ImageStatusLastSyncErrorRegistry is the status of the image when it is last sync error registry.
// Status of the image when it is last sync error registry.
ImageStatusLastSyncErrorRegistry ImageStatusLastSync = "RegistryError"

// ImageStatusLastSyncErrorTags is the status of the image when it is last sync error tags.
// Status of the image when it is last sync error tags.
ImageStatusLastSyncErrorTags ImageStatusLastSync = "TagsError"

// ImageStatusLastSyncErrorGetRule is the status of the image when it is last sync error get rule.
// Status of the image when it is last sync error get rule.
ImageStatusLastSyncErrorGetRule ImageStatusLastSync = "GetRuleError"

// ImageStatusLastSyncErrorAction is the status of the image when it is last sync error action.
// Status of the image when it is last sync error action.
ImageStatusLastSyncErrorAction ImageStatusLastSync = "ActionError"
)
222 changes: 0 additions & 222 deletions cmd/admission-controller/certificate.go

This file was deleted.

Loading
Loading