diff --git a/.gitignore b/.gitignore index 2d33e1d..f5bf34f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ examples/sample_secret.yaml examples/dynatrace_secret.yaml examples/secret.yaml /examples/datasink/dynatrace-prod-setup.yaml + +# debug file +*debug* diff --git a/Makefile b/Makefile index f7650ac..406369d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,3 @@ - - PROJECT_NAME := metrics PROJECT_FULL_NAME := metrics-operator @@ -32,7 +30,6 @@ SHELL = /usr/bin/env bash -o pipefail all: build ##@ General - # The help target prints out all targets with their descriptions organized # beneath their categories. The categories are represented by '##@' and the # target descriptions by '##'. The awk commands is responsible for reading the @@ -46,10 +43,79 @@ all: build .PHONY: help help: ## Display this help. - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +#---------------------------------------------------------------------------------------------- +##@ Build Dependencies + +## Location to install dependencies to +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + mkdir -p $(LOCALBIN) + +## Tool Binaries +KUBECTL ?= kubectl +KIND ?= kind # fix this to use tools +KUSTOMIZE ?= $(LOCALBIN)/kustomize +CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen +ENVTEST ?= $(LOCALBIN)/setup-envtest +GOTESTSUM ?= $(LOCALBIN)/gotestsum +GOLANGCILINT ?= $(LOCALBIN)/golangci-lint + + + +## Tool Versions +KUSTOMIZE_VERSION ?= v5.4.1 +CONTROLLER_TOOLS_VERSION ?= v0.17.2 +GOLANGCILINT_VERSION ?= v2.0.2 + +.PHONY: kustomize +kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading. +$(KUSTOMIZE): $(LOCALBIN) + @if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \ + echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \ + rm -rf $(LOCALBIN)/kustomize; \ + fi + test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION) + +$(GOLANGCILINT): $(LOCALBIN) + @if test -x $(LOCALBIN)/golangci-lint && ! $(LOCALBIN)/golangci-lint version | grep -q $(GOLANGCILINT_VERSION); then \ + echo "$(LOCALBIN)/golangci-lint version is not expected $(GOLANGCILINT_VERSION). Removing it before installing."; \ + rm -rf $(LOCALBIN)/golangci-lint; \ + fi + test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) GO111MODULE=on go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCILINT_VERSION) + +.PHONY: controller-gen +controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten. +$(CONTROLLER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \ + GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) + +.PHONY: envtest +envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. +$(ENVTEST): $(LOCALBIN) + test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest + +.PHONY: envtest-bins +envtest-bins: envtest ## Download envtest binaries + $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) + +.PHONY: gotestsum +gotestsum: $(GOTESTSUM) ## Download gotestsum locally if necessary. +$(GOTESTSUM): $(LOCALBIN) + test -s $(LOCALBIN)/gotestsum || GOBIN=$(LOCALBIN) go install gotest.tools/gotestsum@latest + +.PHONY: lint +lint: $(GOLANGCILINT) ## Run golangci-lint against code. + $(GOLANGCILINT) config verify + $(GOLANGCILINT) run ./... -##@ Development +.PHONY: lint-fix +lint-fix: $(GOLANGCILINT) ## Run golangci-lint with --fix option to automatically fix issues. + $(GOLANGCILINT) run --fix +#---------------------------------------------------------------------------------------------- +##@ Code Generation & Formatting .PHONY: manifests manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases @@ -67,28 +133,16 @@ fmt: ## Run go fmt against code. vet: ## Run go vet against code. go vet ./... -.PHONY: test -test: manifests generate fmt vet envtest ## Run tests. - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out - +#---------------------------------------------------------------------------------------------- ##@ Build - .PHONY: build build: manifests generate fmt vet ## Build manager binary. go build -o bin/manager cmd/main.go -.PHONY: run -run: manifests generate fmt vet ## Run a controller from your host. - OPERATOR_CONFIG_NAMESPACE=metrics-operator-system go run ./cmd/main.go start - .PHONY: build-docker-binary -build-docker-binary: manifests generate fmt vet ## Build manager binary. +build-docker-binary: manifests generate fmt vet ## Build manager binary for Docker image. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/manager-linux.amd64 cmd/main.go - -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. -# More info: https://docs.docker.com/develop/develop-images/build_enhancements/ .PHONY: docker-build docker-build: build-docker-binary test ## Build docker image with the manager. $(CONTAINER_TOOL) build -t ${IMG} . @@ -105,7 +159,7 @@ docker-push: ## Push docker image with the manager. # To properly provided solutions that supports more than one platform you should use this option. PLATFORMS ?= linux/arm64 linux/amd64 .PHONY: docker-buildx -docker-buildx: #test ## Build and tag docker image for each platform locally using --load +docker-buildx: ## Build and tag docker image for each platform locally using --load sed '1 s/^FROM/FROM --platform=$${BUILDPLATFORM}/' Dockerfile > Dockerfile.cross $(CONTAINER_TOOL) buildx create --name project-v3-builder || true $(CONTAINER_TOOL) buildx use project-v3-builder @@ -117,12 +171,8 @@ docker-buildx: #test ## Build and tag docker image for each platform locally usi $(CONTAINER_TOOL) buildx rm project-v3-builder rm Dockerfile.cross +#---------------------------------------------------------------------------------------------- ##@ Deployment - -ifndef ignore-not-found - ignore-not-found = false -endif - .PHONY: install install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. $(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f - @@ -140,223 +190,128 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. $(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f - -##@ Build Dependencies - -## Location to install dependencies to -LOCALBIN ?= $(shell pwd)/bin -$(LOCALBIN): - mkdir -p $(LOCALBIN) - -## Tool Binaries -KUBECTL ?= kubectl -KIND ?= kind # fix this to use tools -KUSTOMIZE ?= $(LOCALBIN)/kustomize -CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen -ENVTEST ?= $(LOCALBIN)/setup-envtest -GOTESTSUM ?= $(LOCALBIN)/gotestsum -GOLANGCILINT ?= $(LOCALBIN)/golangci-lint - - - -## Tool Versions -KUSTOMIZE_VERSION ?= v5.4.1 -CONTROLLER_TOOLS_VERSION ?= v0.17.2 -GOLANGCILINT_VERSION ?= v2.0.2 - -.PHONY: kustomize -kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading. -$(KUSTOMIZE): $(LOCALBIN) - @if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \ - echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \ - rm -rf $(LOCALBIN)/kustomize; \ - fi - test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION) - -.PHONY: controller-gen -controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten. -$(CONTROLLER_GEN): $(LOCALBIN) - test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \ - GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) - -.PHONY: envtest -envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. -$(ENVTEST): $(LOCALBIN) - test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest - -.PHONY: envtest-bins -envtest-bins: envtest ## Download envtest binaries - $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) - -.PHONY: gotestsum -gotestsum: $(GOTESTSUM) ## Download gotestsum locally if necessary. -$(GOTESTSUM): $(LOCALBIN) - test -s $(LOCALBIN)/gotestsum || GOBIN=$(LOCALBIN) go install gotest.tools/gotestsum@latest - - -### ------------------------------------ DEVELOPMENT - LOCAL ------------------------------------ ### - -.PHONY: dev-all -dev-all-deploy: - $(MAKE) dev-deploy - $(MAKE) crossplane-install - $(MAKE) crossplane-provider-install - $(MAKE) crossplane-provider-sample - - -.PHONY: dev-deploy -dev-deploy: manifests kustomize dev-clean - $(KIND) create cluster --name=$(PROJECT_NAME)-dev - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} - $(KUSTOMIZE) build config/default | kubectl apply -f - - $(KIND) load docker-image ${IMG} --name=$(PROJECT_NAME)-dev - - +#---------------------------------------------------------------------------------------------- +##@ Local Development Utilities .PHONY: dev-build -dev-build: docker-build +dev-build: docker-build ## Build the Docker image for local development. @echo "Finished building docker image" ${IMG} -.PHONY: dev-base -dev-base: manifests kustomize dev-build dev-clean dev-cluster helm-install-local +.PHONY: kind-load-image +kind-load-image: ## Load the Docker image into the local kind cluster for development. + $(KIND) load docker-image ${IMG} --name=$(PROJECT_FULL_NAME)-dev -.PHONY: dev-cluster -dev-cluster: +.PHONY: kind-cluster +kind-cluster: ## Create a kind cluster for development (no CRDs or resources applied). $(KIND) create cluster --name=$(PROJECT_FULL_NAME)-dev - $(KIND) load docker-image ${IMG} --name=$(PROJECT_FULL_NAME)-dev +.PHONY: dev-clean +dev-clean: ## Delete the local kind cluster used for development. + $(KIND) delete cluster --name=$(PROJECT_FULL_NAME)-dev + +.PHONY: run +run: ## Run the operator locally (for debugging/development). + ## todo: add flag --debug + OPERATOR_CONFIG_NAMESPACE=metrics-operator-system go run ./cmd/main.go start + +#---------------------------------------------------------------------------------------------- +##@ Testing +.PHONY: test +test: manifests generate fmt vet envtest ## Run tests. + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out + +#---------------------------------------------------------------------------------------------- +##@ Testing: Run Operator outside of the cluster .PHONY: dev-local -dev-local: +dev-local: ## Create a local kind cluster and install CRDs for development. $(KIND) create cluster --name=$(PROJECT_FULL_NAME)-dev $(MAKE) install .PHONY: dev-local-all -dev-local-all: +dev-local-all: ## Full local dev setup: clean-up, create cluster, install CRDs, Crossplane, namespaces, secrets, and sample metrics. $(MAKE) dev-clean - $(KIND) create cluster --name=$(PROJECT_FULL_NAME)-dev + $(MAKE) kind-cluster $(MAKE) install $(MAKE) crossplane-install $(MAKE) crossplane-provider-install - $(MAKE) crossplane-provider-sample - $(MAKE) dev-namespace - $(MAKE) dev-secret + $(MAKE) helm-provider-sample $(MAKE) dev-operator-namespace + $(MAKE) dev-apply-dynatrace-prod-setup $(MAKE) dev-basic-metric $(MAKE) dev-managed-metric +#---------------------------------------------------------------------------------------------- +##@ Testing: Run Operator inside the cluster (production scenario) -.PHONY: dev-secret -dev-secret: - kubectl apply -f examples/secret.yaml - -.PHONY: dev-namespace -dev-namespace: - kubectl apply -f examples/namespace.yaml +.PHONY: dev-deploy +dev-deploy: manifests kustomize dev-build dev-clean kind-cluster kind-load-image helm-install-local ## Build the Docker image, create a local kind cluster, and deploy the Operator. +#---------------------------------------------------------------------------------------------- +##@ Example Resources .PHONY: dev-operator-namespace -dev-operator-namespace: +dev-operator-namespace: ## Create the operator namespace if it does not exist. kubectl create namespace metrics-operator-system --dry-run=client -o yaml | kubectl apply -f - .PHONY: dev-basic-metric -dev-basic-metric: +dev-basic-metric: ## Apply the basic metric example to the cluster. kubectl apply -f examples/basic_metric.yaml .PHONY: dev-managed-metric -dev-managed-metric: +dev-managed-metric: ## Apply the managed metric example to the cluster. kubectl apply -f examples/managed_metric.yaml .PHONY: dev-apply-dynatrace-prod-setup -dev-apply-dynatrace-prod-setup: +dev-apply-dynatrace-prod-setup: ## Apply Dynatrace production setup example to the cluster. kubectl apply -f examples/datasink/dynatrace-prod-setup.yaml .PHONY: dev-apply-metric-dynatrace-prod -dev-apply-metric-dynatrace-prod: +dev-apply-metric-dynatrace-prod: ## Apply metric using Dynatrace production example to the cluster. kubectl apply -f examples/datasink/metric-using-dynatrace-prod.yaml -.PHONY: dev-v1beta1-compmetric -dev-v1beta1-compmetric: - kubectl apply -f examples/v1beta1/compmetric.yaml - - -.PHONY: dev-kind -dev-kind: - $(KIND) create cluster --name=$(PROJECT_FULL_NAME)-dev - -.PHONY: dev-clean -dev-clean: - $(KIND) delete cluster --name=$(PROJECT_FULL_NAME)-dev - -.PHONY: dev-run -dev-run: - ## todo: add flag --debug - go run ./cmd/main.go - -$(GOLANGCILINT): $(LOCALBIN) - @if test -x $(LOCALBIN)/golangci-lint && ! $(LOCALBIN)/golangci-lint version | grep -q $(GOLANGCILINT_VERSION); then \ - echo "$(LOCALBIN)/golangci-lint version is not expected $(GOLANGCILINT_VERSION). Removing it before installing."; \ - rm -rf $(LOCALBIN)/golangci-lint; \ - fi - test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) GO111MODULE=on go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCILINT_VERSION) - - -.PHONY: lint -lint: $(GOLANGCILINT) - $(GOLANGCILINT) config verify - $(GOLANGCILINT) run ./... - -.PHONY: lint-fix -lint-fix: - golangci-lint run --fix - -### ------------------------------------ HELM ------------------------------------ ### - - +#---------------------------------------------------------------------------------------------- +##@ Helm .PHONY: helm-chart -helm-chart: +helm-chart: ## Generate Helm chart files from templates. OPERATOR_VERSION=$(shell cat VERSION) envsubst < charts/$(PROJECT_FULL_NAME)/Chart.yaml.tpl > charts/$(PROJECT_FULL_NAME)/Chart.yaml OPERATOR_VERSION=$(shell cat VERSION) envsubst < charts/$(PROJECT_FULL_NAME)/values.yaml.tpl > charts/$(PROJECT_FULL_NAME)/values.yaml .PHONY: helm-install-local -helm-install-local: docker-build +helm-install-local: ## Install the Helm chart locally using the Docker image helm upgrade --install $(PROJECT_FULL_NAME) charts/$(PROJECT_FULL_NAME)/ --set image.repository=$(IMG_BASE) --set image.tag=$(IMG_VERSION) --set image.pullPolicy=Never $(KIND) load docker-image ${IMG} --name=$(PROJECT_FULL_NAME)-dev +#---------------------------------------------------------------------------------------------- +##@ Crossplane - -.PHONY: helm-work -helm-work: dev-kind crossplane-install helm-install-local - echo "Helm work done" - -# initializes pre-commit hooks using lefthook https://github.com/evilmartians/lefthook -lefthook: - lefthook install - -# ensure go generate doesn't create a diff -check-diff: generate manifests - @echo checking clean branch - @if git status --porcelain | grep . ; then echo Uncommitted changes found after running make generate manifests. Please ensure you commit all generated files in this branch after running make generate. && false; else echo branch is clean; fi - -reviewable: - @$(MAKE) generate - @$(MAKE) lint - @$(MAKE) test -### ------------------------------------ CROSSPLANE ------------------------------------ ### - -# Namespace where Crossplane is installed +# CROSSPLANE_NAMESPACE defines the namespace where Crossplane will be installed. CROSSPLANE_NAMESPACE ?= crossplane-system .PHONY: crossplane-install -crossplane-install: - helm install crossplane crossplane-stable/crossplane --namespace crossplane-system --create-namespace --wait +crossplane-install: ## Install Crossplane into the cluster. + helm install crossplane crossplane-stable/crossplane --namespace $(CROSSPLANE_NAMESPACE) --create-namespace --wait -# Install the Kubernetes provider using kubectl -crossplane-provider-install: +.PHONY: crossplane-provider-install +crossplane-provider-install: ## Install the Helm provider using kubectl kubectl apply -f examples/crossplane/provider.yaml -n $(CROSSPLANE_NAMESPACE) kubectl wait --for=condition=Healthy provider/provider-helm --timeout=1m kubectl apply -f examples/crossplane/provider-config.yaml -n $(CROSSPLANE_NAMESPACE) +.PHONY: helm-provider-sample +helm-provider-sample: ## Apply the Helm provider sample to the cluster. + kubectl apply -f examples/crossplane/release.yaml -n $(CROSSPLANE_NAMESPACE) +#---------------------------------------------------------------------------------------------- +##@ Utility +.PHONY: lefthook +lefthook: ## Initializes pre-commit hooks using lefthook https://github.com/evilmartians/lefthook + lefthook install -.PHONY: install-k8s-provider +.PHONY: check-diff +check-diff: generate manifests ## Ensures that go generate doesn't create a diff + @echo checking clean branch + @if git status --porcelain | grep . ; then echo Uncommitted changes found after running make generate manifests. Please ensure you commit all generated files in this branch after running make generate. && false; else echo branch is clean; fi -.PHONY: helm-provider-sample -crossplane-provider-sample: - kubectl apply -f examples/crossplane/release.yaml -n $(CROSSPLANE_NAMESPACE) +.PHONY: reviewable +reviewable: ## Ensures that the code is reviewable by running generate, lint, and test + @$(MAKE) generate + @$(MAKE) lint + @$(MAKE) test diff --git a/PROJECT b/PROJECT index 0da1491..bfd588e 100644 --- a/PROJECT +++ b/PROJECT @@ -31,36 +31,20 @@ resources: kind: RemoteClusterAccess path: github.com/SAP/metrics-operator/api/v1alpha1 version: v1alpha1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: metrics.cloud.sap - kind: CompoundMetric - path: github.com/SAP/metrics-operator/api/v1beta1 - version: v1beta1 - api: crdVersion: v1 namespaced: true controller: true domain: metrics.cloud.sap kind: FederatedMetric - path: github.com/SAP/metrics-operator/api/v1beta1 - version: v1beta1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: metrics.cloud.sap - kind: ClusterAccess - path: github.com/SAP/metrics-operator/api/v1beta1 + path: github.com/SAP/metrics-operator/api/v1alpha1 version: v1beta1 - api: crdVersion: v1 namespaced: true domain: metrics.cloud.sap kind: FederatedClusterAccess - path: github.com/SAP/metrics-operator/api/v1beta1 + path: github.com/SAP/metrics-operator/api/v1alpha1 version: v1beta1 - api: crdVersion: v1 @@ -68,6 +52,6 @@ resources: controller: true domain: metrics.cloud.sap kind: FederatedManagedMetric - path: github.com/SAP/metrics-operator/api/v1beta1 + path: github.com/SAP/metrics-operator/api/v1alpha1 version: v1beta1 version: "3" diff --git a/README.md b/README.md index aced87e..5ada932 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,45 @@ The Metrics Operator is a powerful tool designed to monitor and provide insights ## Table of Contents -- [Key Features](#key-features) -- [Architecture Overview](#architecture-overview) -- [Installation](#installation) -- [Usage](#usage) -- [RBAC Configuration](#rbac-configuration) -- [Remote Cluster Access](#remote-cluster-access) -- [DataSink Configuration](#datasink-configuration) -- [Data Sink Integration](#data-sink-integration) +- [Metrics Operator](#metrics-operator) + - [Table of Contents](#table-of-contents) + - [Key Features](#key-features) + - [Architecture Overview](#architecture-overview) + - [Metric Resource Flow](#metric-resource-flow) + - [ManagedMetric Resource Flow](#managedmetric-resource-flow) + - [FederatedMetric Resource Flow](#federatedmetric-resource-flow) + - [FederatedManagedMetric Resource Flow](#federatedmanagedmetric-resource-flow) + - [Resource Type Descriptions:](#resource-type-descriptions) + - [Installation](#installation) + - [Prerequisites](#prerequisites) + - [Deployment](#deployment) + - [Getting Started](#getting-started) + - [Quickstart](#quickstart) + - [Common Development Tasks](#common-development-tasks) + - [Usage](#usage) + - [Metric](#metric) + - [Managed Metric](#managed-metric) + - [Federated Metric](#federated-metric) + - [Federated Managed Metric](#federated-managed-metric) + - [Remote Cluster Access](#remote-cluster-access) + - [Remote Cluster Access](#remote-cluster-access-1) + - [Federated Cluster Access](#federated-cluster-access) + - [RBAC Configuration](#rbac-configuration) + - [DataSink Configuration](#datasink-configuration) + - [Creating a DataSink](#creating-a-datasink) + - [DataSink Specification](#datasink-specification) + - [Connection](#connection) + - [Authentication](#authentication) + - [Using DataSink in Metrics](#using-datasink-in-metrics) + - [Default Behavior](#default-behavior) + - [Supported Metric Types](#supported-metric-types) + - [Examples and Detailed Documentation](#examples-and-detailed-documentation) + - [Migration from Legacy Configuration](#migration-from-legacy-configuration) + - [Data Sink Integration](#data-sink-integration) + - [Support, Feedback, Contributing](#support-feedback-contributing) + - [Security / Disclosure](#security--disclosure) + - [Code of Conduct](#code-of-conduct) + - [Licensing](#licensing) ## Key Features @@ -37,12 +68,12 @@ graph LR M -.->|optional| RCA[RemoteClusterAccess] RCA -->|accesses remote cluster| K8S M -->|sends data to| DS[Data Sink
Dynatrace, etc.] - + classDef metricType fill:#e1f5fe,stroke:#01579b,stroke-width:2px classDef accessType fill:#f3e5f5,stroke:#4a148c,stroke-width:2px classDef targetType fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px classDef dataType fill:#fff3e0,stroke:#e65100,stroke-width:2px - + class M metricType class RCA accessType class K8S targetType @@ -57,12 +88,12 @@ graph LR MM -.->|optional| RCA[RemoteClusterAccess] RCA -->|accesses remote cluster| MR MM -->|sends data to| DS[Data Sink
Dynatrace, etc.] - + classDef metricType fill:#e1f5fe,stroke:#01579b,stroke-width:2px classDef accessType fill:#f3e5f5,stroke:#4a148c,stroke-width:2px classDef targetType fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px classDef dataType fill:#fff3e0,stroke:#e65100,stroke-width:2px - + class MM metricType class RCA accessType class MR targetType @@ -78,12 +109,12 @@ graph LR FCA -->|provides access to| MC[Multiple Clusters] FM -->|targets across clusters| K8S[Kubernetes Objects
across federated clusters] FM -->|aggregates & sends to| DS[Data Sink
Dynatrace, etc.] - + classDef metricType fill:#e1f5fe,stroke:#01579b,stroke-width:2px classDef accessType fill:#f3e5f5,stroke:#4a148c,stroke-width:2px classDef targetType fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px classDef dataType fill:#fff3e0,stroke:#e65100,stroke-width:2px - + class FM metricType class FCA accessType class CP,MC,K8S targetType @@ -99,26 +130,27 @@ graph LR FCA -->|provides access to| MC[Multiple Clusters] FMM -->|targets managed resources
across clusters| MR[Managed Resources
with 'crossplane' & 'managed' categories] FMM -->|aggregates & sends to| DS[Data Sink
Dynatrace, etc.] - + classDef metricType fill:#e1f5fe,stroke:#01579b,stroke-width:2px classDef accessType fill:#f3e5f5,stroke:#4a148c,stroke-width:2px classDef targetType fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px classDef dataType fill:#fff3e0,stroke:#e65100,stroke-width:2px - + class FMM metricType class FCA accessType class CP,MC,MR targetType class DS dataType ``` -### Resource Type Descriptions: +## Resource Type Descriptions: -- **Metric**: Monitors specific Kubernetes resources in the local or remote clusters using GroupVersionKind targeting -- **ManagedMetric**: Specialized for monitoring Crossplane managed resources (resources with "crossplane" and "managed" categories) -- **FederatedMetric**: Monitors resources across multiple clusters, aggregating data from federated sources -- **FederatedManagedMetric**: Monitors Crossplane managed resources across multiple clusters -- **RemoteClusterAccess**: Provides access configuration for monitoring resources in remote clusters -- **FederatedClusterAccess**: Discovers and provides access to multiple clusters for federated monitoring +- [**Metric**](config/crd/bases/metrics.cloud.sap_metrics.yaml): Monitors specific Kubernetes resources in the local or remote clusters using GroupVersionKind targeting +- [**ManagedMetric**](config/crd/bases/metrics.cloud.sap_managedmetrics.yaml): Specialized for monitoring Crossplane managed resources (resources with "crossplane" and "managed" categories) +- [**FederatedMetric**](config/crd/bases/metrics.cloud.sap_federatedmetrics.yaml): Monitors resources across multiple clusters, aggregating data from federated sources +- [**FederatedManagedMetric**](config/crd/bases/metrics.cloud.sap_federatedmanagedmetrics.yaml): Monitors Crossplane managed resources across multiple clusters +- [**RemoteClusterAccess**](config/crd/bases/metrics.cloud.sap_remoteclusteraccesses.yaml): Provides access configuration for monitoring resources in remote clusters +- [**FederatedClusterAccess**](config/crd/bases/metrics.cloud.sap_federatedclusteraccesses.yaml): Discovers and provides access to multiple clusters for federated monitoring +- [**DataSink**](config/crd/bases/metrics.cloud.sap_datasinks.yaml): Defines where and how metrics data should be sent, supporting various destinations like Dynatrace ## Installation @@ -132,7 +164,7 @@ graph LR Deploy the Metrics Operator using the Helm chart: ```bash -helm upgrade --install metrics-operator ghcr.io/sap/github.com/sap/metrics-operator/charts/metrics-operator \ +helm upgrade --install metrics-operator oci://ghcr.io/sap/github.com/sap/metrics-operator/charts/metrics-operator \ --namespace \ --create-namespace \ --version= @@ -142,6 +174,30 @@ Replace `` and `` with appropriate values. After deployment, create your DataSink configuration as described in the [DataSink Configuration](#datasink-configuration) section. +## Getting Started +You’ll need a Kubernetes cluster to run against. You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for testing, or run against a remote cluster. +**Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows). + +### Quickstart + +1. Clone the repository and install prerequisites (Go, Docker, kind, kubectl). +2. Configure your data sink by copying the configuration in [`examples/datasink/basic-datasink.yaml`](examples/datasink/basic-datasink.yaml) and modifying it to suit your environment. + - For example, if using Dynatrace, create a Kubernetes Secret with your API token and update the DataSink resource accordingly. + - The file should be placed and named like this: `examples/datasink/dynatrace-prod-setup.yaml`. (automatically excluded in [.gitignore](.gitignore)) +3. Run `make dev-local-all` to set up a local development environment. +4. Run `make run` to start the Metrics Operator locally. +5. Check your data sink for incoming metrics. + +### Common Development Tasks +This project uses a Makefile to streamline development tasks. Common targets include: + +- `make dev-local-all` – Set up a local kind cluster with all CRDs, Crossplane, and sample resources. +- `make run` – Run the operator locally for development. +- `make dev-clean` – Delete the local kind cluster. +- `make test` – Run all Go tests. +- `make lint` – Run golangci-lint on the codebase. +- `make manifests generate` – Regenerate CRDs and deepcopy code after API changes. + ## Usage ### Metric @@ -154,9 +210,9 @@ The projections are then translated to dimensions in the metric. apiVersion: metrics.cloud.sap/v1alpha1 kind: Metric metadata: - name: comp-pod + name: metric-pod-count spec: - name: comp-metric-pods + name: metric-pod-count description: Pods target: kind: Pod @@ -416,7 +472,7 @@ The detailed guide covers: ### Migration from Legacy Configuration -**Important**: The old method of using hardcoded secret names (such as `co-dynatrace-credentials`) has been deprecated and removed. You must now use DataSink resources to configure your metrics destinations. +**Important**: The old method of using hardcoded secret names (such as `dynatrace-credentials`) has been deprecated and removed. You must now use DataSink resources to configure your metrics destinations. To migrate: 1. Create a DataSink resource pointing to your existing authentication secret @@ -437,37 +493,6 @@ To make the most of your metrics: For specific instructions on using your data sink's features, refer to its documentation. For example, if using Dynatrace, consult the Dynatrace documentation for information on creating custom charts, setting up alerts, and performing advanced analytics on your metric data. -## Getting Started -You’ll need a Kubernetes cluster to run against. You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for testing, or run against a remote cluster. -**Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows). - -### Running on the cluster -1. Install Instances of Custom Resources: - -```sh -make dev-local-all -``` - -2. Run the controller: - -```sh -make dev-run -``` -Or run it from your IDE. - -### Delete Kind Cluster -Delete Kind cluster -```sh -make dev-clean -``` - -### Modifying the API definitions -If you are editing the API definitions, generate the manifests such as CRs or CRDs using: - -```sh -make manifests generate -``` - ## Support, Feedback, Contributing This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/SAP/metrics-operator/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md). diff --git a/charts/metrics-operator/values.yaml b/charts/metrics-operator/values.yaml index d61a872..f7d84b5 100644 --- a/charts/metrics-operator/values.yaml +++ b/charts/metrics-operator/values.yaml @@ -1,11 +1,11 @@ -# Default values for co-metrics-operator. +# Default values for metrics-operator. # This is a YAML-formatted file. # Declare variables to be passed into your templates. replicaCount: 1 image: - repository: deploy-releases-hyperspace-docker.common.cdn.repositories.cloud.sap/cloud-orchestration/co-metrics-operator + repository: ghcr.io/sap/github.com/sap/metrics-operator/images/metrics-operator pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: v0.5.2-dev diff --git a/charts/metrics-operator/values.yaml.tpl b/charts/metrics-operator/values.yaml.tpl index 08a4ce3..8c75552 100644 --- a/charts/metrics-operator/values.yaml.tpl +++ b/charts/metrics-operator/values.yaml.tpl @@ -1,11 +1,11 @@ -# Default values for co-metrics-operator. +# Default values for metrics-operator. # This is a YAML-formatted file. # Declare variables to be passed into your templates. replicaCount: 1 image: - repository: deploy-releases-hyperspace-docker.common.cdn.repositories.cloud.sap/cloud-orchestration/co-metrics-operator + repository: ghcr.io/sap/github.com/sap/metrics-operator/images/metrics-operator pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: $OPERATOR_VERSION diff --git a/cmd/embedded/crds/metrics.cloud.sap_clusteraccesses.yaml b/cmd/embedded/crds/metrics.cloud.sap_clusteraccesses.yaml deleted file mode 100644 index a376644..0000000 --- a/cmd/embedded/crds/metrics.cloud.sap_clusteraccesses.yaml +++ /dev/null @@ -1,83 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.17.2 - name: clusteraccesses.metrics.cloud.sap -spec: - group: metrics.cloud.sap - names: - kind: ClusterAccess - listKind: ClusterAccessList - plural: clusteraccesses - singular: clusteraccess - scope: Namespaced - versions: - - name: v1beta1 - schema: - openAPIV3Schema: - description: ClusterAccess is the Schema for the clusteraccesses 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: ClusterAccessSpec defines the desired state of ClusterAccess - properties: - kubeConfigSecretRef: - description: Reference to the secret that contains the kubeconfig - to access an external cluster other than the one the operator is - running in - properties: - key: - description: Key is the key in the secret to use - type: string - name: - description: Name is the name of the secret - type: string - namespace: - description: Namespace is the namespace of the secret - type: string - type: object - remoteClusterConfig: - description: ClusterAccessConfig defines the configuration to access - a remote cluster - properties: - clusterSecretRef: - description: RemoteClusterSecretRef is a reference to a secret - that contains host, audience, and caData to a remote cluster - properties: - name: - type: string - namespace: - type: string - type: object - serviceAccountName: - type: string - serviceAccountNamespace: - type: string - type: object - type: object - status: - description: ClusterAccessStatus defines the observed state of ClusterAccess - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/cmd/main.go b/cmd/main.go index 4cce0dd..b53fe28 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -168,19 +168,14 @@ func main() { os.Exit(1) } - // TODO: to deprecate v1beta1 resources setupMetricController(mgr) + setupManagedMetricController(mgr) - setupReconcilersV1beta1(mgr) + setupFederatedMetricController(mgr) + + setupFederatedManagedMetricController(mgr) - if err = (&controller.ClusterAccessReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "ClusterAccess") - os.Exit(1) - } //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { @@ -199,17 +194,18 @@ func main() { } } -func setupReconcilersV1beta1(mgr ctrl.Manager) { +func setupFederatedMetricController(mgr ctrl.Manager) { if err := (controller.NewFederatedMetricReconciler(mgr)).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create reconciler", "controller", "federated metric") os.Exit(1) } +} +func setupFederatedManagedMetricController(mgr ctrl.Manager) { if err := (controller.NewFederatedManagedMetricReconciler(mgr)).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create reconciler", "controller", "federated managed metric") os.Exit(1) } - } func setupMetricController(mgr ctrl.Manager) { diff --git a/config/crd/bases/metrics.cloud.sap_clusteraccesses.yaml b/config/crd/bases/metrics.cloud.sap_clusteraccesses.yaml deleted file mode 100644 index a376644..0000000 --- a/config/crd/bases/metrics.cloud.sap_clusteraccesses.yaml +++ /dev/null @@ -1,83 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.17.2 - name: clusteraccesses.metrics.cloud.sap -spec: - group: metrics.cloud.sap - names: - kind: ClusterAccess - listKind: ClusterAccessList - plural: clusteraccesses - singular: clusteraccess - scope: Namespaced - versions: - - name: v1beta1 - schema: - openAPIV3Schema: - description: ClusterAccess is the Schema for the clusteraccesses 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: ClusterAccessSpec defines the desired state of ClusterAccess - properties: - kubeConfigSecretRef: - description: Reference to the secret that contains the kubeconfig - to access an external cluster other than the one the operator is - running in - properties: - key: - description: Key is the key in the secret to use - type: string - name: - description: Name is the name of the secret - type: string - namespace: - description: Namespace is the namespace of the secret - type: string - type: object - remoteClusterConfig: - description: ClusterAccessConfig defines the configuration to access - a remote cluster - properties: - clusterSecretRef: - description: RemoteClusterSecretRef is a reference to a secret - that contains host, audience, and caData to a remote cluster - properties: - name: - type: string - namespace: - type: string - type: object - serviceAccountName: - type: string - serviceAccountNamespace: - type: string - type: object - type: object - status: - description: ClusterAccessStatus defines the observed state of ClusterAccess - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 2e78881..d7d0c8a 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -7,7 +7,6 @@ resources: - bases/metrics.cloud.sap_datasinks.yaml - bases/metrics.cloud.sap_remoteclusteraccesses.yaml - bases/metrics.cloud.sap_federatedmetrics.yaml -- bases/metrics.cloud.sap_clusteraccesses.yaml - bases/metrics.cloud.sap_federatedclusteraccesses.yaml - bases/metrics.cloud.sap_federatedmanagedmetrics.yaml #+kubebuilder:scaffold:crdkustomizeresource diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index ed7a405..e1b3c3b 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -1,12 +1,12 @@ # Adds namespace to all resources. -namespace: co-metrics-operator-system +namespace: metrics-operator-system # Value of this field is prepended to the # names of all resources, e.g. a deployment named # "wordpress" becomes "alices-wordpress". # Note that it should also match with the prefix (text before '-') of the namespace # field above. -namePrefix: co-metrics-operator- +namePrefix: metrics-operator- # Labels to add to all resources and selectors. #labels: diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 974782f..255c4cf 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: co-metrics-operator + newName: metrics-operator newTag: dev diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 22ccc94..1a018ec 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: namespace app.kubernetes.io/instance: system app.kubernetes.io/component: manager - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: system --- @@ -21,8 +21,8 @@ metadata: app.kubernetes.io/name: deployment app.kubernetes.io/instance: controller-manager app.kubernetes.io/component: manager - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize spec: selector: diff --git a/config/prometheus/monitor.yaml b/config/prometheus/monitor.yaml index 634a68e..69e937e 100644 --- a/config/prometheus/monitor.yaml +++ b/config/prometheus/monitor.yaml @@ -8,8 +8,8 @@ metadata: app.kubernetes.io/name: servicemonitor app.kubernetes.io/instance: controller-manager-metrics-monitor app.kubernetes.io/component: metrics - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: controller-manager-metrics-monitor namespace: system diff --git a/config/rbac/auth_proxy_client_clusterrole.yaml b/config/rbac/auth_proxy_client_clusterrole.yaml index 965f85b..2e0625c 100644 --- a/config/rbac/auth_proxy_client_clusterrole.yaml +++ b/config/rbac/auth_proxy_client_clusterrole.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: metrics-reader app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: metrics-reader rules: diff --git a/config/rbac/auth_proxy_role.yaml b/config/rbac/auth_proxy_role.yaml index 92fa5e3..068b905 100644 --- a/config/rbac/auth_proxy_role.yaml +++ b/config/rbac/auth_proxy_role.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: proxy-role app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: proxy-role rules: diff --git a/config/rbac/auth_proxy_role_binding.yaml b/config/rbac/auth_proxy_role_binding.yaml index 81c5354..b76220a 100644 --- a/config/rbac/auth_proxy_role_binding.yaml +++ b/config/rbac/auth_proxy_role_binding.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: clusterrolebinding app.kubernetes.io/instance: proxy-rolebinding app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: proxy-rolebinding roleRef: diff --git a/config/rbac/auth_proxy_service.yaml b/config/rbac/auth_proxy_service.yaml index 64c5bc0..609ade6 100644 --- a/config/rbac/auth_proxy_service.yaml +++ b/config/rbac/auth_proxy_service.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: service app.kubernetes.io/instance: controller-manager-metrics-service app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: controller-manager-metrics-service namespace: system diff --git a/config/rbac/clientconfig_editor_role.yaml b/config/rbac/clientconfig_editor_role.yaml index 3bdb300..e7afcee 100644 --- a/config/rbac/clientconfig_editor_role.yaml +++ b/config/rbac/clientconfig_editor_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: clientconfig-editor-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: clientconfig-editor-role rules: diff --git a/config/rbac/clientconfig_viewer_role.yaml b/config/rbac/clientconfig_viewer_role.yaml index 9936cf8..3f14327 100644 --- a/config/rbac/clientconfig_viewer_role.yaml +++ b/config/rbac/clientconfig_viewer_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: clientconfig-viewer-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: clientconfig-viewer-role rules: diff --git a/config/rbac/clusteraccess_editor_role.yaml b/config/rbac/clusteraccess_editor_role.yaml index 1f0a426..6a59529 100644 --- a/config/rbac/clusteraccess_editor_role.yaml +++ b/config/rbac/clusteraccess_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: clusteraccess-editor-role rules: diff --git a/config/rbac/clusteraccess_viewer_role.yaml b/config/rbac/clusteraccess_viewer_role.yaml index e400c78..5e5437c 100644 --- a/config/rbac/clusteraccess_viewer_role.yaml +++ b/config/rbac/clusteraccess_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: clusteraccess-viewer-role rules: diff --git a/config/rbac/datasink_editor_role.yaml b/config/rbac/datasink_editor_role.yaml index 7a8987c..72d3928 100644 --- a/config/rbac/datasink_editor_role.yaml +++ b/config/rbac/datasink_editor_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: datasink-editor-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: datasink-editor-role rules: diff --git a/config/rbac/datasink_viewer_role.yaml b/config/rbac/datasink_viewer_role.yaml index e02999c..4cd6082 100644 --- a/config/rbac/datasink_viewer_role.yaml +++ b/config/rbac/datasink_viewer_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: datasink-viewer-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: datasink-viewer-role rules: diff --git a/config/rbac/federatedclusteraccess_editor_role.yaml b/config/rbac/federatedclusteraccess_editor_role.yaml index f855adf..c4587fb 100644 --- a/config/rbac/federatedclusteraccess_editor_role.yaml +++ b/config/rbac/federatedclusteraccess_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: federatedclusteraccess-editor-role rules: diff --git a/config/rbac/federatedclusteraccess_viewer_role.yaml b/config/rbac/federatedclusteraccess_viewer_role.yaml index d8c892b..c864a59 100644 --- a/config/rbac/federatedclusteraccess_viewer_role.yaml +++ b/config/rbac/federatedclusteraccess_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: federatedclusteraccess-viewer-role rules: diff --git a/config/rbac/federatedmanagedmetric_editor_role.yaml b/config/rbac/federatedmanagedmetric_editor_role.yaml index 306c883..489f107 100644 --- a/config/rbac/federatedmanagedmetric_editor_role.yaml +++ b/config/rbac/federatedmanagedmetric_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: federatedmanagedmetric-editor-role rules: diff --git a/config/rbac/federatedmanagedmetric_viewer_role.yaml b/config/rbac/federatedmanagedmetric_viewer_role.yaml index 2bd7642..9e17be9 100644 --- a/config/rbac/federatedmanagedmetric_viewer_role.yaml +++ b/config/rbac/federatedmanagedmetric_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: federatedmanagedmetric-viewer-role rules: diff --git a/config/rbac/federatedmetric_editor_role.yaml b/config/rbac/federatedmetric_editor_role.yaml index aa7d044..649e2cd 100644 --- a/config/rbac/federatedmetric_editor_role.yaml +++ b/config/rbac/federatedmetric_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: federatedmetric-editor-role rules: diff --git a/config/rbac/federatedmetric_viewer_role.yaml b/config/rbac/federatedmetric_viewer_role.yaml index 69e61bb..254a72e 100644 --- a/config/rbac/federatedmetric_viewer_role.yaml +++ b/config/rbac/federatedmetric_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: federatedmetric-viewer-role rules: diff --git a/config/rbac/leader_election_role.yaml b/config/rbac/leader_election_role.yaml index b088dfe..4284c4a 100644 --- a/config/rbac/leader_election_role.yaml +++ b/config/rbac/leader_election_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: role app.kubernetes.io/instance: leader-election-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: leader-election-role rules: diff --git a/config/rbac/leader_election_role_binding.yaml b/config/rbac/leader_election_role_binding.yaml index 57bee51..3146d51 100644 --- a/config/rbac/leader_election_role_binding.yaml +++ b/config/rbac/leader_election_role_binding.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: rolebinding app.kubernetes.io/instance: leader-election-rolebinding app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: leader-election-rolebinding roleRef: diff --git a/config/rbac/managedmetric_editor_role.yaml b/config/rbac/managedmetric_editor_role.yaml index 5f51fbf..0aa86d1 100644 --- a/config/rbac/managedmetric_editor_role.yaml +++ b/config/rbac/managedmetric_editor_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: managedmetric-editor-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: managedmetric-editor-role rules: diff --git a/config/rbac/managedmetric_viewer_role.yaml b/config/rbac/managedmetric_viewer_role.yaml index c1ef156..fd862d1 100644 --- a/config/rbac/managedmetric_viewer_role.yaml +++ b/config/rbac/managedmetric_viewer_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: managedmetric-viewer-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: managedmetric-viewer-role rules: diff --git a/config/rbac/metric_editor_role.yaml b/config/rbac/metric_editor_role.yaml index 1da36bd..39cde64 100644 --- a/config/rbac/metric_editor_role.yaml +++ b/config/rbac/metric_editor_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: metric-editor-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: metric-editor-role rules: diff --git a/config/rbac/metric_viewer_role.yaml b/config/rbac/metric_viewer_role.yaml index 1509cc1..23d5e08 100644 --- a/config/rbac/metric_viewer_role.yaml +++ b/config/rbac/metric_viewer_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: metric-viewer-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: metric-viewer-role rules: diff --git a/config/rbac/remoteclusteraccess_editor_role.yaml b/config/rbac/remoteclusteraccess_editor_role.yaml index 75b361a..c32954a 100644 --- a/config/rbac/remoteclusteraccess_editor_role.yaml +++ b/config/rbac/remoteclusteraccess_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: remoteclusteraccess-editor-role rules: diff --git a/config/rbac/remoteclusteraccess_viewer_role.yaml b/config/rbac/remoteclusteraccess_viewer_role.yaml index f88428c..2ab022a 100644 --- a/config/rbac/remoteclusteraccess_viewer_role.yaml +++ b/config/rbac/remoteclusteraccess_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: remoteclusteraccess-viewer-role rules: diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 74ab89e..ff05639 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -13,7 +13,14 @@ rules: - apiGroups: - metrics.cloud.sap resources: - - clusteraccesses + - datasinks + verbs: + - get + - list + - watch +- apiGroups: + - metrics.cloud.sap + resources: - federatedmetrics - managedmetrics - metrics @@ -28,7 +35,6 @@ rules: - apiGroups: - metrics.cloud.sap resources: - - clusteraccesses/finalizers - federatedmetrics/finalizers - managedmetrics/finalizers - metrics/finalizers @@ -37,7 +43,6 @@ rules: - apiGroups: - metrics.cloud.sap resources: - - clusteraccesses/status - federatedmetrics/status - managedmetrics/status - metrics/status @@ -45,11 +50,3 @@ rules: - get - patch - update -- apiGroups: - - metrics.cloud.sap - resources: - - datasinks - verbs: - - get - - list - - watch diff --git a/config/rbac/role_binding.yaml b/config/rbac/role_binding.yaml index be55ece..88724ec 100644 --- a/config/rbac/role_binding.yaml +++ b/config/rbac/role_binding.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: clusterrolebinding app.kubernetes.io/instance: manager-rolebinding app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: manager-rolebinding roleRef: diff --git a/config/rbac/service_account.yaml b/config/rbac/service_account.yaml index 94de4de..22d9010 100644 --- a/config/rbac/service_account.yaml +++ b/config/rbac/service_account.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: serviceaccount app.kubernetes.io/instance: controller-manager-sa app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: co-metrics-operator - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize name: controller-manager namespace: system diff --git a/config/samples/insight_v1_managedmetric.yaml b/config/samples/insight_v1_managedmetric.yaml index 098b465..0f4454a 100644 --- a/config/samples/insight_v1_managedmetric.yaml +++ b/config/samples/insight_v1_managedmetric.yaml @@ -4,9 +4,9 @@ metadata: labels: app.kubernetes.io/name: managedmetric app.kubernetes.io/instance: managedmetric-sample - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator name: managedmetric-sample spec: # TODO(user): Add fields here diff --git a/config/samples/insight_v1_metric.yaml b/config/samples/insight_v1_metric.yaml index 10a3d76..4205316 100644 --- a/config/samples/insight_v1_metric.yaml +++ b/config/samples/insight_v1_metric.yaml @@ -4,9 +4,9 @@ metadata: labels: app.kubernetes.io/name: metric app.kubernetes.io/instance: metric-sample - app.kubernetes.io/part-of: co-metrics-operator + app.kubernetes.io/part-of: metrics-operator app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: co-metrics-operator + app.kubernetes.io/created-by: metrics-operator name: metric-sample spec: # TODO(user): Add fields here diff --git a/config/samples/insight_v1alpha1_remoteclusteraccess.yaml b/config/samples/insight_v1alpha1_remoteclusteraccess.yaml index 0d2ac5f..d2b9203 100644 --- a/config/samples/insight_v1alpha1_remoteclusteraccess.yaml +++ b/config/samples/insight_v1alpha1_remoteclusteraccess.yaml @@ -2,7 +2,7 @@ apiVersion: orchestrate.cloud.sap/v1alpha1 kind: RemoteClusterAccess metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: remoteclusteraccess-sample spec: diff --git a/config/samples/insight_v1beta1_clusteraccess.yaml b/config/samples/insight_v1beta1_clusteraccess.yaml index 9dfebb7..3ef793b 100644 --- a/config/samples/insight_v1beta1_clusteraccess.yaml +++ b/config/samples/insight_v1beta1_clusteraccess.yaml @@ -2,7 +2,7 @@ apiVersion: metrics.cloud.sap/v1beta1 kind: ClusterAccess metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: clusteraccess-sample spec: diff --git a/config/samples/insight_v1beta1_federatedclusteraccess.yaml b/config/samples/insight_v1beta1_federatedclusteraccess.yaml index e0dfa7b..e8ca4db 100644 --- a/config/samples/insight_v1beta1_federatedclusteraccess.yaml +++ b/config/samples/insight_v1beta1_federatedclusteraccess.yaml @@ -2,7 +2,7 @@ apiVersion: metrics.cloud.sap/v1beta1 kind: FederatedClusterAccess metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: federatedclusteraccess-sample spec: diff --git a/config/samples/insight_v1beta1_federatedmanagedmetric.yaml b/config/samples/insight_v1beta1_federatedmanagedmetric.yaml index 84afa5c..998c6dc 100644 --- a/config/samples/insight_v1beta1_federatedmanagedmetric.yaml +++ b/config/samples/insight_v1beta1_federatedmanagedmetric.yaml @@ -2,7 +2,7 @@ apiVersion: metrics.cloud.sap/v1beta1 kind: FederatedManagedMetric metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: federatedmanagedmetric-sample spec: diff --git a/config/samples/insight_v1beta1_federatedmetric.yaml b/config/samples/insight_v1beta1_federatedmetric.yaml index 3974c57..a70c93f 100644 --- a/config/samples/insight_v1beta1_federatedmetric.yaml +++ b/config/samples/insight_v1beta1_federatedmetric.yaml @@ -2,7 +2,7 @@ apiVersion: metrics.cloud.sap/v1beta1 kind: FederatedMetric metadata: labels: - app.kubernetes.io/name: co-metrics-operator + app.kubernetes.io/name: metrics-operator app.kubernetes.io/managed-by: kustomize name: federatedmetric-sample spec: diff --git a/docs/datasink-configuration.md b/docs/datasink-configuration.md index e99a4f6..cda7114 100644 --- a/docs/datasink-configuration.md +++ b/docs/datasink-configuration.md @@ -304,8 +304,8 @@ Previously, the operator used hardcoded secret names: apiVersion: v1 kind: Secret metadata: - name: co-dynatrace-credentials # Hardcoded name - namespace: co-metrics-operator # Hardcoded namespace + name: dynatrace-credentials # Hardcoded name + namespace: metrics-operator # Hardcoded namespace type: Opaque data: api-token: @@ -371,7 +371,7 @@ data: **Error**: `401 Unauthorized` or similar authentication errors -**Solution**: +**Solution**: - Verify the API token is correct and has the necessary permissions - Check that the token is properly base64 encoded in the secret - Ensure the endpoint URL is correct for your data sink diff --git a/examples/dev-core/metric.yaml b/examples/dev-core/metric.yaml deleted file mode 100644 index 6ded561..0000000 --- a/examples/dev-core/metric.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: metrics.cloud.sap/v1alpha1 -kind: Metric -metadata: - name: dev-core-landscaperdeployment -spec: - name: dev-core-landscaperdeployment - description: Number of LandscapperDeplyoments in the LS-DEV-CORE cluster - target: - kind: LandscaperDeployment - group: landscaper-service.gardener.cloud - version: v1alpha1 - interval: "1m" # in minutes - # Uses default DataSink (named "default" in metrics-operator-system namespace) - # To use a custom DataSink, uncomment and specify: - # dataSinkRef: - # name: custom-sink ---- diff --git a/examples/dev-core/serviceaccount.yaml b/examples/dev-core/serviceaccount.yaml deleted file mode 100644 index 3ad9155..0000000 --- a/examples/dev-core/serviceaccount.yaml +++ /dev/null @@ -1,60 +0,0 @@ -# Please edit the object below. Lines beginning with a '#' will be ignored, -# and an empty file will abort the edit. If an error occurs while saving this file will be -# reopened with the relevant failures. -# -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: co-monitor-co-metrics-operator -rules: - - apiGroups: [ "" ] - resources: [ "serviceaccounts/token" ] - verbs: [ "create" ] - - apiGroups: [""] - resources: ["events"] - verbs: - - '*' - - apiGroups: - - landscaper-service.gardener.cloud - resources: - - landscaperdeployments - verbs: - - '*' - - apiGroups: - - admissionregistration.k8s.io - resources: - - validatingwebhookconfigurations - - mutatingwebhookconfigurations - verbs: - - '*' - - apiGroups: - - apiextensions.k8s.io - resources: - - customresourcedefinitions - verbs: - - '*' - - apiGroups: - - metrics.cloud.sap - resources: - - managedmetrics - - metrics - - metrics/status - - managedmetrics/status - verbs: - - '*' - - apiGroups: - - "" - resources: - - secrets - verbs: - - get - - list - - watch - - apiGroups: - - '*' - resources: - - '*' - verbs: - - get - - list - - watch diff --git a/examples/namespace.yaml b/examples/namespace.yaml index 797743e..b450f7b 100644 --- a/examples/namespace.yaml +++ b/examples/namespace.yaml @@ -1,4 +1,4 @@ apiVersion: v1 kind: Namespace metadata: - name: metrics-operator-system \ No newline at end of file + name: metrics-operator-system diff --git a/examples/remoteclusteraccess/crate.yaml b/examples/remoteclusteraccess/crate.yaml deleted file mode 100644 index a6bee5c..0000000 --- a/examples/remoteclusteraccess/crate.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: metrics.cloud.sap/v1alpha1 -kind: RemoteClusterAccess -metadata: - name: crate-cluster - namespace: test-monitoring -spec: - remoteClusterConfig: - clusterSecretRef: - name: crate-cluster - namespace: cola-system - serviceAccountName: co-monitor-co-metrics-operator - serviceAccountNamespace: co-metrics-operator diff --git a/examples/remoteclusteraccess/crate/crateroles.yaml b/examples/remoteclusteraccess/crate/crateroles.yaml deleted file mode 100644 index 0b51054..0000000 --- a/examples/remoteclusteraccess/crate/crateroles.yaml +++ /dev/null @@ -1,57 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: co-monitor-co-metrics-operator -rules: - - apiGroups: - - cola.cloud.sap - resources: - - managedcontrolplanes - - managedcontrolplanes/status - - internalconfigurations - - dataplanes - - dataplanes/status - - landscapers - - landscapers/status - - cloudorchestrators - - cloudorchestrators/status - - authentications - - authentications/status - - authorizations - - authorizations/status - verbs: - - '*' - - apiGroups: - - apiextensions.k8s.io - resources: - - customresourcedefinitions - verbs: - - '*' - - apiGroups: - - "" - resources: - - namespaces - verbs: - - get - - list - - watch - - apiGroups: - - "" - resources: - - secrets - - configmaps - verbs: - - '*' ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: co-monitor-co-metrics-operator -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: co-monitor-co-metrics-operator -subjects: - - apiGroup: rbac.authorization.k8s.io - kind: User - name: dev-core:system:serviceaccount:co-metrics-operator:co-monitor-co-metrics-operator diff --git a/examples/remoteclusteraccess/metric_with_rca.yaml b/examples/remoteclusteraccess/metric_with_rca.yaml deleted file mode 100644 index 11e568e..0000000 --- a/examples/remoteclusteraccess/metric_with_rca.yaml +++ /dev/null @@ -1,60 +0,0 @@ -apiVersion: metrics.cloud.sap/v1alpha1 -kind: Metric -metadata: - name: crate-mcp-metric -spec: - name: crate-mcp-metric - description: Number of ManagedControlPlanes in the Crate cluster - target: - kind: ManagedControlPlane - group: cola.cloud.sap - version: v1alpha1 - interval: "1m" # in minutes - remoteClusterAccessRef: - name: crate-cluster - namespace: test-monitoring - # Uses default DataSink (named "default" in metrics-operator-system namespace) - # To use a custom DataSink, uncomment and specify: - # dataSinkRef: - # name: custom-sink ---- -apiVersion: metrics.cloud.sap/v1alpha1 -kind: Metric -metadata: - name: crate-co-metric -spec: - name: crate-co-metric - description: Number of CloudOrchestrators in the Crate cluster - target: - kind: CloudOrchestrator - group: cola.cloud.sap - version: v1alpha1 - interval: "1m" # in minutes - remoteClusterAccessRef: - name: crate-cluster - namespace: test-monitoring - # Uses default DataSink (named "default" in metrics-operator-system namespace) - # To use a custom DataSink, uncomment and specify: - # dataSinkRef: - # name: custom-sink ---- -apiVersion: metrics.cloud.sap/v1alpha1 -kind: Metric -metadata: - name: crate-dataplane-metric -spec: - name: crate-dataplane-metric - description: Number of DataPlanes in the Crate cluster - target: - kind: DataPlane - group: cola.cloud.sap - version: v1alpha1 - interval: "1m" # in minutes - remoteClusterAccessRef: - name: crate-cluster - namespace: test-monitoring - # Uses default DataSink (named "default" in metrics-operator-system namespace) - # To use a custom DataSink, uncomment and specify: - # dataSinkRef: - # name: custom-sink ---- diff --git a/examples/sample-secret b/examples/sample-secret deleted file mode 100644 index 9e320d9..0000000 --- a/examples/sample-secret +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: co-dynatrace-credentials - namespace: co-metrics-operator -type: Opaque -stringData: - Token: "dt0c01.Zzxxxxxxxxxxx" - Host: "apm.xxxx.xxxx.com" - Path: "/e/1xxxxx/api/v2" ---- -apiVersion: v1 -kind: Namespace -metadata: - name: co-metrics-operator diff --git a/examples/v1beta1/dummy_cr.yaml b/examples/v1beta1/dummy_cr.yaml deleted file mode 100644 index 8088085..0000000 --- a/examples/v1beta1/dummy_cr.yaml +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: example.com/v1 -kind: KubeConfig -metadata: - name: my-kubeconfig - namespace: default -spec: - kubeConfig: | - apiVersion: v1 - clusters: - - cluster: - certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQ1akNDQWs2Z0F3SUJBZ0lRY2lFcEVSUjBNNkJUQTdFZ2RKb1NKREFOQmdrcWhraUc5dzBCQVFzRkFEQU4KTVFzd0NRWURWUVFERXdKallUQWVGdzB5TkRBNE1EZ3dOelV4TWpKYUZ3MHpOREE0TURnd056VXhNakphTUEweApDekFKQmdOVkJBTVRBbU5oTUlJQm9qQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FZOEFNSUlCaWdLQ0FZRUF0dktLClI1cnc5QW5uUUl5clJqMXZjYzd1b0xmNEdsUlhJQm91eVR5aGI0d01VckJUQ3RIQWtnOGluc3E5R20zeTE3Zk4KVVd3OUsyREJ1LzdTSDFSaTRGc29yRk1RaTdPaTZYNWJlTFJOVHQwZEJOQXJtYlZSeHJRTjhYK01iUDdGNFdGNwo4NW40a2Z1b0VrMFVYVWlra2tnaG1FRzRYRlR6Q3U4MThaWWdnWDFiUHN2cHpnd2lNdDFhUEplOEROWmZsa2VyClg2WksyWVlobHVXaXJkckFRT0dWOHp0d2RKMnlhekdjSDcwN1lXWGgxZXFLTHJjN1VrZVlZYmxQT1JqTllVdncKVWFsdExjcWdWb09mdjZLUzlaMjEwZ09zN28wdm9kUGFaTTJSRzBxSFh2U2tqaG84NmZDRkRycG5EVWRLRHJLUgpLWWpBY0wzY0k0REt1NmlKUk9vTmlXMEdvbTUxdCtuK3FaM1BHbThoTXdtbGtQa1BySzFmRFFXSnVqUDZmVmhkCmxpQ2hOb1hiTytyVXNiQVk5T3hJbU44c1F2aXU2U2JFTWNOUTh3dHZuMVBRSVNVTXh1Y0pqd0E2T3lEQi9uWHAKSnIxWk9mdHFVak1FMllKeklZdGxZQ3pYQmN6eC9UVVQ3cWhWRDlTYkVBRGpEdDRCTlV4MUF4L2xhaHR4QWdNQgpBQUdqUWpCQU1BNEdBMVVkRHdFQi93UUVBd0lCcGpBUEJnTlZIUk1CQWY4RUJUQURBUUgvTUIwR0ExVWREZ1FXCkJCUTJ5VjRQRnMvR1pEZXlPNlJBNUdQSXpxMloyVEFOQmdrcWhraUc5dzBCQVFzRkFBT0NBWUVBYmIwMFRxQmwKQjNISzl6VEM2T0QweExSNWdIZjhrQ2t2b05oeVFyNnpaOW1DaXVmdVZhOEIwWUdJYzlDbXZGaTBMK2pXbThsZgpOdENTd1R6VlVwTFBNUlJVc1d3L3BBQjNGaDdnQWFPdXBkZEh3Z3gxYUtNMUVPVEl5T2xkazVwMzhOYlUvNVV4CnhIWGhoS3RDV1pFS1pNNHV3Sjh6REtWc2FwZ0RLU1JETnVNcW9TZFFLNFIxNklkZmRxeExCQmNjZSsyb0hQbHYKVHNhSkJtMkkwaWRjOWF5SVY4c0xjVmx4UmwvQXVsVUhqeEtDSlVuK3lWeWNEY1I1bEpHR21qZlozejJyTCttawpaMWtydmYxaG9QNVVadWt2bHdPUHNJWjNaT21PZlJBeUk0bWIvZXVKV1dtdzhYdmtyZXo0bktiRHZ6WXRnOEsrCktZS0hBc29NM2tsQjJYNlZXRzl3NjJqTW5wRWdHMHNuTUNSNng3WXNvTU1nNkwwdWxwTmhONzBGZ05SamlJS1gKeW42ODBKQ2I4N0dSSzNvYTMrcFdkbzZOWGhPclZoOEViWnp6cHhZR1pBNTB3QlBwbkFBLzNaakR0Y3BCeUVCZApQdThzZGJ5a0U0d0xkaXU5VjBLbVd1dDQrNlg1aCtWb3V0OU5wa0haV3NENSt0S0orYlFxcm01NQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== - server: https://api.fwijenvzjrnno7l.laasds.shoot.live.k8s-hana.ondemand.com - name: cluster - contexts: - - context: - cluster: cluster - user: admin - name: cluster - current-context: cluster - kind: Config - preferences: {} - users: - - name: admin - user: - token: eyJhbGciOiJSUzI1NiIsImtpZCI6ImFORTVEcUhsdzc1dFJ2aDNCcHUza094UFpSZmhQOWdyemQtTDgwRUROSUkifQ.eyJhdWQiOlsia3ViZXJuZXRlcyIsImdhcmRlbmVyIl0sImV4cCI6MTczODY1NjE0NCwiaWF0IjoxNzIzMTA0MTQ0LCJpc3MiOiJodHRwczovL2FwaS5md2lqZW52empybm5vN2wubGFhc2RzLmludGVybmFsLmxpdmUuazhzLm9uZGVtYW5kLmNvbSIsImp0aSI6IjU3MTQ2NjRlLTgwN2YtNDg5Yi1iYzAxLTkyMjYyZTUxOWMzYyIsImt1YmVybmV0ZXMuaW8iOnsibmFtZXNwYWNlIjoiY29sYS1zeXN0ZW0iLCJzZXJ2aWNlYWNjb3VudCI6eyJuYW1lIjoiYWRtaW4iLCJ1aWQiOiI2OGJiNGYyZS01MjljLTQ3M2QtYmNmMi0xZmYwNDlmNTM0NjQifX0sIm5iZiI6MTcyMzEwNDE0NCwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50OmNvbGEtc3lzdGVtOmFkbWluIn0.PU_-6wbzxZlaQyzW9-NHvxzBHYEjmS6u929llv2coaW80KW27B7_Hbhpn20QzBLAbpyJ2gV8d2koU8sALQJVwHnW7FhYGSEA-qCAi0svcDaFnpRenxXANzNGly8l4PubgFBSS0hLu_lWu-h3mOYVp4tcLGS7RKzvThQuxxvg-7CUtuqkM_cfrzQ-Uvgdz-jOAwQI25mSLoqfelgPppHzcUyWA9mv2bHer4I45t44euXuim4t90uXVMvlms-5jwHSLMClYJcGSdrgXfXQJcI8dRd_NQn3SRC-srvSVZEobFWzqtEyVlVeftIvsZMDPO0zmcAex5XLo9CcKguXdl-5IfCCcS0CIHDz7RO6SEWRHHRGplJy-YbaBwZAXK7z-ZDGNc9v4HNTIEMP1CEMwKjrNus5s9f6v_UUsFjg50RrGn5BN0v4ukTynhvLk9CveYXbiMaWl1EUCOdSK3DZ3Fqdk1iKsw6cVq6iMz8OWy-AaRLFi5U60kcV-m-qwJ6nyCYLyyc_L7AqpRPsA9_msESKbF1awzF3J60CgWPv9pL_cYc4g5MQVCKlaRxYIr_jwNRyhqmJ_brlm13u8RukanQxqkJXE6vnhKJ2pwqdcUV71_0TYVXqDIjRmghMNoNhyLRQANDHN9ZgVSFPZoKcWC8fGzZbUE_pWpWgXymY_wZ-N20 ---- -apiVersion: example.com/v1 -kind: KubeConfig -metadata: - name: my-kubeconfig2 - namespace: default -spec: - kubeConfig: | - apiVersion: v1 - clusters: - - cluster: - certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQ1akNDQWs2Z0F3SUJBZ0lRY2lFcEVSUjBNNkJUQTdFZ2RKb1NKREFOQmdrcWhraUc5dzBCQVFzRkFEQU4KTVFzd0NRWURWUVFERXdKallUQWVGdzB5TkRBNE1EZ3dOelV4TWpKYUZ3MHpOREE0TURnd056VXhNakphTUEweApDekFKQmdOVkJBTVRBbU5oTUlJQm9qQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FZOEFNSUlCaWdLQ0FZRUF0dktLClI1cnc5QW5uUUl5clJqMXZjYzd1b0xmNEdsUlhJQm91eVR5aGI0d01VckJUQ3RIQWtnOGluc3E5R20zeTE3Zk4KVVd3OUsyREJ1LzdTSDFSaTRGc29yRk1RaTdPaTZYNWJlTFJOVHQwZEJOQXJtYlZSeHJRTjhYK01iUDdGNFdGNwo4NW40a2Z1b0VrMFVYVWlra2tnaG1FRzRYRlR6Q3U4MThaWWdnWDFiUHN2cHpnd2lNdDFhUEplOEROWmZsa2VyClg2WksyWVlobHVXaXJkckFRT0dWOHp0d2RKMnlhekdjSDcwN1lXWGgxZXFLTHJjN1VrZVlZYmxQT1JqTllVdncKVWFsdExjcWdWb09mdjZLUzlaMjEwZ09zN28wdm9kUGFaTTJSRzBxSFh2U2tqaG84NmZDRkRycG5EVWRLRHJLUgpLWWpBY0wzY0k0REt1NmlKUk9vTmlXMEdvbTUxdCtuK3FaM1BHbThoTXdtbGtQa1BySzFmRFFXSnVqUDZmVmhkCmxpQ2hOb1hiTytyVXNiQVk5T3hJbU44c1F2aXU2U2JFTWNOUTh3dHZuMVBRSVNVTXh1Y0pqd0E2T3lEQi9uWHAKSnIxWk9mdHFVak1FMllKeklZdGxZQ3pYQmN6eC9UVVQ3cWhWRDlTYkVBRGpEdDRCTlV4MUF4L2xhaHR4QWdNQgpBQUdqUWpCQU1BNEdBMVVkRHdFQi93UUVBd0lCcGpBUEJnTlZIUk1CQWY4RUJUQURBUUgvTUIwR0ExVWREZ1FXCkJCUTJ5VjRQRnMvR1pEZXlPNlJBNUdQSXpxMloyVEFOQmdrcWhraUc5dzBCQVFzRkFBT0NBWUVBYmIwMFRxQmwKQjNISzl6VEM2T0QweExSNWdIZjhrQ2t2b05oeVFyNnpaOW1DaXVmdVZhOEIwWUdJYzlDbXZGaTBMK2pXbThsZgpOdENTd1R6VlVwTFBNUlJVc1d3L3BBQjNGaDdnQWFPdXBkZEh3Z3gxYUtNMUVPVEl5T2xkazVwMzhOYlUvNVV4CnhIWGhoS3RDV1pFS1pNNHV3Sjh6REtWc2FwZ0RLU1JETnVNcW9TZFFLNFIxNklkZmRxeExCQmNjZSsyb0hQbHYKVHNhSkJtMkkwaWRjOWF5SVY4c0xjVmx4UmwvQXVsVUhqeEtDSlVuK3lWeWNEY1I1bEpHR21qZlozejJyTCttawpaMWtydmYxaG9QNVVadWt2bHdPUHNJWjNaT21PZlJBeUk0bWIvZXVKV1dtdzhYdmtyZXo0bktiRHZ6WXRnOEsrCktZS0hBc29NM2tsQjJYNlZXRzl3NjJqTW5wRWdHMHNuTUNSNng3WXNvTU1nNkwwdWxwTmhONzBGZ05SamlJS1gKeW42ODBKQ2I4N0dSSzNvYTMrcFdkbzZOWGhPclZoOEViWnp6cHhZR1pBNTB3QlBwbkFBLzNaakR0Y3BCeUVCZApQdThzZGJ5a0U0d0xkaXU5VjBLbVd1dDQrNlg1aCtWb3V0OU5wa0haV3NENSt0S0orYlFxcm01NQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== - server: https://api.fwijenvzjrnno7l.laasds.shoot.live.k8s-hana.ondemand.com - name: cluster - contexts: - - context: - cluster: cluster - user: admin - name: cluster - current-context: cluster - kind: Config - preferences: {} - users: - - name: admin - user: - token: eyJhbGciOiJSUzI1NiIsImtpZCI6ImFORTVEcUhsdzc1dFJ2aDNCcHUza094UFpSZmhQOWdyemQtTDgwRUROSUkifQ.eyJhdWQiOlsia3ViZXJuZXRlcyIsImdhcmRlbmVyIl0sImV4cCI6MTczODY1NjE0NCwiaWF0IjoxNzIzMTA0MTQ0LCJpc3MiOiJodHRwczovL2FwaS5md2lqZW52empybm5vN2wubGFhc2RzLmludGVybmFsLmxpdmUuazhzLm9uZGVtYW5kLmNvbSIsImp0aSI6IjU3MTQ2NjRlLTgwN2YtNDg5Yi1iYzAxLTkyMjYyZTUxOWMzYyIsImt1YmVybmV0ZXMuaW8iOnsibmFtZXNwYWNlIjoiY29sYS1zeXN0ZW0iLCJzZXJ2aWNlYWNjb3VudCI6eyJuYW1lIjoiYWRtaW4iLCJ1aWQiOiI2OGJiNGYyZS01MjljLTQ3M2QtYmNmMi0xZmYwNDlmNTM0NjQifX0sIm5iZiI6MTcyMzEwNDE0NCwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50OmNvbGEtc3lzdGVtOmFkbWluIn0.PU_-6wbzxZlaQyzW9-NHvxzBHYEjmS6u929llv2coaW80KW27B7_Hbhpn20QzBLAbpyJ2gV8d2koU8sALQJVwHnW7FhYGSEA-qCAi0svcDaFnpRenxXANzNGly8l4PubgFBSS0hLu_lWu-h3mOYVp4tcLGS7RKzvThQuxxvg-7CUtuqkM_cfrzQ-Uvgdz-jOAwQI25mSLoqfelgPppHzcUyWA9mv2bHer4I45t44euXuim4t90uXVMvlms-5jwHSLMClYJcGSdrgXfXQJcI8dRd_NQn3SRC-srvSVZEobFWzqtEyVlVeftIvsZMDPO0zmcAex5XLo9CcKguXdl-5IfCCcS0CIHDz7RO6SEWRHHRGplJy-YbaBwZAXK7z-ZDGNc9v4HNTIEMP1CEMwKjrNus5s9f6v_UUsFjg50RrGn5BN0v4ukTynhvLk9CveYXbiMaWl1EUCOdSK3DZ3Fqdk1iKsw6cVq6iMz8OWy-AaRLFi5U60kcV-m-qwJ6nyCYLyyc_L7AqpRPsA9_msESKbF1awzF3J60CgWPv9pL_cYc4g5MQVCKlaRxYIr_jwNRyhqmJ_brlm13u8RukanQxqkJXE6vnhKJ2pwqdcUV71_0TYVXqDIjRmghMNoNhyLRQANDHN9ZgVSFPZoKcWC8fGzZbUE_pWpWgXymY_wZ-N20 diff --git a/examples/v1beta1/dummy_crd.yaml b/examples/v1beta1/dummy_crd.yaml deleted file mode 100644 index f59897e..0000000 --- a/examples/v1beta1/dummy_crd.yaml +++ /dev/null @@ -1,29 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: kubeconfigs.example.com -spec: - group: example.com - versions: - - name: v1 - served: true - storage: true - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - kubeConfig: - type: string - description: "The kubeconfig to be stored" - required: - - kubeConfig - scope: Namespaced - names: - plural: kubeconfigs - singular: kubeconfig - kind: KubeConfig - shortNames: - - kc diff --git a/examples/v1beta1/fedclusteraccess.yaml b/examples/v1beta1/fedclusteraccess.yaml deleted file mode 100644 index dbe89a2..0000000 --- a/examples/v1beta1/fedclusteraccess.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: metrics.cloud.sap/v1beta1 -kind: FederatedClusterAccess -metadata: - name: federate-ca-sample - namespace: default -spec: - target: - group: core.orchestrate.cloud.sap - resource: controlplanes #plural always, lowecase only - version: v1beta1 - kubeConfigPath: spec.target.kubeconfig #case sensitive -#--- -#apiVersion: metrics.cloud.sap/v1beta1 -#kind: FederatedClusterAccess -#metadata: -# name: federate-ca-sample -# namespace: default -#spec: -# target: -# group: example.com -# resource: kubeconfigs #plural always, lowecase only -# version: v1 -# kubeConfigPath: spec.kubeConfig #case sensitive diff --git a/examples/v1beta1/fedmetric.yaml b/examples/v1beta1/fedmetric.yaml deleted file mode 100644 index 9a30267..0000000 --- a/examples/v1beta1/fedmetric.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: metrics.cloud.sap/v1alpha1 -kind: FederatedMetric -metadata: - name: xfed-prov -spec: - name: xfed-prov - description: crossplane providers - target: - group: pkg.crossplane.io - kind: Provider - version: v1 - interval: "1m" # in minutes - projections: - - name: package - fieldPath: "spec.package" - federateClusterAccessRef: - name: federate-ca-sample - namespace: default - # Uses default DataSink (named "default" in metrics-operator-system namespace) - # To use a custom DataSink, uncomment and specify: - # dataSinkRef: - # name: custom-sink ---- diff --git a/internal/config/external_config_real_test.go b/internal/config/external_config_real_test.go deleted file mode 100644 index 9964396..0000000 --- a/internal/config/external_config_real_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package config - -// -// import ( -// "context" -// "fmt" -// "testing" -// -// v1 "github.com/SAP/metrics-operator/api/v1alpha1" -// metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -// "k8s.io/apimachinery/pkg/runtime/schema" -// "k8s.io/client-go/dynamic" -// "k8s.io/client-go/tools/clientcmd" -// "sigs.k8s.io/controller-runtime/pkg/client" -//) -// -// func TestCreateExternalQueryConfig_REAL(t *testing.T) { -// -// ctx := context.TODO() -// -// rcaRef := &v1.RemoteClusterAccessRef{Name: "crate-cluster", Namespace: "test-monitoring"} -// -// restconfig, errrc := clientcmd.BuildConfigFromFlags("", "/Users/I073426/Desktop/metric-demo/dev-core.yaml") -// if errrc != nil { -// fmt.Println(errrc) -// } -// -// // Test parameters -// //saName := "mcp-operator" -// //saNamespace := "cola-system" -// //audience := "crate" -// -// // Create the client -// inClient, err := client.New(restconfig, client.Options{Scheme: externalScheme}) -// -// queryConfig, err := CreateExternalQueryConfig(ctx, rcaRef, inClient) -// if err != nil { -// t.Errorf("Error: %v", err) -// } -// -// println(queryConfig) -// -// dynamicClient, errDyn := dynamic.NewForConfig(&queryConfig.RestConfig) -// if errDyn != nil { -// fmt.Println(errDyn) -// } -// -// gvr := schema.GroupVersionResource{ -// Group: "cola.cloud.sap", -// Version: "v1alpha1", -// Resource: "managedcontrolplanes", -// } -// -// unstrct, err := dynamicClient.Resource(gvr).List(context.TODO(), metav1.ListOptions{}) -// if err != nil { -// -// //Project.cola.cloud.sap "valentin" is forbidden: User "dev-core:system:serviceaccount:cola-system:mcp-operator" cannot get resource "Project" in API group "cola.cloud.sap" in the namespace "project-valentin" -// -// // Handle error -// fmt.Println(err) -// } -// -// println(unstrct) -//} diff --git a/internal/config/token_manager_test.go b/internal/config/token_manager_test.go index 1c95ea7..983a799 100644 --- a/internal/config/token_manager_test.go +++ b/internal/config/token_manager_test.go @@ -122,38 +122,3 @@ func TestGetToken_Cache_Expired(t *testing.T) { require.NoError(t, err) require.NotEqual(t, tk, rt) } - -// func TestTokenManager(t *testing.T) { -// -// config, errrc := clientcmd.BuildConfigFromFlags("", "/Users/I073426/Desktop/metric-demo/dev-core.yaml") -// if errrc != nil { -// fmt.Println(errrc) -// } -// -// clientset, _ := kubernetes.NewForConfig(config) -// -// tokenManager, err := GetTokenManager(clientset) -// if err != nil { -// panic(err) -// } -// -// token, err := tokenManager.GetToken("cola-system", "mcp-operator", "crate") -// if err != nil { -// // Handle error -// } -// -// tokenManager2, err := GetTokenManager(clientset) -// if err != nil { -// panic(err) -// } -// -// token2, err := tokenManager2.GetToken("cola-system", "mcp-operator", "crate") -// if err != nil { -// // Handle error -// } -// -// require.Equal(t, token, token2) -// -// fmt.Println(token) -// -//} diff --git a/internal/controller/clusteraccess_controller.go b/internal/controller/clusteraccess_controller.go deleted file mode 100644 index 7927cdf..0000000 --- a/internal/controller/clusteraccess_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024. - -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 controller - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - "github.com/SAP/metrics-operator/api/v1alpha1" -) - -// ClusterAccessReconciler reconciles a ClusterAccess object -type ClusterAccessReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=metrics.cloud.sap,resources=clusteraccesses,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=metrics.cloud.sap,resources=clusteraccesses/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=metrics.cloud.sap,resources=clusteraccesses/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. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the ClusterAccess 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.18.4/pkg/reconcile -func (r *ClusterAccessReconciler) Reconcile(ctx context.Context, _ ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *ClusterAccessReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&v1alpha1.RemoteClusterAccess{}). - Complete(r) -}