From b27adf1edc297dd7723998fcf4960929b2b2952d Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 30 Mar 2023 10:20:46 +0200 Subject: [PATCH 1/8] chore: improve CRD docs generation script output (#1157) --- .github/scripts/generate-crd-docs/generate-crd-docs.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/scripts/generate-crd-docs/generate-crd-docs.sh b/.github/scripts/generate-crd-docs/generate-crd-docs.sh index 6efa5f1926..cc2fb02f73 100755 --- a/.github/scripts/generate-crd-docs/generate-crd-docs.sh +++ b/.github/scripts/generate-crd-docs/generate-crd-docs.sh @@ -16,7 +16,12 @@ RENDERER='markdown' RENDERER_CONFIG_FILE='.github/scripts/generate-crd-docs/crd-docs-generator-config.yaml' echo "Checking if code generator tool is installed..." -test -s crd-ref-docs || go install github.com/elastic/crd-ref-docs@${GENERATOR_VERSION} +if ! test -s crd-ref-docs; then + echo "Docs generator is not installed, installing now..." + go install github.com/elastic/crd-ref-docs@${GENERATOR_VERSION} +else + echo "Docs generator is installed, continuing..." +fi echo "Running CRD docs auto-generator..." From 06b10a82fd3e8c942ef7592f919acb60552c4ae4 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 30 Mar 2023 12:45:40 +0200 Subject: [PATCH 2/8] fix: fix examples restart make command, reduce prometheus resources (#1158) --- examples/Makefile | 8 ++++---- .../config/prometheus/alertmanager-alertmanager.yaml | 2 +- .../config/prometheus/prometheus-adapter-deployment.yaml | 2 +- .../config/prometheus/prometheus-prometheus.yaml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 9b9e60ab44..fe918a5c88 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -89,8 +89,8 @@ restart-lifecycle-toolkit: @echo "----------------------------------" @echo "Restart Keptn Lifecycle Controller" @echo "----------------------------------" - kubectl rollout restart deployment -n "$(TOOLKIT_NAMESPACE)" lifecycle-operator - kubectl rollout status deployment -n "$(TOOLKIT_NAMESPACE)" lifecycle-operator --watch - kubectl rollout restart deployment -n "$(TOOLKIT_NAMESPACE)" scheduler -n keptn-lifecycle-toolkit-system - kubectl rollout status deployment -n "$(TOOLKIT_NAMESPACE)" scheduler --watch + kubectl rollout restart deployment -n "$(TOOLKIT_NAMESPACE)" -l control-plane=lifecycle-operator + kubectl rollout status deployment -n "$(TOOLKIT_NAMESPACE)" -l control-plane=lifecycle-operator --watch + kubectl rollout restart deployment -n "$(TOOLKIT_NAMESPACE)" -l component=scheduler + kubectl rollout status deployment -n "$(TOOLKIT_NAMESPACE)" -l component=scheduler --watch diff --git a/examples/support/observability/config/prometheus/alertmanager-alertmanager.yaml b/examples/support/observability/config/prometheus/alertmanager-alertmanager.yaml index 7361532ab5..d29262caba 100644 --- a/examples/support/observability/config/prometheus/alertmanager-alertmanager.yaml +++ b/examples/support/observability/config/prometheus/alertmanager-alertmanager.yaml @@ -20,7 +20,7 @@ spec: app.kubernetes.io/name: alertmanager app.kubernetes.io/part-of: kube-prometheus app.kubernetes.io/version: 0.24.0 - replicas: 3 + replicas: 0 resources: limits: cpu: 100m diff --git a/examples/support/observability/config/prometheus/prometheus-adapter-deployment.yaml b/examples/support/observability/config/prometheus/prometheus-adapter-deployment.yaml index fcfdf35629..01bd7e992c 100644 --- a/examples/support/observability/config/prometheus/prometheus-adapter-deployment.yaml +++ b/examples/support/observability/config/prometheus/prometheus-adapter-deployment.yaml @@ -9,7 +9,7 @@ metadata: name: prometheus-adapter namespace: monitoring spec: - replicas: 2 + replicas: 1 selector: matchLabels: app.kubernetes.io/component: metrics-adapter diff --git a/examples/support/observability/config/prometheus/prometheus-prometheus.yaml b/examples/support/observability/config/prometheus/prometheus-prometheus.yaml index 789fbd42ab..dff6d8e376 100644 --- a/examples/support/observability/config/prometheus/prometheus-prometheus.yaml +++ b/examples/support/observability/config/prometheus/prometheus-prometheus.yaml @@ -32,7 +32,7 @@ spec: podMonitorSelector: {} probeNamespaceSelector: {} probeSelector: {} - replicas: 2 + replicas: 1 resources: requests: memory: 400Mi From 9890213a643aac0977f677ac181d1d39e77fa5b5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 Mar 2023 08:45:44 +0200 Subject: [PATCH 3/8] deps: update dependency jaegertracing/jaeger-operator to v1.43.0 (#1152) Signed-off-by: Renovate Bot Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com> --- examples/Makefile | 2 +- examples/support/observability/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index fe918a5c88..62ca06c7b0 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,5 +1,5 @@ # renovate: datasource=github-tags depName=jaegertracing/jaeger-operator -JAEGER_VERSION ?= v1.42.0 +JAEGER_VERSION ?= v1.43.0 TOOLKIT_NAMESPACE ?= keptn-lifecycle-toolkit-system PODTATO_NAMESPACE ?= podtato-kubectl GRAFANA_PORT_FORWARD ?= 3000 diff --git a/examples/support/observability/Makefile b/examples/support/observability/Makefile index e374b16166..1b219fc956 100644 --- a/examples/support/observability/Makefile +++ b/examples/support/observability/Makefile @@ -1,5 +1,5 @@ # renovate: datasource=github-tags depName=jaegertracing/jaeger-operator -JAEGER_VERSION ?= v1.42.0 +JAEGER_VERSION ?= v1.43.0 TOOLKIT_NAMESPACE ?= keptn-lifecycle-toolkit-system PODTATO_NAMESPACE ?= podtato-kubectl GRAFANA_PORT_FORWARD ?= 3000 From 1071f0297b59bbd3a755e0a21c8e894bbfde1907 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 Mar 2023 08:47:29 +0200 Subject: [PATCH 4/8] deps: update dependency golangci/golangci-lint to v1.52.2 (#1142) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index a6c06fdca4..7ada776d21 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -17,7 +17,7 @@ on: - "!docs/**" env: # renovate: datasource=github-releases depName=golangci/golangci-lint - GOLANGCI_LINT_VERSION: "v1.52.1" + GOLANGCI_LINT_VERSION: "v1.52.2" GO_VERSION: "~1.19" jobs: golangci-lint: From c1ecfd03e39fc72f8304c78f80e71941aa0162e9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 Mar 2023 08:47:40 +0200 Subject: [PATCH 5/8] deps: update module github.com/go-logr/logr to v1.2.4 (#1153) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- klt-cert-manager/go.mod | 2 +- klt-cert-manager/go.sum | 4 ++-- metrics-operator/go.mod | 2 +- metrics-operator/go.sum | 4 ++-- operator/go.mod | 2 +- operator/go.sum | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/klt-cert-manager/go.mod b/klt-cert-manager/go.mod index 941207510c..fccf226924 100644 --- a/klt-cert-manager/go.mod +++ b/klt-cert-manager/go.mod @@ -3,7 +3,7 @@ module github.com/keptn/lifecycle-toolkit/klt-cert-manager go 1.19 require ( - github.com/go-logr/logr v1.2.3 + github.com/go-logr/logr v1.2.4 github.com/kelseyhightower/envconfig v1.4.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.8.2 diff --git a/klt-cert-manager/go.sum b/klt-cert-manager/go.sum index 08b675fd10..25b6707e02 100644 --- a/klt-cert-manager/go.sum +++ b/klt-cert-manager/go.sum @@ -84,8 +84,8 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= diff --git a/metrics-operator/go.mod b/metrics-operator/go.mod index 34f6ce843b..cf744ed95b 100644 --- a/metrics-operator/go.mod +++ b/metrics-operator/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( github.com/DataDog/datadog-api-client-go/v2 v2.11.0 github.com/benbjohnson/clock v1.3.0 - github.com/go-logr/logr v1.2.3 + github.com/go-logr/logr v1.2.4 github.com/gorilla/mux v1.8.0 github.com/kelseyhightower/envconfig v1.4.0 github.com/open-feature/go-sdk v1.3.0 diff --git a/metrics-operator/go.sum b/metrics-operator/go.sum index d84abf64be..e317a28a27 100644 --- a/metrics-operator/go.sum +++ b/metrics-operator/go.sum @@ -132,8 +132,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= diff --git a/operator/go.mod b/operator/go.mod index adc9d62e32..e8aca7b69b 100644 --- a/operator/go.mod +++ b/operator/go.mod @@ -3,7 +3,7 @@ module github.com/keptn/lifecycle-toolkit/operator go 1.19 require ( - github.com/go-logr/logr v1.2.3 + github.com/go-logr/logr v1.2.4 github.com/hashicorp/go-version v1.6.0 github.com/imdario/mergo v0.3.15 github.com/kelseyhightower/envconfig v1.4.0 diff --git a/operator/go.sum b/operator/go.sum index b2a75707b7..207ca22641 100644 --- a/operator/go.sum +++ b/operator/go.sum @@ -92,8 +92,8 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= From 5f0071d114e28863192427e33ac5daa412418995 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 Mar 2023 08:47:53 +0200 Subject: [PATCH 6/8] deps: update module sigs.k8s.io/controller-runtime to v0.14.6 (#1160) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- klt-cert-manager/go.mod | 2 +- klt-cert-manager/go.sum | 4 ++-- metrics-operator/go.mod | 2 +- metrics-operator/go.sum | 4 ++-- operator/go.mod | 2 +- operator/go.sum | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/klt-cert-manager/go.mod b/klt-cert-manager/go.mod index fccf226924..f486604c8a 100644 --- a/klt-cert-manager/go.mod +++ b/klt-cert-manager/go.mod @@ -11,7 +11,7 @@ require ( k8s.io/apiextensions-apiserver v0.26.3 k8s.io/apimachinery v0.26.3 k8s.io/client-go v0.26.3 - sigs.k8s.io/controller-runtime v0.14.5 + sigs.k8s.io/controller-runtime v0.14.6 ) require ( diff --git a/klt-cert-manager/go.sum b/klt-cert-manager/go.sum index 25b6707e02..b87ca40611 100644 --- a/klt-cert-manager/go.sum +++ b/klt-cert-manager/go.sum @@ -612,8 +612,8 @@ k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/controller-runtime v0.14.5 h1:6xaWFqzT5KuAQ9ufgUaj1G/+C4Y1GRkhrxl+BJ9i+5s= -sigs.k8s.io/controller-runtime v0.14.5/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= +sigs.k8s.io/controller-runtime v0.14.6 h1:oxstGVvXGNnMvY7TAESYk+lzr6S3V5VFxQ6d92KcwQA= +sigs.k8s.io/controller-runtime v0.14.6/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= diff --git a/metrics-operator/go.mod b/metrics-operator/go.mod index cf744ed95b..5c75fecb1a 100644 --- a/metrics-operator/go.mod +++ b/metrics-operator/go.mod @@ -22,7 +22,7 @@ require ( k8s.io/component-base v0.26.3 k8s.io/klog/v2 v2.90.1 k8s.io/metrics v0.26.3 - sigs.k8s.io/controller-runtime v0.14.5 + sigs.k8s.io/controller-runtime v0.14.6 sigs.k8s.io/custom-metrics-apiserver v1.25.1-0.20230116101851-63817c8ac8f2 ) diff --git a/metrics-operator/go.sum b/metrics-operator/go.sum index e317a28a27..5c14171bcf 100644 --- a/metrics-operator/go.sum +++ b/metrics-operator/go.sum @@ -819,8 +819,8 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.36 h1:PUuX1qIFv309AT8hF/CdPKDmsG/hn/L8zRX7VvISM3A= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.36/go.mod h1:WxjusMwXlKzfAs4p9km6XJRndVt2FROgMVCE4cdohFo= -sigs.k8s.io/controller-runtime v0.14.5 h1:6xaWFqzT5KuAQ9ufgUaj1G/+C4Y1GRkhrxl+BJ9i+5s= -sigs.k8s.io/controller-runtime v0.14.5/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= +sigs.k8s.io/controller-runtime v0.14.6 h1:oxstGVvXGNnMvY7TAESYk+lzr6S3V5VFxQ6d92KcwQA= +sigs.k8s.io/controller-runtime v0.14.6/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= sigs.k8s.io/custom-metrics-apiserver v1.25.1-0.20230116101851-63817c8ac8f2 h1:D49r2VoxIdm3s1yVoCMbHrLH0qxDj5TiaWB0XYdqgcI= sigs.k8s.io/custom-metrics-apiserver v1.25.1-0.20230116101851-63817c8ac8f2/go.mod h1:D1ZXB9iOdI97WAE3G1kjlwUhwEnGfpq4af3drpEYVlI= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= diff --git a/operator/go.mod b/operator/go.mod index e8aca7b69b..294bda4008 100644 --- a/operator/go.mod +++ b/operator/go.mod @@ -29,7 +29,7 @@ require ( k8s.io/apimachinery v0.26.3 k8s.io/apiserver v0.26.3 k8s.io/client-go v0.26.3 - sigs.k8s.io/controller-runtime v0.14.5 + sigs.k8s.io/controller-runtime v0.14.6 ) require ( diff --git a/operator/go.sum b/operator/go.sum index 207ca22641..92f19df47c 100644 --- a/operator/go.sum +++ b/operator/go.sum @@ -682,8 +682,8 @@ k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/controller-runtime v0.14.5 h1:6xaWFqzT5KuAQ9ufgUaj1G/+C4Y1GRkhrxl+BJ9i+5s= -sigs.k8s.io/controller-runtime v0.14.5/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= +sigs.k8s.io/controller-runtime v0.14.6 h1:oxstGVvXGNnMvY7TAESYk+lzr6S3V5VFxQ6d92KcwQA= +sigs.k8s.io/controller-runtime v0.14.6/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= From 6b58da3c907af591633052ba3d7fc49a2b801ebc Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Fri, 31 Mar 2023 09:57:49 +0200 Subject: [PATCH 7/8] feat(operator): bootstrapped KeptnAppCreationRequest CRD (#1134) Signed-off-by: Florian Bacher --- .../docs/crd-ref/lifecycle/v1alpha3/_index.md | 51 +++++++++++ helm/chart/README.md | 1 + helm/chart/doc.yaml | 1 + helm/chart/values.yaml | 1 + operator/PROJECT | 9 ++ .../v1alpha3/keptnappcreationrequest_types.go | 61 +++++++++++++ .../v1alpha3/zz_generated.deepcopy.go | 89 +++++++++++++++++++ ...cle.keptn.sh_keptnappcreationrequests.yaml | 55 ++++++++++++ operator/config/crd/kustomization.yaml | 2 + ...in_lifecycle_keptnappcreationrequests.yaml | 16 ++++ operator/config/manager/manager.yaml | 2 + ...e_keptnappcreationrequest_editor_role.yaml | 31 +++++++ ...e_keptnappcreationrequest_viewer_role.yaml | 27 ++++++ operator/config/rbac/role.yaml | 26 ++++++ ...ycle_v1alpha3_keptnappcreationrequest.yaml | 12 +++ .../keptnappcreationrequest/controller.go | 57 ++++++++++++ .../controller_test.go | 49 ++++++++++ operator/main.go | 29 ++++-- .../app-creation-request/00-assert.yaml | 6 ++ .../app-creation-request/00-install.yaml | 6 ++ 20 files changed, 523 insertions(+), 8 deletions(-) create mode 100644 operator/apis/lifecycle/v1alpha3/keptnappcreationrequest_types.go create mode 100644 operator/config/crd/bases/lifecycle.keptn.sh_keptnappcreationrequests.yaml create mode 100644 operator/config/crd/patches/webhook_in_lifecycle_keptnappcreationrequests.yaml create mode 100644 operator/config/rbac/lifecycle_keptnappcreationrequest_editor_role.yaml create mode 100644 operator/config/rbac/lifecycle_keptnappcreationrequest_viewer_role.yaml create mode 100644 operator/config/samples/lifecycle_v1alpha3_keptnappcreationrequest.yaml create mode 100644 operator/controllers/lifecycle/keptnappcreationrequest/controller.go create mode 100644 operator/controllers/lifecycle/keptnappcreationrequest/controller_test.go create mode 100644 test/integration/app-creation-request/00-assert.yaml create mode 100644 test/integration/app-creation-request/00-install.yaml diff --git a/docs/content/en/docs/crd-ref/lifecycle/v1alpha3/_index.md b/docs/content/en/docs/crd-ref/lifecycle/v1alpha3/_index.md index ad2f234e3a..271e40457e 100644 --- a/docs/content/en/docs/crd-ref/lifecycle/v1alpha3/_index.md +++ b/docs/content/en/docs/crd-ref/lifecycle/v1alpha3/_index.md @@ -14,6 +14,8 @@ Package v1alpha3 contains API Schema definitions for the lifecycle v1alpha3 API ### Resource Types - [KeptnApp](#keptnapp) +- [KeptnAppCreationRequest](#keptnappcreationrequest) +- [KeptnAppCreationRequestList](#keptnappcreationrequestlist) - [KeptnAppList](#keptnapplist) - [KeptnAppVersion](#keptnappversion) - [KeptnAppVersionList](#keptnappversionlist) @@ -175,6 +177,55 @@ _Appears in:_ | `spec` _[KeptnAppSpec](#keptnappspec)_ | | +#### KeptnAppCreationRequest + + + +KeptnAppCreationRequest is the Schema for the keptnappcreationrequests API + +_Appears in:_ +- [KeptnAppCreationRequestList](#keptnappcreationrequestlist) + +| Field | Description | +| --- | --- | +| `apiVersion` _string_ | `lifecycle.keptn.sh/v1alpha3` +| `kind` _string_ | `KeptnAppCreationRequest` +| `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | +| `spec` _[KeptnAppCreationRequestSpec](#keptnappcreationrequestspec)_ | | + + +#### KeptnAppCreationRequestList + + + +KeptnAppCreationRequestList contains a list of KeptnAppCreationRequest + + + +| Field | Description | +| --- | --- | +| `apiVersion` _string_ | `lifecycle.keptn.sh/v1alpha3` +| `kind` _string_ | `KeptnAppCreationRequestList` +| `metadata` _[ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#listmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | +| `items` _[KeptnAppCreationRequest](#keptnappcreationrequest) array_ | | + + +#### KeptnAppCreationRequestSpec + + + +KeptnAppCreationRequestSpec defines the desired state of KeptnAppCreationRequest + +_Appears in:_ +- [KeptnAppCreationRequest](#keptnappcreationrequest) + +| Field | Description | +| --- | --- | +| `appName` _string_ | AppName is the name of the KeptnApp the KeptnAppCreationRequest should create if no user-defined object with that name is found. | + + + + #### KeptnAppList diff --git a/helm/chart/README.md b/helm/chart/README.md index f459266109..aa4d068a84 100644 --- a/helm/chart/README.md +++ b/helm/chart/README.md @@ -80,6 +80,7 @@ checks | `lifecycleOperator.manager.containerSecurityContext.runAsUser` | | `65532` | | `lifecycleOperator.manager.containerSecurityContext.seccompProfile.type` | | `RuntimeDefault` | | `lifecycleOperator.manager.env.keptnAppControllerLogLevel` | sets the log level of Keptn App Controller | `0` | +| `lifecycleOperator.manager.env.keptnAppCreationRequestControllerLogLevel` | sets the log level of Keptn App Creation Request Controller | `0` | | `lifecycleOperator.manager.env.keptnAppVersionControllerLogLevel` | sets the log level of Keptn AppVersion Controller | `0` | | `lifecycleOperator.manager.env.keptnEvaluationControllerLogLevel` | sets the log level of Keptn Evaluation Controller | `0` | | `lifecycleOperator.manager.env.keptnTaskControllerLogLevel` | sets the log level of Keptn Task Controller | `0` | diff --git a/helm/chart/doc.yaml b/helm/chart/doc.yaml index 21ffc56149..11687c8b15 100644 --- a/helm/chart/doc.yaml +++ b/helm/chart/doc.yaml @@ -118,6 +118,7 @@ ## @param lifecycleOperator.manager.containerSecurityContext.seccompProfile.type ## @param lifecycleOperator.manager.env.keptnAppControllerLogLevel sets the log level of Keptn App Controller +## @param lifecycleOperator.manager.env.keptnAppCreationRequestControllerLogLevel sets the log level of Keptn App Creation Request Controller ## @param lifecycleOperator.manager.env.keptnAppVersionControllerLogLevel sets the log level of Keptn AppVersion Controller ## @param lifecycleOperator.manager.env.keptnEvaluationControllerLogLevel sets the log level of Keptn Evaluation Controller ## @param lifecycleOperator.manager.env.keptnTaskControllerLogLevel sets the log level of Keptn Task Controller diff --git a/helm/chart/values.yaml b/helm/chart/values.yaml index 32a4dedbd5..01e663f335 100644 --- a/helm/chart/values.yaml +++ b/helm/chart/values.yaml @@ -66,6 +66,7 @@ lifecycleOperator: env: functionRunnerImage: ghcr.keptn.sh/keptn/functions-runtime:v0.7.0 keptnAppControllerLogLevel: "0" + keptnAppCreationRequestControllerLogLevel: "0" keptnAppVersionControllerLogLevel: "0" keptnEvaluationControllerLogLevel: "0" keptnTaskControllerLogLevel: "0" diff --git a/operator/PROJECT b/operator/PROJECT index 6c3ec1efaf..5e2a1e5003 100644 --- a/operator/PROJECT +++ b/operator/PROJECT @@ -258,4 +258,13 @@ resources: kind: KeptnEvaluationProvider path: github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3 version: v1alpha3 +- api: + crdVersion: v1 + namespaced: true + controller: true + domain: keptn.sh + group: lifecycle + kind: KeptnAppCreationRequest + path: github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3 + version: v1alpha3 version: "3" diff --git a/operator/apis/lifecycle/v1alpha3/keptnappcreationrequest_types.go b/operator/apis/lifecycle/v1alpha3/keptnappcreationrequest_types.go new file mode 100644 index 0000000000..4eb0811844 --- /dev/null +++ b/operator/apis/lifecycle/v1alpha3/keptnappcreationrequest_types.go @@ -0,0 +1,61 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha3 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// KeptnAppCreationRequestSpec defines the desired state of KeptnAppCreationRequest +type KeptnAppCreationRequestSpec struct { + // AppName is the name of the KeptnApp the KeptnAppCreationRequest should create if no user-defined object with that name is found. + AppName string `json:"appName"` +} + +// KeptnAppCreationRequestStatus defines the observed state of KeptnAppCreationRequest +type KeptnAppCreationRequestStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status + +// KeptnAppCreationRequest is the Schema for the keptnappcreationrequests API +type KeptnAppCreationRequest struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec KeptnAppCreationRequestSpec `json:"spec,omitempty"` + Status KeptnAppCreationRequestStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// KeptnAppCreationRequestList contains a list of KeptnAppCreationRequest +type KeptnAppCreationRequestList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []KeptnAppCreationRequest `json:"items"` +} + +func init() { + SchemeBuilder.Register(&KeptnAppCreationRequest{}, &KeptnAppCreationRequestList{}) +} diff --git a/operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go b/operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go index 4d6c1ecc81..7ee7cd41e2 100644 --- a/operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go +++ b/operator/apis/lifecycle/v1alpha3/zz_generated.deepcopy.go @@ -197,6 +197,95 @@ func (in *KeptnApp) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KeptnAppCreationRequest) DeepCopyInto(out *KeptnAppCreationRequest) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeptnAppCreationRequest. +func (in *KeptnAppCreationRequest) DeepCopy() *KeptnAppCreationRequest { + if in == nil { + return nil + } + out := new(KeptnAppCreationRequest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KeptnAppCreationRequest) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KeptnAppCreationRequestList) DeepCopyInto(out *KeptnAppCreationRequestList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KeptnAppCreationRequest, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeptnAppCreationRequestList. +func (in *KeptnAppCreationRequestList) DeepCopy() *KeptnAppCreationRequestList { + if in == nil { + return nil + } + out := new(KeptnAppCreationRequestList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KeptnAppCreationRequestList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KeptnAppCreationRequestSpec) DeepCopyInto(out *KeptnAppCreationRequestSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeptnAppCreationRequestSpec. +func (in *KeptnAppCreationRequestSpec) DeepCopy() *KeptnAppCreationRequestSpec { + if in == nil { + return nil + } + out := new(KeptnAppCreationRequestSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KeptnAppCreationRequestStatus) DeepCopyInto(out *KeptnAppCreationRequestStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeptnAppCreationRequestStatus. +func (in *KeptnAppCreationRequestStatus) DeepCopy() *KeptnAppCreationRequestStatus { + if in == nil { + return nil + } + out := new(KeptnAppCreationRequestStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KeptnAppList) DeepCopyInto(out *KeptnAppList) { *out = *in diff --git a/operator/config/crd/bases/lifecycle.keptn.sh_keptnappcreationrequests.yaml b/operator/config/crd/bases/lifecycle.keptn.sh_keptnappcreationrequests.yaml new file mode 100644 index 0000000000..c0930ef75a --- /dev/null +++ b/operator/config/crd/bases/lifecycle.keptn.sh_keptnappcreationrequests.yaml @@ -0,0 +1,55 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.11.3 + creationTimestamp: null + name: keptnappcreationrequests.lifecycle.keptn.sh +spec: + group: lifecycle.keptn.sh + names: + kind: KeptnAppCreationRequest + listKind: KeptnAppCreationRequestList + plural: keptnappcreationrequests + singular: keptnappcreationrequest + scope: Namespaced + versions: + - name: v1alpha3 + schema: + openAPIV3Schema: + description: KeptnAppCreationRequest is the Schema for the keptnappcreationrequests + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: KeptnAppCreationRequestSpec defines the desired state of + KeptnAppCreationRequest + properties: + appName: + description: AppName is the name of the KeptnApp the KeptnAppCreationRequest + should create if no user-defined object with that name is found. + type: string + required: + - appName + type: object + status: + description: KeptnAppCreationRequestStatus defines the observed state + of KeptnAppCreationRequest + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/operator/config/crd/kustomization.yaml b/operator/config/crd/kustomization.yaml index d8607bd6e4..a7c0b7e0b8 100644 --- a/operator/config/crd/kustomization.yaml +++ b/operator/config/crd/kustomization.yaml @@ -12,6 +12,7 @@ resources: - bases/lifecycle.keptn.sh_keptnevaluationproviders.yaml - bases/lifecycle.keptn.sh_keptnevaluations.yaml - bases/options.keptn.sh_keptnconfigs.yaml +- bases/lifecycle.keptn.sh_keptnappcreationrequests.yaml #+kubebuilder:scaffold:crdkustomizeresource patchesStrategicMerge: @@ -31,6 +32,7 @@ patchesStrategicMerge: #- patches/webhook_in_lifecycle_keptnappversions.yaml #- patches/webhook_in_lifecycle_keptnworkloadinstances.yaml #- patches/webhook_in_lifecycle_keptnevaluationproviders.yaml +#- patches/webhook_in_keptnappcreationrequests.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/operator/config/crd/patches/webhook_in_lifecycle_keptnappcreationrequests.yaml b/operator/config/crd/patches/webhook_in_lifecycle_keptnappcreationrequests.yaml new file mode 100644 index 0000000000..fb68a5908b --- /dev/null +++ b/operator/config/crd/patches/webhook_in_lifecycle_keptnappcreationrequests.yaml @@ -0,0 +1,16 @@ +# The following patch enables a conversion webhook for the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: keptnappcreationrequests.lifecycle.keptn.sh +spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + namespace: system + name: webhook-service + path: /convert + conversionReviewVersions: + - v1 diff --git a/operator/config/manager/manager.yaml b/operator/config/manager/manager.yaml index 24b5b52f79..ff2a30393f 100644 --- a/operator/config/manager/manager.yaml +++ b/operator/config/manager/manager.yaml @@ -73,6 +73,8 @@ spec: value: otel-collector:4317 - name: KEPTN_APP_CONTROLLER_LOG_LEVEL value: "0" + - name: KEPTN_APP_CREATION_REQUEST_CONTROLLER_LOG_LEVEL + value: "0" - name: KEPTN_APP_VERSION_CONTROLLER_LOG_LEVEL value: "0" - name: KEPTN_EVALUATION_CONTROLLER_LOG_LEVEL diff --git a/operator/config/rbac/lifecycle_keptnappcreationrequest_editor_role.yaml b/operator/config/rbac/lifecycle_keptnappcreationrequest_editor_role.yaml new file mode 100644 index 0000000000..675405d4a9 --- /dev/null +++ b/operator/config/rbac/lifecycle_keptnappcreationrequest_editor_role.yaml @@ -0,0 +1,31 @@ +# permissions for end users to edit keptnappcreationrequests. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: keptnappcreationrequest-editor-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: keptn-lifecycle-toolkit + app.kubernetes.io/part-of: keptn-lifecycle-toolkit + app.kubernetes.io/managed-by: kustomize + name: keptnappcreationrequest-editor-role +rules: +- apiGroups: + - lifecycle.keptn.sh + resources: + - keptnappcreationrequests + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - lifecycle.keptn.sh + resources: + - keptnappcreationrequests/status + verbs: + - get diff --git a/operator/config/rbac/lifecycle_keptnappcreationrequest_viewer_role.yaml b/operator/config/rbac/lifecycle_keptnappcreationrequest_viewer_role.yaml new file mode 100644 index 0000000000..5e01a264eb --- /dev/null +++ b/operator/config/rbac/lifecycle_keptnappcreationrequest_viewer_role.yaml @@ -0,0 +1,27 @@ +# permissions for end users to view keptnappcreationrequests. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: keptnappcreationrequest-viewer-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: keptn-lifecycle-toolkit + app.kubernetes.io/part-of: keptn-lifecycle-toolkit + app.kubernetes.io/managed-by: kustomize + name: keptnappcreationrequest-viewer-role +rules: +- apiGroups: + - lifecycle.keptn.sh + resources: + - keptnappcreationrequests + verbs: + - get + - list + - watch +- apiGroups: + - lifecycle.keptn.sh + resources: + - keptnappcreationrequests/status + verbs: + - get diff --git a/operator/config/rbac/role.yaml b/operator/config/rbac/role.yaml index 58f727d947..9deb085059 100644 --- a/operator/config/rbac/role.yaml +++ b/operator/config/rbac/role.yaml @@ -85,6 +85,32 @@ rules: - secrets verbs: - get +- apiGroups: + - lifecycle.keptn.sh + resources: + - keptnappcreationrequests + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - lifecycle.keptn.sh + resources: + - keptnappcreationrequests/finalizers + verbs: + - update +- apiGroups: + - lifecycle.keptn.sh + resources: + - keptnappcreationrequests/status + verbs: + - get + - patch + - update - apiGroups: - lifecycle.keptn.sh resources: diff --git a/operator/config/samples/lifecycle_v1alpha3_keptnappcreationrequest.yaml b/operator/config/samples/lifecycle_v1alpha3_keptnappcreationrequest.yaml new file mode 100644 index 0000000000..3bda2955d9 --- /dev/null +++ b/operator/config/samples/lifecycle_v1alpha3_keptnappcreationrequest.yaml @@ -0,0 +1,12 @@ +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnAppCreationRequest +metadata: + labels: + app.kubernetes.io/name: keptnappcreationrequest + app.kubernetes.io/instance: keptnappcreationrequest-sample + app.kubernetes.io/part-of: keptn-lifecycle-toolkit + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/created-by: keptn-lifecycle-toolkit + name: keptnappcreationrequest-sample +spec: + appName: my-app diff --git a/operator/controllers/lifecycle/keptnappcreationrequest/controller.go b/operator/controllers/lifecycle/keptnappcreationrequest/controller.go new file mode 100644 index 0000000000..e8d9fcab6b --- /dev/null +++ b/operator/controllers/lifecycle/keptnappcreationrequest/controller.go @@ -0,0 +1,57 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package keptnappcreationrequest + +import ( + "context" + + "github.com/go-logr/logr" + lifecyclev1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" + "k8s.io/apimachinery/pkg/runtime" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// KeptnAppCreationRequestReconciler reconciles a KeptnAppCreationRequest object +type KeptnAppCreationRequestReconciler struct { + client.Client + Scheme *runtime.Scheme + Log logr.Logger +} + +//+kubebuilder:rbac:groups=lifecycle.keptn.sh,resources=keptnappcreationrequests,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=lifecycle.keptn.sh,resources=keptnappcreationrequests/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=lifecycle.keptn.sh,resources=keptnappcreationrequests/finalizers,verbs=update + +// Reconcile is part of the main kubernetes reconciliation loop which aims to +// move the current state of the cluster closer to the desired state. +// the KeptnAppCreationRequest object against the actual cluster state, and then +// perform operations to make the cluster state reflect the state specified by +// the user. +// +// For more details, check Reconcile and its Result here: +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.1/pkg/reconcile +func (r *KeptnAppCreationRequestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + return ctrl.Result{}, nil +} + +// SetupWithManager sets up the controller with the Manager. +func (r *KeptnAppCreationRequestReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&lifecyclev1alpha3.KeptnAppCreationRequest{}). + Complete(r) +} diff --git a/operator/controllers/lifecycle/keptnappcreationrequest/controller_test.go b/operator/controllers/lifecycle/keptnappcreationrequest/controller_test.go new file mode 100644 index 0000000000..1a980c1890 --- /dev/null +++ b/operator/controllers/lifecycle/keptnappcreationrequest/controller_test.go @@ -0,0 +1,49 @@ +package keptnappcreationrequest + +import ( + "context" + "testing" + + "github.com/go-logr/logr" + klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" + "github.com/stretchr/testify/require" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + controllerruntime "sigs.k8s.io/controller-runtime" + k8sfake "sigs.k8s.io/controller-runtime/pkg/client/fake" +) + +func TestKeptnAppCreationRequestReconciler_Reconcile(t *testing.T) { + fakeClient := k8sfake.NewClientBuilder().WithObjects().Build() + + err := klcv1alpha3.AddToScheme(fakeClient.Scheme()) + require.Nil(t, err) + + kacr := &klcv1alpha3.KeptnAppCreationRequest{ + ObjectMeta: metav1.ObjectMeta{ + Name: "my-kacr", + Namespace: "my-namespace", + }, + Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ + AppName: "my-app", + }, + } + + err = fakeClient.Create(context.TODO(), kacr) + require.Nil(t, err) + + r := &KeptnAppCreationRequestReconciler{ + Client: fakeClient, + Scheme: fakeClient.Scheme(), + Log: logr.Logger{}, + } + + _, err = r.Reconcile(context.Background(), controllerruntime.Request{ + NamespacedName: types.NamespacedName{ + Namespace: kacr.Namespace, + Name: kacr.Name, + }, + }) + + require.Nil(t, err) +} diff --git a/operator/main.go b/operator/main.go index cdd6d104b2..d11dc1b427 100644 --- a/operator/main.go +++ b/operator/main.go @@ -33,6 +33,7 @@ import ( "github.com/keptn/lifecycle-toolkit/operator/cmd/webhook" controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common" "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnapp" + "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnappcreationrequest" "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnappversion" "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnevaluation" "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptntask" @@ -72,14 +73,15 @@ type envConfig struct { PodNamespace string `envconfig:"POD_NAMESPACE" default:""` PodName string `envconfig:"POD_NAME" default:""` - KeptnAppControllerLogLevel int `envconfig:"KEPTN_APP_CONTROLLER_LOG_LEVEL" default:"0"` - KeptnAppVersionControllerLogLevel int `envconfig:"KEPTN_APP_VERSION_CONTROLLER_LOG_LEVEL" default:"0"` - KeptnEvaluationControllerLogLevel int `envconfig:"KEPTN_EVALUATION_CONTROLLER_LOG_LEVEL" default:"0"` - KeptnTaskControllerLogLevel int `envconfig:"KEPTN_TASK_CONTROLLER_LOG_LEVEL" default:"0"` - KeptnTaskDefinitionControllerLogLevel int `envconfig:"KEPTN_TASK_DEFINITION_CONTROLLER_LOG_LEVEL" default:"0"` - KeptnWorkloadControllerLogLevel int `envconfig:"KEPTN_WORKLOAD_CONTROLLER_LOG_LEVEL" default:"0"` - KeptnWorkloadInstanceControllerLogLevel int `envconfig:"KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL" default:"0"` - KeptnOptionsControllerLogLevel int `envconfig:"OPTIONS_CONTROLLER_LOG_LEVEL" default:"0"` + KeptnAppControllerLogLevel int `envconfig:"KEPTN_APP_CONTROLLER_LOG_LEVEL" default:"0"` + KeptnAppCreationRequestControllerLogLevel int `envconfig:"KEPTN_APP_CREATION_REQUEST_CONTROLLER_LOG_LEVEL" default:"0"` + KeptnAppVersionControllerLogLevel int `envconfig:"KEPTN_APP_VERSION_CONTROLLER_LOG_LEVEL" default:"0"` + KeptnEvaluationControllerLogLevel int `envconfig:"KEPTN_EVALUATION_CONTROLLER_LOG_LEVEL" default:"0"` + KeptnTaskControllerLogLevel int `envconfig:"KEPTN_TASK_CONTROLLER_LOG_LEVEL" default:"0"` + KeptnTaskDefinitionControllerLogLevel int `envconfig:"KEPTN_TASK_DEFINITION_CONTROLLER_LOG_LEVEL" default:"0"` + KeptnWorkloadControllerLogLevel int `envconfig:"KEPTN_WORKLOAD_CONTROLLER_LOG_LEVEL" default:"0"` + KeptnWorkloadInstanceControllerLogLevel int `envconfig:"KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL" default:"0"` + KeptnOptionsControllerLogLevel int `envconfig:"OPTIONS_CONTROLLER_LOG_LEVEL" default:"0"` KeptnOptionsCollectorURL string `envconfig:"OTEL_COLLECTOR_URL" default:""` } @@ -201,6 +203,17 @@ func main() { os.Exit(1) } + appCreationRequestLogger := ctrl.Log.WithName("KeptnAppCreationRequest Controller") + appCreationRequestReconciler := &keptnappcreationrequest.KeptnAppCreationRequestReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Log: appCreationRequestLogger.V(env.KeptnAppCreationRequestControllerLogLevel), + } + if err := appCreationRequestReconciler.SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "KeptnAppCreationRequest") + os.Exit(1) + } + workloadLogger := ctrl.Log.WithName("KeptnWorkload Controller") workloadReconciler := &keptnworkload.KeptnWorkloadReconciler{ Client: mgr.GetClient(), diff --git a/test/integration/app-creation-request/00-assert.yaml b/test/integration/app-creation-request/00-assert.yaml new file mode 100644 index 0000000000..3bb778d462 --- /dev/null +++ b/test/integration/app-creation-request/00-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnAppCreationRequest +metadata: + name: my-kacr +spec: + appName: my-app diff --git a/test/integration/app-creation-request/00-install.yaml b/test/integration/app-creation-request/00-install.yaml new file mode 100644 index 0000000000..3bb778d462 --- /dev/null +++ b/test/integration/app-creation-request/00-install.yaml @@ -0,0 +1,6 @@ +apiVersion: lifecycle.keptn.sh/v1alpha3 +kind: KeptnAppCreationRequest +metadata: + name: my-kacr +spec: + appName: my-app From 385905913f867c88482e5b1a40643a8957a8e022 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 Mar 2023 12:17:11 +0200 Subject: [PATCH 8/8] deps: update github.com/keptn/lifecycle-toolkit/metrics-operator digest to 6b58da3 (#1141) Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- operator/go.mod | 6 +++--- operator/go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/operator/go.mod b/operator/go.mod index 294bda4008..a41020d00e 100644 --- a/operator/go.mod +++ b/operator/go.mod @@ -7,7 +7,7 @@ require ( github.com/hashicorp/go-version v1.6.0 github.com/imdario/mergo v0.3.15 github.com/kelseyhightower/envconfig v1.4.0 - github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230327141700-f5fb9ead9a53 + github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230331075749-6b58da3c907a github.com/magiconair/properties v1.8.7 github.com/onsi/ginkgo/v2 v2.9.2 github.com/onsi/gomega v1.27.5 @@ -33,10 +33,10 @@ require ( ) require ( - github.com/prometheus/common v0.40.0 // indirect + github.com/prometheus/common v0.42.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/net v0.8.0 // indirect - golang.org/x/oauth2 v0.4.0 // indirect + golang.org/x/oauth2 v0.5.0 // indirect golang.org/x/sys v0.6.0 // indirect golang.org/x/term v0.6.0 // indirect golang.org/x/text v0.8.0 // indirect diff --git a/operator/go.sum b/operator/go.sum index 92f19df47c..6e1b27550f 100644 --- a/operator/go.sum +++ b/operator/go.sum @@ -205,8 +205,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= -github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230327141700-f5fb9ead9a53 h1:R93KBGUIXb9GNWnxC4H2KxP1BocY9UAcu2Q/TH8C/4g= -github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230327141700-f5fb9ead9a53/go.mod h1:Qxao25jY8CYbTvtUQLkiUj4ianjxdH4qUGkAyJRda34= +github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230331075749-6b58da3c907a h1:j90xB4wUJdTMDZeP1u8GPmqJmstQc3wLTgtlPwAALZQ= +github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230331075749-6b58da3c907a/go.mod h1:8rQ1flqblBWy43k4xJnoaMUA7e50zP95QIab3z6NCw4= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -246,8 +246,8 @@ github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQg github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.40.0 h1:Afz7EVRqGg2Mqqf4JuF9vdvp1pi220m55Pi9T2JnO4Q= -github.com/prometheus/common v0.40.0/go.mod h1:L65ZJPSmfn/UBWLQIHV7dBrKFidB/wPlF1y5TlSt9OE= +github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= +github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -403,8 +403,8 @@ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= -golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= +golang.org/x/oauth2 v0.5.0 h1:HuArIo48skDwlrvM3sEdHXElYslAMsf3KwRkkW4MC4s= +golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=