diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 48d172bb..6d108ea9 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -11,6 +11,7 @@ on: types: - opened - reopened + - synchronize - ready_for_review - converted_to_draft concurrency: @@ -18,11 +19,16 @@ concurrency: cancel-in-progress: true jobs: build: - name: test and build + name: Build and Test runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 + - name: Restore binaries from cache + uses: actions/cache/restore@v4 + with: + path: ./bin + key: binary - name: Setup Go uses: actions/setup-go@v5 with: @@ -33,13 +39,12 @@ jobs: with: scan-type: "fs" ignore-unfixed: true - format: "template" - template: "@/contrib/sarif.tpl" + format: "sarif" output: "trivy-results.sarif" severity: "HIGH,CRITICAL,MEDIUM" vuln-type: "os,library" - name: Upload Trivy scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v2 + uses: github/codeql-action/upload-sarif@v3 with: sarif_file: "trivy-results.sarif" - name: Set output variables @@ -47,7 +52,7 @@ jobs: run: | IMAGE_TAG=${GITHUB_SHA:0:7} echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT - - name: lint and test + - name: Lint, Test and Build if: github.event.pull_request.draft == false env: GO111MODULE: on @@ -57,16 +62,6 @@ jobs: make lint make test TAG=${TAG} make test-e2e - - name: build binary - env: - GO111MODULE: on - TAG: ${{ steps.vars.outputs.IMAGE_TAG }} - run: | - make build - - name: build crosscompile and push to remote registry - env: - TAG: ${{ steps.vars.outputs.IMAGE_TAG }} - run: | if [ -n '${{secrets.REPO_KEY}}' ]; then echo ${{secrets.REPO_KEY}} | docker login --username ${{secrets.REPO_USER}} --password-stdin make publish @@ -74,3 +69,8 @@ jobs: echo "there is no docker secret, just build" make build fi + - name: Prapare binary cache + uses: actions/cache@v4 + with: + path: ./bin + key: binary diff --git a/.github/workflows/operatorhub.yaml b/.github/workflows/operatorhub.yaml new file mode 100644 index 00000000..ab098261 --- /dev/null +++ b/.github/workflows/operatorhub.yaml @@ -0,0 +1,70 @@ +name: Publish OperatorHub release + +on: + workflow_run: + workflows: + - Release + types: + - completed + +jobs: + update: + name: Publish new OperatorHub release + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' && ! contains(github.event.workflow_run.head_branch, '-') }} + strategy: + matrix: + repo: + - fork: VictoriaMetrics/operatorhub-operators + upstream: k8s-operatorhub/community-operators + - fork: VictoriaMetrics/openshift-community-operators-prod + upstream: redhat-openshift-ecosystem/community-operators-prod + - fork: VictoriaMetrics/openshift-certified-operators + upstream: redhat-openshift-ecosystem/certified-operators + steps: + - name: Check out OperatorHub operators repo fork + uses: actions/checkout@v4 + with: + repository: ${{ matrix.repo.upstream }} + ref: main + token: ${{ secrets.VM_BOT_GH_TOKEN }} + path: __k8s-operatorhub-repo + + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.VM_BOT_GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.VM_BOT_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + workdir: __k8s-operatorhub-repo + + - uses: dawidd6/action-download-artifact@v6 + with: + name: olm + workflow: main.yaml + github_token: ${{ secrets.VM_BOT_GH_TOKEN }} + run_id: ${{ github.event.workflow_run.id }} + path: bundle + + - name: Add operatorhub bundle + id: update + run: | + mv bundle/* __k8s-operatorhub-repo/operators/victoriametrics-operator/ + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + push-to-fork: VictoriaMetrics/operatorhub-operators + add-paths: operators/victoriametrics-operator + signoff: true + author: Github Actions + path: __k8s-operatorhub-repo + push-to-fork: ${{ matrix.repo.fork }} + branch: vm-operator-release-{{ github.event.release.tag_name }} + token: ${{ secrets.VM_BOT_GH_TOKEN }} + delete-branch: true + title: "victoriametrics-operator: update operator ${{ github.event.release.tag_name }}" + body: | + Added OLM package for [VictoriaMetrics operator ${{ github.event.release.tag_name }}"](https://github.com/VictoriaMetrics/operator/releases/tag/${{ github.event.release.tag_name }}) + > Auto-generated by `Github Actions Bot` diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9f4876f8..5f5c0104 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,24 +10,36 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + - name: Restore binaries from cache + uses: actions/cache/restore@v4 + with: + path: ./bin + key: binary - name: Setup Go uses: actions/setup-go@v5 with: go-version: "1.22" id: go - - name: build binary + - name: lint, test and build env: TAG: ${{ github.event.release.tag_name }} run: | make lint make test make build - - name: build crosscompile and push to remote registry - env: - TAG: "${{ github.event.release.tag_name }}" - run: | echo ${{secrets.REPO_KEY}} | docker login --username ${{secrets.REPO_USER}} --password-stdin make publish + TAG=${TAG} make olm + - name: Prapare binary cache + uses: actions/cache@v4 + with: + path: ./bin + key: binary + - uses: actions/upload-artifact@v4 + with: + name: olm + path: bundle + retention-days: 1 - name: Upload Release CRDs id: upload-release-crds uses: actions/upload-release-asset@v1 diff --git a/.github/workflows/sandbox.yaml b/.github/workflows/sandbox.yaml index 1cd8989e..b136ac4f 100644 --- a/.github/workflows/sandbox.yaml +++ b/.github/workflows/sandbox.yaml @@ -43,7 +43,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.VM_BOT_GH_TOKEN }} - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v6 with: path: "__vm-ops-repo" branch: sandbox-operator-release-automation diff --git a/.gitignore b/.gitignore index d763546a..63615f67 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,8 @@ Dockerfile.cross .idea bin/ build/_output -bundle_crd.zip +bundle* operator.zip -bundle.Dockerfile coverage.txt doc-print build/_test diff --git a/Dockerfile b/Dockerfile index f36ea18c..a27226c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ ARG REPO +ARG ROOT # Build the manager binary FROM golang:1.22 AS builder @@ -18,21 +19,20 @@ COPY cmd/ cmd/ COPY api/ api/ COPY internal/ internal/ ARG REPO +ARG ROOT # Build # the GOARCH has not a default value to allow the binary be built according to the host where the command # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o ${REPO} ./cmd/${REPO}/... +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o app ${ROOT}/ # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details FROM gcr.io/distroless/static:nonroot -ARG REPO -ENV REPO=${REPO} WORKDIR / -COPY --from=builder /workspace/${REPO} . +COPY --from=builder /workspace/app . USER 65532:65532 -ENTRYPOINT ["/${REPO}"] +ENTRYPOINT ["/app"] diff --git a/Makefile b/Makefile index aae8a25a..5bd54531 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ # Image URL to use all building/pushing image targets REGISTRY ?= docker.io REPO ?= operator +ROOT ?= ./cmd ORG ?= victoriametrics TAG ?= v0.46.0 +VERSION ?= $(TAG:v%=%) NAMESPACE ?= vm BUILDINFO_TAG ?= $(shell echo $$(git describe --long --all | tr '/' '-')$$( \ git diff-index --quiet HEAD -- || echo '-dirty-'$$(git diff-index -u HEAD | openssl sha1 | cut -d' ' -f2 | cut -c 1-8))) @@ -10,6 +12,7 @@ OVERLAY ?= config/default # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. ENVTEST_K8S_VERSION = 1.30.0 +PLATFORM = $(shell uname -o) # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -136,6 +139,7 @@ run: manifests generate fmt vet ## Run a controller from your host. docker-build: ## Build docker image with the manager. $(CONTAINER_TOOL) build \ --build-arg REPO=$(REPO) \ + --build-arg ROOT=$(ROOT) \ ${DOCKER_BUILD_ARGS} \ -t $(REGISTRY)/$(ORG)/$(REPO):$(TAG) \ -t $(REGISTRY)/$(ORG)/$(REPO):$(BUILDINFO_TAG) . @@ -164,6 +168,7 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform --push \ --platform=$(PLATFORMS) \ --build-arg REPO=$(REPO) \ + --build-arg ROOT=$(ROOT) \ ${DOCKER_BUILD_ARGS} \ --tag $(REGISTRY)/$(ORG)/$(REPO):$(TAG) \ --tag $(REGISTRY)/$(ORG)/$(REPO):$(BUILDINFO_TAG) \ @@ -172,8 +177,8 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform rm Dockerfile.cross publish: - REPO=operator $(MAKE) docker-buildx - REPO=config-reloader $(MAKE) docker-buildx + REPO=operator ROOT=./cmd $(MAKE) docker-buildx + REPO=config-reloader ROOT=./cmd/config-reloader $(MAKE) docker-buildx .PHONY: build-installer build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment. @@ -181,6 +186,17 @@ build-installer: manifests generate kustomize ## Generate a consolidated YAML wi cd config/manager && $(KUSTOMIZE) edit set image manager=$(REGISTRY)/$(ORG)/$(REPO):$(TAG) $(KUSTOMIZE) build config/default > dist/install.yaml +olm: operator-sdk docs + rm -rf bundle* + $(OPERATOR_SDK) generate kustomize manifests -q + $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle \ + -q --overwrite --version $(VERSION) --channels=beta --output-dir=bundle/$(VERSION) + $(if $(findstring $(PLATFORM),Darwin), \ + sed -i '', \ + sed -i) 's/$(ORG)\/$(REPO):.*/$(ORG)\/$(REPO):$(TAG)/g' bundle/$(VERSION)/manifests/* + $(OPERATOR_SDK) bundle validate ./bundle/$(VERSION) + cp config/manifests/ci.yaml bundle/ + ##@ Deployment ifndef ignore-not-found @@ -237,6 +253,7 @@ CLIENT_GEN = $(LOCALBIN)/client-gen-$(CODEGENERATOR_VERSION) LISTER_GEN = $(LOCALBIN)/lister-gen-$(CODEGENERATOR_VERSION) INFORMER_GEN = $(LOCALBIN)/informer-gen-$(CODEGENERATOR_VERSION) KIND = $(LOCALBIN)/kind-$(KIND_VERSION) +OPERATOR_SDK = $(LOCALBIN)/operator-sdk-$(OPERATOR_SDK_VERSION) ENVCONFIG_DOCS = $(LOCALBIN)/envconfig-docs-$(ENVCONFIG_DOCS_VERSION) CRD_REF_DOCS = $(LOCALBIN)/crd-ref-docs-$(CRD_REF_DOCS_VERSION) @@ -247,6 +264,7 @@ ENVTEST_VERSION ?= release-0.18 GOLANGCI_LINT_VERSION ?= v1.59.1 CODEGENERATOR_VERSION ?= v0.30.2 KIND_VERSION ?= v0.23.0 +OPERATOR_SDK_VERSION ?= v1.35.0 ENVCONFIG_DOCS_VERSION ?= latest CRD_REF_DOCS_VERSION ?= latest @@ -293,6 +311,11 @@ envtest: $(ENVTEST) ## Download setup-envtest locally if necessary. $(ENVTEST): $(LOCALBIN) $(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION)) +.PHONY: operator-sdk +operator-sdk: $(OPERATOR_SDK) +$(OPERATOR_SDK): $(LOCALBIN) + $(call go-install-tool,$(OPERATOR_SDK),github.com/operator-framework/operator-sdk/cmd/operator-sdk,$(OPERATOR_SDK_VERSION)) + .PHONY: golangci-lint golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. $(GOLANGCI_LINT): $(LOCALBIN) diff --git a/PROJECT b/PROJECT index 72769eba..835c5081 100644 --- a/PROJECT +++ b/PROJECT @@ -171,4 +171,13 @@ resources: conversion: true validation: true webhookVersion: v1 +- api: + crdVersion: v1 + namespaced: true + controller: true + domain: victoriametrics.com + group: operator + kind: VMScrapeConfig + path: github.com/VictoriaMetrics/operator/api/operator/v1beta1 + version: v1beta1 version: "3" diff --git a/api/operator/v1beta1/vmscrapeconfig_types.go b/api/operator/v1beta1/vmscrapeconfig_types.go index d231d12f..6f9ffd5b 100644 --- a/api/operator/v1beta1/vmscrapeconfig_types.go +++ b/api/operator/v1beta1/vmscrapeconfig_types.go @@ -1,9 +1,24 @@ +/* + +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 v1beta1 import ( "fmt" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -243,7 +258,7 @@ type ConsulSDConfig struct { Server string `json:"server"` // Consul ACL TokenRef, if not provided it will use the ACL from the local Consul Agent. // +optional - TokenRef *v1.SecretKeySelector `json:"tokenRef,omitempty"` + TokenRef *corev1.SecretKeySelector `json:"tokenRef,omitempty"` // Consul Datacenter name, if not provided it will use the local Consul Agent Datacenter. // +optional Datacenter *string `json:"datacenter,omitempty"` @@ -334,10 +349,10 @@ type EC2SDConfig struct { Region *string `json:"region"` // AccessKey is the AWS API key. // +optional - AccessKey *v1.SecretKeySelector `json:"accessKey,omitempty"` + AccessKey *corev1.SecretKeySelector `json:"accessKey,omitempty"` // SecretKey is the AWS API secret. // +optional - SecretKey *v1.SecretKeySelector `json:"secretKey,omitempty"` + SecretKey *corev1.SecretKeySelector `json:"secretKey,omitempty"` // AWS Role ARN, an alternative to using AWS API keys. // +optional RoleARN *string `json:"roleARN,omitempty"` @@ -383,7 +398,7 @@ type AzureSDConfig struct { ClientID *string `json:"clientID,omitempty"` // Optional client secret. Only required with the OAuth authentication method. // +optional - ClientSecret *v1.SecretKeySelector `json:"clientSecret,omitempty"` + ClientSecret *corev1.SecretKeySelector `json:"clientSecret,omitempty"` // Optional resource group name. Limits discovery to this resource group. // +optional ResourceGroup *string `json:"resourceGroup,omitempty"` @@ -453,7 +468,7 @@ type OpenStackSDConfig struct { // Password for the Identity V2 and V3 APIs. Consult with your provider's // control panel to discover your account's preferred method of authentication. // +optional - Password *v1.SecretKeySelector `json:"password,omitempty"` + Password *corev1.SecretKeySelector `json:"password,omitempty"` // At most one of domainId and domainName must be provided if using username // with Identity V3. Otherwise, either are optional. // +optional @@ -482,7 +497,7 @@ type OpenStackSDConfig struct { // The applicationCredentialSecret field is required if using an application // credential to authenticate. // +optional - ApplicationCredentialSecret *v1.SecretKeySelector `json:"applicationCredentialSecret,omitempty"` + ApplicationCredentialSecret *corev1.SecretKeySelector `json:"applicationCredentialSecret,omitempty"` // Whether the service discovery should list all instances for all projects. // It is only relevant for the 'instance' role and usually requires admin permissions. // +optional diff --git a/cmd/operator/main.go b/cmd/main.go similarity index 100% rename from cmd/operator/main.go rename to cmd/main.go diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index ac16d999..662cf893 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -75,6 +75,7 @@ patches: #- path: patches/cainjection_in_operator_vmstaticscrapes.yaml #- path: patches/cainjection_in_operator_vmusers.yaml #- path: patches/cainjection_in_operator_vmauths.yaml +#- path: patches/cainjection_in_operator_vmscrapeconfigs.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section diff --git a/config/manifests/bases/victoriametrics-operator.clusterserviceversion.yaml b/config/manifests/bases/victoriametrics-operator.clusterserviceversion.yaml new file mode 100644 index 00000000..4d2bcb0a --- /dev/null +++ b/config/manifests/bases/victoriametrics-operator.clusterserviceversion.yaml @@ -0,0 +1,597 @@ +apiVersion: operators.coreos.com/v1alpha1 +kind: ClusterServiceVersion +metadata: + annotations: + alm-examples: | + [ + { + "apiVersion": "operator.victoriametrics.com/v1beta1", + "kind": "VMAgent", + "metadata": { + "name": "example" + }, + "spec": { + "remoteWrite": [ + { + "url": "http://vmsingle.example.com/" + } + ] + } + }, + { + "apiVersion": "operator.victoriametrics.com/v1beta1", + "kind": "VMSingle", + "metadata": { + "name": "example" + }, + "spec": { + "retentionPeriod": "1h" + } + }, + { + "apiVersion": "operator.victoriametrics.com/v1beta1", + "kind": "VMCluster", + "metadata": { + "name": "example" + }, + "spec": { + "retentionPeriod": "1h" + } + }, + { + "apiVersion": "operator.victoriametrics.com/v1beta1", + "kind": "VMPodScrape", + "metadata": { + "name": "example" + }, + "spec": { + "namespaceSelector": { + "any": true + } + } + }, + { + "apiVersion": "operator.victoriametrics.com/v1beta1", + "kind": "VMNodeScrape", + "metadata": { + "name": "example" + }, + "spec": { + "scheme": "https", + "tlsConfig": { + "insecureSkipVerify": true, + "caFile": "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" + }, + "bearerTokenFile": "/var/run/secrets/kubernetes.io/serviceaccount/token" + } + }, + { + "apiVersion": "operator.victoriametrics.com/v1beta1", + "kind": "VMStaticScrape", + "metadata": { + "name": "example" + }, + "spec": { + "jobName": "static", + "targetEndpoints": [ + { + "targets": ["192.168.0.1:9100", "196.168.0.50:9100"], + "labels": { + "env": "dev", + "project": "operator" + } + } + ] + } + }, + { + "apiVersion": "operator.victoriametrics.com/v1beta1", + "kind": "VMServiceScrape", + "metadata": { + "name": "example" + }, + "spec": { + "selector": { + "matchLabels": { + "app": "example-app" + } + }, + "endpoints": [ + { + "port": "web" + } + ] + } + } + ] + capabilities: Deep Insights + categories: Monitoring + certified: "false" + containerImage: victoriametrics/operator:0.0.0 + createdAt: "2020-05-01 12:00:00" + description: Provides monitoring capabilites for kubernetes clusters and applications + operators.operatorframework.io/builder: operator-sdk-v1.0.0 + operators.operatorframework.io/project_layout: go.kubebuilder.io/v4 + repository: https://github.com/VictoriaMetrics/operator + support: VictoriaMetrics + labels: + operatorframework.io/arch.amd64: supported + operatorframework.io/arch.arm64: supported + operatorframework.io/arch.ppc64le: supported + name: victoriametrics-operator.v0.0.0 + namespace: placeholder +spec: + apiservicedefinitions: {} + customresourcedefinitions: + owned: + - description: VMAgent - is a tiny but brave agent, which helps you collect metrics + from various sources and stores them in VictoriaMetrics or any other Prometheus-compatible + storage system that supports the remote_write protocol. + displayName: VMAgent + kind: VMAgent + name: vmagents.operator.victoriametrics.com + version: v1beta1 + - description: VMAlertmanagerConfig is the Schema for the vmalertmanagerconfigs + API + displayName: VMAlertmanager Config + kind: VMAlertmanagerConfig + name: vmalertmanagerconfigs.operator.victoriametrics.com + version: v1beta1 + - description: VMAlertmanager represents Victoria-Metrics deployment for Alertmanager. + displayName: VMAlertmanager + kind: VMAlertmanager + name: vmalertmanagers.operator.victoriametrics.com + version: v1beta1 + - description: VMAlert executes a list of given alerting or recording rules against + configured address. + displayName: VMAlert + kind: VMAlert + name: vmalerts.operator.victoriametrics.com + version: v1beta1 + - description: VMAuth is the Schema for the vmauths API + displayName: VMAuth + kind: VMAuth + name: vmauths.operator.victoriametrics.com + version: v1beta1 + - description: VMCluster is fast, cost-effective and scalable time-series database. + Cluster version with + displayName: VMCluster + kind: VMCluster + name: vmclusters.operator.victoriametrics.com + version: v1beta1 + - description: VMNodeScrape defines discovery for targets placed on kubernetes + nodes, usually its node-exporters and other host services. InternalIP is used + as __address__ for scraping. + displayName: VMNode Scrape + kind: VMNodeScrape + name: vmnodescrapes.operator.victoriametrics.com + version: v1beta1 + - description: VMPodScrape is scrape configuration for pods, it generates vmagent's + config for scraping pod targets based on selectors. + displayName: VMPod Scrape + kind: VMPodScrape + name: vmpodscrapes.operator.victoriametrics.com + version: v1beta1 + - description: VMProbe defines a probe for targets, that will be executed with + prober, like blackbox exporter. It helps to monitor reachability of target + with various checks. + displayName: VMProbe + kind: VMProbe + name: vmprobes.operator.victoriametrics.com + version: v1beta1 + - description: VMRule defines rule records for vmalert application + displayName: VMRule + kind: VMRule + name: vmrules.operator.victoriametrics.com + version: v1beta1 + - description: VMScrapeConfig specifies a set of targets and parameters describing + how to scrape them. + displayName: VMScrape Config + kind: VMScrapeConfig + name: vmscrapeconfigs.operator.victoriametrics.com + version: v1beta1 + - description: VMServiceScrape is scrape configuration for endpoints associated + with kubernetes service, it generates scrape configuration for vmagent based + on selectors. result config will scrape service endpoints + displayName: VMService Scrape + kind: VMServiceScrape + name: vmservicescrapes.operator.victoriametrics.com + version: v1beta1 + - description: VMSingle is fast, cost-effective and scalable time-series database. + displayName: VMSingle + kind: VMSingle + name: vmsingles.operator.victoriametrics.com + version: v1beta1 + - description: VMStaticScrape defines static targets configuration for scraping. + displayName: VMStatic Scrape + kind: VMStaticScrape + name: vmstaticscrapes.operator.victoriametrics.com + version: v1beta1 + - description: VMUser is the Schema for the vmusers API + displayName: VMUser + kind: VMUser + name: vmusers.operator.victoriametrics.com + version: v1beta1 + description: | + Operator manages VictoriaMetrics applications and provides monitoring features for applications running inside and outside kubernetes cluster. It has support for prometheus-operator objects and + provides migration mechanism. + + Operator desinged to use existing installation of VictoriaMetrics inside or outside kubernetes cluster or it could + bring own resources and fully manages them. + + You can read more about operator at docs: + - quick start [doc](https://github.com/VictoriaMetrics/operator/blob/master/docs/quick-start.md) + - high availability [doc](https://github.com/VictoriaMetrics/operator/blob/master/docs/high-availability.md) + - design and description of implementation [design](https://github.com/VictoriaMetrics/operator/blob/master/docs/design.md) + - operator objects description [doc](https://github.com/VictoriaMetrics/operator/blob/master/docs/api.md) + + # VictoriaMetrics + * VictoriaMetrics can be used as long-term storage for Prometheus or for [vmagent](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/app/vmagent/README.md). + See [these docs](https://github.com/VictoriaMetrics/VictoriaMetrics#prometheus-setup) for details. + * Supports [Prometheus querying API](https://prometheus.io/docs/prometheus/latest/querying/api/), so it can be used as Prometheus drop-in replacement in Grafana. + VictoriaMetrics implements [MetricsQL](https://github.com/VictoriaMetrics/VictoriaMetrics/wiki/MetricsQL) query language, which is inspired by PromQL. + * Supports global query view. Multiple Prometheus instances may write data into VictoriaMetrics. Later this data may be used in a single query. + * High performance and good scalability for both [inserts](https://medium.com/@valyala/high-cardinality-tsdb-benchmarks-victoriametrics-vs-timescaledb-vs-influxdb-13e6ee64dd6b) + and [selects](https://medium.com/@valyala/when-size-matters-benchmarking-victoriametrics-vs-timescale-and-influxdb-6035811952d4). + [Outperforms InfluxDB and TimescaleDB by up to 20x](https://medium.com/@valyala/measuring-vertical-scalability-for-time-series-databases-in-google-cloud-92550d78d8ae). + * [Uses 10x less RAM than InfluxDB](https://medium.com/@valyala/insert-benchmarks-with-inch-influxdb-vs-victoriametrics-e31a41ae2893) when working with millions of unique time series (aka high cardinality). + * Optimized for time series with high churn rate. Think about [prometheus-operator](https://github.com/coreos/prometheus-operator) metrics from frequent deployments in Kubernetes. + * High data compression, so [up to 70x more data points](https://medium.com/@valyala/when-size-matters-benchmarking-victoriametrics-vs-timescale-and-influxdb-6035811952d4) + may be crammed into limited storage comparing to TimescaleDB. + * Optimized for storage with high-latency IO and low IOPS (HDD and network storage in AWS, Google Cloud, Microsoft Azure, etc). See [graphs from these benchmarks](https://medium.com/@valyala/high-cardinality-tsdb-benchmarks-victoriametrics-vs-timescaledb-vs-influxdb-13e6ee64dd6b). + * A single-node VictoriaMetrics may substitute moderately sized clusters built with competing solutions such as Thanos, M3DB, Cortex, InfluxDB or TimescaleDB. + See [vertical scalability benchmarks](https://medium.com/@valyala/measuring-vertical-scalability-for-time-series-databases-in-google-cloud-92550d78d8ae), + [comparing Thanos to VictoriaMetrics cluster](https://medium.com/@valyala/comparing-thanos-to-victoriametrics-cluster-b193bea1683) + and [Remote Write Storage Wars](https://promcon.io/2019-munich/talks/remote-write-storage-wars/) talk + from [PromCon 2019](https://promcon.io/2019-munich/talks/remote-write-storage-wars/). + * Easy operation: + * VictoriaMetrics consists of a single [small executable](https://medium.com/@valyala/stripping-dependency-bloat-in-victoriametrics-docker-image-983fb5912b0d) without external dependencies. + * All the configuration is done via explicit command-line flags with reasonable defaults. + * All the data is stored in a single directory pointed by `-storageDataPath` flag. + * Easy and fast backups from [instant snapshots](https://medium.com/@valyala/how-victoriametrics-makes-instant-snapshots-for-multi-terabyte-time-series-data-e1f3fb0e0282) + to S3 or GCS with [vmbackup](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/app/vmbackup/README.md) / [vmrestore](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/app/vmrestore/README.md). + See [this article](https://medium.com/@valyala/speeding-up-backups-for-big-time-series-databases-533c1a927883) for more details. + * Storage is protected from corruption on unclean shutdown (i.e. OOM, hardware reset or `kill -9`) thanks to [the storage architecture](https://medium.com/@valyala/how-victoriametrics-makes-instant-snapshots-for-multi-terabyte-time-series-data-e1f3fb0e0282). + * Supports metrics' scraping, ingestion and [backfilling](https://github.com/VictoriaMetrics/VictoriaMetrics#backfilling) via the following protocols: + * [Metrics from Prometheus exporters](https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#text-based-format) + such as [node_exporter](https://github.com/prometheus/node_exporter). See [these docs](https://github.com/VictoriaMetrics/VictoriaMetrics#how-to-scrape-prometheus-exporters-such-as-node-exporter) for details. + * [Prometheus remote write API](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_write) + * [InfluxDB line protocol](https://github.com/VictoriaMetrics/VictoriaMetrics#how-to-send-data-from-influxdb-compatible-agents-such-as-telegraf) over HTTP, TCP and UDP. + * [Graphite plaintext protocol](https://github.com/VictoriaMetrics/VictoriaMetrics#how-to-send-data-from-graphite-compatible-agents-such-as-statsd) with [tags](https://graphite.readthedocs.io/en/latest/tags.html#carbon) + if `-graphiteListenAddr` is set. + * [OpenTSDB put message](https://github.com/VictoriaMetrics/VictoriaMetrics#sending-data-via-telnet-put-protocol) if `-opentsdbListenAddr` is set. + * [HTTP OpenTSDB /api/put requests](https://github.com/VictoriaMetrics/VictoriaMetrics#sending-opentsdb-data-via-http-apiput-requests) if `-opentsdbHTTPListenAddr` is set. + * [How to import time series data](https://github.com/VictoriaMetrics/VictoriaMetrics#how-to-import-time-series-data). + * [Prometheus exposition format](https://github.com/VictoriaMetrics/VictoriaMetrics#how-to-import-data-in-prometheus-exposition-format). + * [Arbitrary CSV data](https://github.com/VictoriaMetrics/VictoriaMetrics#how-to-import-csv-data). + * Supports metrics' relabeling. See [these docs](https://github.com/VictoriaMetrics/VictoriaMetrics#relabeling) for details. + * Ideally works with big amounts of time series data from Kubernetes, IoT sensors, connected cars, industrial telemetry, financial data and various Enterprise workloads. + displayName: VictoriaMetrics Operator + icon: + - base64data: iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAARuklEQVR4nOxdfawc11U/5+7nc/xmdl+WuvkwoaX8UTXkA5WAmsQfaRulpC44IuEjLaoS2hSswh8JSFAELVQCCYKg0DZOUwSFELWBNtSBVGka28ShIkXEDo7yB3GD65rU9PnNzD5/7NfMQWf23H3X45l9W8fu3n0zP+nZ783O3jln7u/ee+7vnjujoECuURAg5ygIkHMUBMg5CgLkHAUBco6CADlHQYCcoyBAzlEQIOcoCJBzFATIOQoC5BwFAXKOggA5R0GAnKMgQM5RECDnKAiQcxQEyDkKAuQcBQFyjoIAOUdBgJyjIEDOURAg5ygIkHOUp23ABQZm/J72N435O/nZmkHyJswSMOVHV1QkP+cTyugx9bWSPzOHWSKArgCUyg0n+E651WrNdTqderVarQ8Gg1o5iqpUqZSjKCojYlxpRIRKqQH2+4OBUr1yudzt9Xqder3eWVxcPA0AgwmuVRL76AIR8ILAdgLomzpIaWGlVqu1gXq9jYR4BQFcgYiXE9ElAPADANAEAAcBLiKAOQCoypBXWuWaoVyvhwCnCeAkALQBwAOA7yLiq0T0bQQ4jESHsVo9sri4eCyFkCjXm5SsU4GNBECppDNaXaPRuAIArkWi6wDgGgD4EQC4DADmENPdIMrslbM+SC1olfK5hzgKAP8NAPsJ8TkAeN73/cOJ08tCBKuGCtsIUDYrfmF+/m2k1E8DwDsA4EpErI7OJNJ3Une3+sai4VfyfxOrBYHmMfN/8zrxsBQXZJCEiHoAcBAAnsIo+qel5eV/y/Jx2rCJACVpIeWm43wIEO9BgCv1jZXWpocCNOKBaftAxrivbSuPeo0hUQ8C0U6v3X5AfLCGBNO+eRpx5T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EgFMlDvd7r/P1WovAsAdxrsFTRKMniqKSt1Wr9UGohWQsT9QJTJ+9AOdPoJK/aUcSxN4Vh4KCXC7127/TUYiqPWYhSAwC7qb3oxEX0WACqWngY82kxLA44D4W57nHUwrsNlsXglEf4gA7x6z2bOvr0WI7/R9f6/N07zVMMsEAK3RxxU31AoWMqZoZGQYQSz6ED0LAK/I528AxOuB6HrJGMra7Kmnmksyxz+YsQNpZjDrBADd+i6++OLLosGASfDDY7SCgfEk77Mg6d9pXT4YU8xDqlzefPz48aOz3PI11gIBQFfEhg0bLup2Ok8rxOvGkMB8p5+pA4x7N2Fc+RHRc7V6/aZjx46lrRPMJNYKASCxb3+XjONZgtGkMHMBH/d8f1vyWrOOWZ0FpCEavXKm03mkXqtdhsNkz+gcXzmjBR6OGz7jBYGZYWTNcu5rxVoiACQEo10JwSj6HpTPMCHw3DtrAs+kWGsEgKRgNFerHUXE92RoBWnQ+wd4OvCBpSD401kUeCbFWooBkhilbcnbRnZJd94zRCATkX6/L08DkWib8daPtH0GawJrmQAaplbwJUR8E6y8jl5X6mhmSEQvg1Lb18IcfxLkgQBgTNnKjUZjBxDdiQBvAYB18vkpAngREB/2ff+ThvY/89O81ZAXAkAyem+tW3fJoFrdwL+Xe71ji6dOvZp1boG1AxyjC4z7bM0iV84mkBYEFiiQL8xCSliBC4iCADlHQYCcoyBAzlEQIOcoCJBzFATIOQoC5BwFAXKOggA5R0GAnKMgQM5RECDnKAiQcxQEyDkKAuQcBQFyjoIAOUdBgJyjIEDOURAg5ygIkHMUBMg5CgLkHAUBco6CADnH/wcAAP//XWOHWC5Ltq8AAAAASUVORK5CYII= + mediatype: image/png + install: + spec: + clusterPermissions: + - rules: + - apiGroups: + - "" + resources: + - configmaps + verbs: + - '*' + - apiGroups: + - "" + resources: + - endpoints + verbs: + - '*' + - apiGroups: + - "" + resources: + - events + verbs: + - '*' + - apiGroups: + - "" + resources: + - namespaces + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - persistentvolumeclaims + verbs: + - '*' + - apiGroups: + - "" + resources: + - pods + verbs: + - list + - watch + - get + - apiGroups: + - "" + resources: + - secrets + verbs: + - '*' + - apiGroups: + - "" + resources: + - services + verbs: + - '*' + - apiGroups: + - "" + resources: + - services/finalizers + verbs: + - '*' + - apiGroups: + - apps + resources: + - deployments + verbs: + - '*' + - apiGroups: + - apps + resources: + - replicasets + verbs: + - '*' + - apiGroups: + - apps + resources: + - statefulsets + verbs: + - '*' + - apiGroups: + - monitoring.coreos.com + resources: + - '*' + verbs: + - '*' + - apiGroups: + - operator.victoriametrics.com + resources: + - vmagents + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - operator.victoriametrics.com + resources: + - vmagents/status + verbs: + - get + - patch + - update + - apiGroups: + - operator.victoriametrics.com + resources: + - vmalertmanagers + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - operator.victoriametrics.com + resources: + - vmalertmanagers/status + verbs: + - get + - patch + - update + - apiGroups: + - operator.victoriametrics.com + resources: + - vmalerts + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - operator.victoriametrics.com + resources: + - vmalerts/status + verbs: + - get + - patch + - update + - apiGroups: + - operator.victoriametrics.com + resources: + - vmclusters + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - operator.victoriametrics.com + resources: + - vmclusters/status + verbs: + - get + - patch + - update + - apiGroups: + - operator.victoriametrics.com + resources: + - vmpodscrapes + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - operator.victoriametrics.com + resources: + - vmpodscrapes/status + verbs: + - get + - patch + - update + - apiGroups: + - operator.victoriametrics.com + resources: + - vmrules + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - operator.victoriametrics.com + resources: + - vmrules/status + verbs: + - get + - patch + - update + - apiGroups: + - operator.victoriametrics.com + resources: + - vmservicescrapes + - vmscrapeconfigs + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - operator.victoriametrics.com + resources: + - vmservicescrapes/status + - vmscrapeconfigs/status + verbs: + - get + - patch + - update + - apiGroups: + - operator.victoriametrics.com + resources: + - vmprobes + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - operator.victoriametrics.com + resources: + - vmprobes/status + verbs: + - get + - patch + - update + - apiGroups: + - operator.victoriametrics.com + resources: + - vmsingles + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - operator.victoriametrics.com + resources: + - vmsingles/status + verbs: + - get + - patch + - update + - apiGroups: + - "" + - networking.k8s.io + - extensions + - discovery.k8s.io + resources: + - nodes + - nodes/metrics + - services + - endpoints + - endpointslices + - pods + - app + - ingresses + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - configmaps + verbs: + - get + - nonResourceURLs: + - /metrics + verbs: + - get + serviceAccountName: vmagent + deployments: null + strategy: "" + installModes: + - supported: true + type: OwnNamespace + - supported: true + type: SingleNamespace + - supported: false + type: MultiNamespace + - supported: true + type: AllNamespaces + keywords: + - monitoring + - prometheus + - victoriametrics + links: + - name: VictoriaMetrics + url: https://victoriametrics.com + maintainers: + - email: nik@victoriametrics.com + name: f41gh7 + - email: info@victoriametrics.com + name: info + maturity: beta + minKubeVersion: 1.27.0 + provider: + name: VictoriaMetrics + version: 0.0.0 diff --git a/config/manifests/ci.yaml b/config/manifests/ci.yaml new file mode 100644 index 00000000..f0e53b12 --- /dev/null +++ b/config/manifests/ci.yaml @@ -0,0 +1,10 @@ +--- +# Use `replaces-mode` or `semver-mode`. Once you switch to `semver-mode`, there is no easy way back. +updateGraph: replaces-mode +packagemanifestClusterVersionLabel: auto +addReviewers: true +reviewers: + - f41gh7 + - k1rk + - Amper + - Haleygo diff --git a/config/manifests/kustomization.yaml b/config/manifests/kustomization.yaml new file mode 100644 index 00000000..ecbcca00 --- /dev/null +++ b/config/manifests/kustomization.yaml @@ -0,0 +1,2 @@ +resources: +- ../default diff --git a/config/rbac/kustomization.yaml b/config/rbac/kustomization.yaml index f7c2e242..112007e0 100644 --- a/config/rbac/kustomization.yaml +++ b/config/rbac/kustomization.yaml @@ -13,6 +13,8 @@ resources: # default, aiding admins in cluster management. Those roles are # not used by the Project itself. You can comment the following lines # if you do not want those helpers be installed with your Project. +- operator_vmscrapeconfig_editor_role.yaml +- operator_vmscrapeconfig_viewer_role.yaml - operator_vmauth_editor_role.yaml - operator_vmauth_viewer_role.yaml - operator_vmuser_editor_role.yaml @@ -41,3 +43,5 @@ resources: - operator_vmalert_viewer_role.yaml - operator_vmagent_editor_role.yaml - operator_vmagent_viewer_role.yaml + + diff --git a/config/rbac/operator_vmscrapeconfig_editor_role.yaml b/config/rbac/operator_vmscrapeconfig_editor_role.yaml new file mode 100644 index 00000000..3876f8c2 --- /dev/null +++ b/config/rbac/operator_vmscrapeconfig_editor_role.yaml @@ -0,0 +1,27 @@ +# permissions for end users to edit vmscrapeconfigs. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: victoriametrics-operator + app.kubernetes.io/managed-by: kustomize + name: operator-vmscrapeconfig-editor-role +rules: +- apiGroups: + - operator.victoriametrics.com + resources: + - vmscrapeconfigs + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - operator.victoriametrics.com + resources: + - vmscrapeconfigs/status + verbs: + - get diff --git a/config/rbac/operator_vmscrapeconfig_viewer_role.yaml b/config/rbac/operator_vmscrapeconfig_viewer_role.yaml new file mode 100644 index 00000000..47423cbd --- /dev/null +++ b/config/rbac/operator_vmscrapeconfig_viewer_role.yaml @@ -0,0 +1,23 @@ +# permissions for end users to view vmscrapeconfigs. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: victoriametrics-operator + app.kubernetes.io/managed-by: kustomize + name: operator-vmscrapeconfig-viewer-role +rules: +- apiGroups: + - operator.victoriametrics.com + resources: + - vmscrapeconfigs + verbs: + - get + - list + - watch +- apiGroups: + - operator.victoriametrics.com + resources: + - vmscrapeconfigs/status + verbs: + - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 23cb8de2..0a754877 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -338,20 +338,6 @@ rules: - update - watch - delete -- apiGroups: - - "policy" - resources: - - podsecuritypolicies - - podsecuritypolicies/finalizers - verbs: - - get - - list - - create - - patch - - update - - use - - watch - - delete - apiGroups: - "" resources: diff --git a/docs/vars.md b/docs/vars.md index 0b1fa318..86b0655d 100644 --- a/docs/vars.md +++ b/docs/vars.md @@ -10,7 +10,7 @@ menu: # Auto Generated vars for package config - updated at Tue Jul 2 15:08:03 UTC 2024 + updated at Wed Jul 3 10:11:07 UTC 2024 | variable name | variable default value | variable required | variable description | diff --git a/internal/controller/operator/controllers.go b/internal/controller/operator/controllers.go index eceb37f5..ee5bdc3a 100644 --- a/internal/controller/operator/controllers.go +++ b/internal/controller/operator/controllers.go @@ -1,4 +1,4 @@ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/controllers_test.go b/internal/controller/operator/controllers_test.go index 3eae0e9b..47192d6d 100644 --- a/internal/controller/operator/controllers_test.go +++ b/internal/controller/operator/controllers_test.go @@ -1,4 +1,4 @@ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/objects_stat.go b/internal/controller/operator/objects_stat.go index 766e673a..3ca02c6d 100644 --- a/internal/controller/operator/objects_stat.go +++ b/internal/controller/operator/objects_stat.go @@ -1,4 +1,4 @@ -package controller +package operator import ( "fmt" diff --git a/internal/controller/operator/suite_test.go b/internal/controller/operator/suite_test.go index 3740637a..33631279 100644 --- a/internal/controller/operator/suite_test.go +++ b/internal/controller/operator/suite_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "fmt" @@ -71,27 +71,6 @@ var _ = BeforeSuite(func(done Done) { err = vmv1beta1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) - err = vmv1beta1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - err = vmv1beta1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - err = vmv1beta1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - err = vmv1beta1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - err = vmv1beta1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - err = vmv1beta1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - err = vmv1beta1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - // +kubebuilder:scaffold:scheme k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) diff --git a/internal/controller/operator/vmagent_controller.go b/internal/controller/operator/vmagent_controller.go index 9eaba336..e0719760 100644 --- a/internal/controller/operator/vmagent_controller.go +++ b/internal/controller/operator/vmagent_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmagent_controller_test.go b/internal/controller/operator/vmagent_controller_test.go index 5783cc99..ee242777 100644 --- a/internal/controller/operator/vmagent_controller_test.go +++ b/internal/controller/operator/vmagent_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmalert_controller.go b/internal/controller/operator/vmalert_controller.go index 91a4426b..4848b9ed 100644 --- a/internal/controller/operator/vmalert_controller.go +++ b/internal/controller/operator/vmalert_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmalert_controller_test.go b/internal/controller/operator/vmalert_controller_test.go index 41053797..4f136a62 100644 --- a/internal/controller/operator/vmalert_controller_test.go +++ b/internal/controller/operator/vmalert_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmalertmanager_controller.go b/internal/controller/operator/vmalertmanager_controller.go index e738383f..2379c7fc 100644 --- a/internal/controller/operator/vmalertmanager_controller.go +++ b/internal/controller/operator/vmalertmanager_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmalertmanager_controller_test.go b/internal/controller/operator/vmalertmanager_controller_test.go index 7e8bfa70..48919178 100644 --- a/internal/controller/operator/vmalertmanager_controller_test.go +++ b/internal/controller/operator/vmalertmanager_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmalertmanagerconfig_controller.go b/internal/controller/operator/vmalertmanagerconfig_controller.go index 9f32aa5c..4ce19ffc 100644 --- a/internal/controller/operator/vmalertmanagerconfig_controller.go +++ b/internal/controller/operator/vmalertmanagerconfig_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmalertmanagerconfig_controller_test.go b/internal/controller/operator/vmalertmanagerconfig_controller_test.go index 9585dcf5..5110bd06 100644 --- a/internal/controller/operator/vmalertmanagerconfig_controller_test.go +++ b/internal/controller/operator/vmalertmanagerconfig_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmauth_controller.go b/internal/controller/operator/vmauth_controller.go index 0bb31f00..18c9d80f 100644 --- a/internal/controller/operator/vmauth_controller.go +++ b/internal/controller/operator/vmauth_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmauth_controller_test.go b/internal/controller/operator/vmauth_controller_test.go index 8323b330..c61ea5ac 100644 --- a/internal/controller/operator/vmauth_controller_test.go +++ b/internal/controller/operator/vmauth_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmcluster_controller.go b/internal/controller/operator/vmcluster_controller.go index 7f5fc6de..db263910 100644 --- a/internal/controller/operator/vmcluster_controller.go +++ b/internal/controller/operator/vmcluster_controller.go @@ -1,4 +1,4 @@ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmcluster_controller_test.go b/internal/controller/operator/vmcluster_controller_test.go index af9275e8..c617cd91 100644 --- a/internal/controller/operator/vmcluster_controller_test.go +++ b/internal/controller/operator/vmcluster_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmnodescrape_controller.go b/internal/controller/operator/vmnodescrape_controller.go index 4c239e23..a6c38a80 100644 --- a/internal/controller/operator/vmnodescrape_controller.go +++ b/internal/controller/operator/vmnodescrape_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmnodescrape_controller_test.go b/internal/controller/operator/vmnodescrape_controller_test.go index 66698146..9563453f 100644 --- a/internal/controller/operator/vmnodescrape_controller_test.go +++ b/internal/controller/operator/vmnodescrape_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmpodscrape_controller.go b/internal/controller/operator/vmpodscrape_controller.go index 7d6d974f..1d22a593 100644 --- a/internal/controller/operator/vmpodscrape_controller.go +++ b/internal/controller/operator/vmpodscrape_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmpodscrape_controller_test.go b/internal/controller/operator/vmpodscrape_controller_test.go index 6e0aecb6..a119c3ba 100644 --- a/internal/controller/operator/vmpodscrape_controller_test.go +++ b/internal/controller/operator/vmpodscrape_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmprobe_controller.go b/internal/controller/operator/vmprobe_controller.go index 76b8dbe9..09f3141f 100644 --- a/internal/controller/operator/vmprobe_controller.go +++ b/internal/controller/operator/vmprobe_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmprobe_controller_test.go b/internal/controller/operator/vmprobe_controller_test.go index 583332d8..eae73e50 100644 --- a/internal/controller/operator/vmprobe_controller_test.go +++ b/internal/controller/operator/vmprobe_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmprometheusconverter_controller.go b/internal/controller/operator/vmprometheusconverter_controller.go index 24c812fd..8b26be07 100644 --- a/internal/controller/operator/vmprometheusconverter_controller.go +++ b/internal/controller/operator/vmprometheusconverter_controller.go @@ -1,4 +1,4 @@ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmprometheusconverter_controller_test.go b/internal/controller/operator/vmprometheusconverter_controller_test.go index fa7896c0..c33c0f92 100644 --- a/internal/controller/operator/vmprometheusconverter_controller_test.go +++ b/internal/controller/operator/vmprometheusconverter_controller_test.go @@ -1,4 +1,4 @@ -package controller +package operator import ( "reflect" diff --git a/internal/controller/operator/vmrule_controller.go b/internal/controller/operator/vmrule_controller.go index cc86a34b..3c3bdb0f 100644 --- a/internal/controller/operator/vmrule_controller.go +++ b/internal/controller/operator/vmrule_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmrule_controller_test.go b/internal/controller/operator/vmrule_controller_test.go index d2bc63e1..0466631a 100644 --- a/internal/controller/operator/vmrule_controller_test.go +++ b/internal/controller/operator/vmrule_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmscrapeconfig_controller.go b/internal/controller/operator/vmscrapeconfig_controller.go index 5e32fd73..eb4cb48b 100644 --- a/internal/controller/operator/vmscrapeconfig_controller.go +++ b/internal/controller/operator/vmscrapeconfig_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmscrapeconfig_controller_test.go b/internal/controller/operator/vmscrapeconfig_controller_test.go new file mode 100644 index 00000000..95c13d27 --- /dev/null +++ b/internal/controller/operator/vmscrapeconfig_controller_test.go @@ -0,0 +1,84 @@ +/* + + +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 operator + +import ( + "context" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + operatorv1beta1 "github.com/VictoriaMetrics/operator/api/operator/v1beta1" +) + +var _ = Describe("VMScrapeConfig Controller", func() { + Context("When reconciling a resource", func() { + const resourceName = "test-resource" + + ctx := context.Background() + + typeNamespacedName := types.NamespacedName{ + Name: resourceName, + Namespace: "default", // TODO(user):Modify as needed + } + vmscrapeconfig := &operatorv1beta1.VMScrapeConfig{} + + BeforeEach(func() { + By("creating the custom resource for the Kind VMScrapeConfig") + err := k8sClient.Get(ctx, typeNamespacedName, vmscrapeconfig) + if err != nil && errors.IsNotFound(err) { + resource := &operatorv1beta1.VMScrapeConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: resourceName, + Namespace: "default", + }, + // TODO(user): Specify other spec details if needed. + } + Expect(k8sClient.Create(ctx, resource)).To(Succeed()) + } + }) + + AfterEach(func() { + // TODO(user): Cleanup logic after each test, like removing the resource instance. + resource := &operatorv1beta1.VMScrapeConfig{} + err := k8sClient.Get(ctx, typeNamespacedName, resource) + Expect(err).NotTo(HaveOccurred()) + + By("Cleanup the specific resource instance VMScrapeConfig") + Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) + }) + It("should successfully reconcile the resource", func() { + By("Reconciling the created resource") + controllerReconciler := &VMScrapeConfigReconciler{ + Client: k8sClient, + OriginScheme: k8sClient.Scheme(), + } + + _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ + NamespacedName: typeNamespacedName, + }) + Expect(err).NotTo(HaveOccurred()) + // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. + // Example: If you expect a certain status condition after reconciliation, verify it here. + }) + }) +}) diff --git a/internal/controller/operator/vmservicescrape_controller.go b/internal/controller/operator/vmservicescrape_controller.go index bd6d871e..9292ae78 100644 --- a/internal/controller/operator/vmservicescrape_controller.go +++ b/internal/controller/operator/vmservicescrape_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmservicescrape_controller_test.go b/internal/controller/operator/vmservicescrape_controller_test.go index 16d150ae..91d513b9 100644 --- a/internal/controller/operator/vmservicescrape_controller_test.go +++ b/internal/controller/operator/vmservicescrape_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmsingle_controller.go b/internal/controller/operator/vmsingle_controller.go index b893bb08..25174e5b 100644 --- a/internal/controller/operator/vmsingle_controller.go +++ b/internal/controller/operator/vmsingle_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmsingle_controller_test.go b/internal/controller/operator/vmsingle_controller_test.go index f4a94681..771c7280 100644 --- a/internal/controller/operator/vmsingle_controller_test.go +++ b/internal/controller/operator/vmsingle_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmstaticscrape_controller.go b/internal/controller/operator/vmstaticscrape_controller.go index e4083ca9..a633da7f 100644 --- a/internal/controller/operator/vmstaticscrape_controller.go +++ b/internal/controller/operator/vmstaticscrape_controller.go @@ -1,4 +1,4 @@ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmstaticscrape_controller_test.go b/internal/controller/operator/vmstaticscrape_controller_test.go index f64dd121..77d04675 100644 --- a/internal/controller/operator/vmstaticscrape_controller_test.go +++ b/internal/controller/operator/vmstaticscrape_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmuser_controller.go b/internal/controller/operator/vmuser_controller.go index 4fd44c5e..09c29ce4 100644 --- a/internal/controller/operator/vmuser_controller.go +++ b/internal/controller/operator/vmuser_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context" diff --git a/internal/controller/operator/vmuser_controller_test.go b/internal/controller/operator/vmuser_controller_test.go index c6f55e16..d304e1cf 100644 --- a/internal/controller/operator/vmuser_controller_test.go +++ b/internal/controller/operator/vmuser_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package operator import ( "context"