From b9e2bc93eaa4b60b797ab34286b384987c03f0be Mon Sep 17 00:00:00 2001 From: Hao Yamg Date: Tue, 24 Dec 2024 11:14:23 +0000 Subject: [PATCH 01/33] sample servicemonitor and values --- helm-charts/prometheus/service-monitor.yaml | 33 +++++++++++++++++++++ helm-charts/prometheus/values.yaml | 24 +++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 helm-charts/prometheus/service-monitor.yaml create mode 100644 helm-charts/prometheus/values.yaml diff --git a/helm-charts/prometheus/service-monitor.yaml b/helm-charts/prometheus/service-monitor.yaml new file mode 100644 index 000000000..03fbfd8ed --- /dev/null +++ b/helm-charts/prometheus/service-monitor.yaml @@ -0,0 +1,33 @@ +apiVersion: v1 +kind: Secret +metadata: + name: dbadmin +data: + username: ZGJhZG1pbg== + password: '' +type: Opaque +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: k8s-vertica-prometheus + labels: + release: prometheus +spec: + selector: + matchLabels: + app.kubernetes.io/name: vertica + endpoints: + - basicAuth: + password: + key: password + name: dbadmin + username: + key: username + name: dbadmin + interval: 1s + path: /v1/metrics + port: "8443" + scheme: https + tlsConfig: + insecureSkipVerify: true diff --git a/helm-charts/prometheus/values.yaml b/helm-charts/prometheus/values.yaml new file mode 100644 index 000000000..ca16a6ba8 --- /dev/null +++ b/helm-charts/prometheus/values.yaml @@ -0,0 +1,24 @@ +defaultRules: + create: false +alertmanager: + enabled: true +grafana: + enabled: false +kubeApiServer: + enabled: true +kubelet: + enabled: false +kubeControllerManager: + enabled: true +coreDns: + enabled: false +kubeEtcd: + enabled: false +kubeScheduler: + enabled: false +kubeStateMetrics: + enabled: true +nodeExporter: + enabled: false +prometheus: + enabled: true From f39bfb2753a984f59937bcb49214e7e525a0ea00 Mon Sep 17 00:00:00 2001 From: Hao Yamg Date: Tue, 24 Dec 2024 11:15:52 +0000 Subject: [PATCH 02/33] update make file --- Makefile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3afb1124a..992694dbf 100644 --- a/Makefile +++ b/Makefile @@ -146,10 +146,12 @@ export OLM_CATALOG_IMG MINIMAL_VERTICA_IMG ?= # Name of the helm release that we will install/uninstall HELM_RELEASE_NAME?=vdb-op +PROMETHEUS_HELM_NAME?=prometheus # Can be used to specify additional overrides when doing the helm install. # For example to specify a custom webhook tls cert when deploying use this command: # HELM_OVERRIDES="--set webhook.tlsSecret=custom-cert" make deploy-operator HELM_OVERRIDES?= +PROMETHEUS_HELM_OVERRIDES?= # Maximum number of tests to run at once. (default 2) # Set it to any value not greater than 8 to override the default one E2E_PARALLELISM?=2 @@ -245,7 +247,9 @@ DEPLOY_WAIT?=--wait # Name of the test OLM catalog that we will create and deploy with in e2e tests OLM_TEST_CATALOG_SOURCE=e2e-test-catalog # Name of the namespace to deploy the operator in -NAMESPACE?=verticadb-operator +NAMESPACE?=default +# Name of the namespace to deploy prometheus +PROMETHEUS_NAMESPACE?=default # The Go version that we will build the operator with GO_VERSION?=1.23.2 @@ -255,6 +259,7 @@ HELM_UNITTEST_VERSION?=3.9.3-0.2.11 KUTTL_PLUGIN_INSTALLED:=$(shell kubectl krew list 2>/dev/null | grep -c '^kuttl') STERN_PLUGIN_INSTALLED:=$(shell kubectl krew list 2>/dev/null | grep -c '^stern') OPERATOR_CHART = $(shell pwd)/helm-charts/verticadb-operator +PROMETHEUS_CHART=prometheus-community/kube-prometheus-stack # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -634,12 +639,22 @@ endif deploy-webhook: manifests kustomize ## Using helm, deploy just the webhook in the k8s cluster ifeq ($(DEPLOY_WITH), helm) - helm install $(DEPLOY_WAIT) -n $(NAMESPACE) --create-namespace $(HELM_RELEASE_NAME) $(OPERATOR_CHART) --set image.repo=null --set image.name=${OPERATOR_IMG} --set image.pullPolicy=$(HELM_IMAGE_PULL_POLICY) --set imagePullSecrets[0].name=priv-reg-cred $(HELM_OVERRIDES) --set webhook.enable=true,controllers.enable=false + helm install $(DEPLOY_WAIT) -n $(NAMESPACE) --create-namespace $(HELM_RELEASE_NAME) $(OPERATOR_CHART) --set image.repo=null --set image.name=${OPERATOR_IMG} --set image.pullPolicy=$(HELM_IMAGE_PULL_POLICY) --set imagePullSecrets[0].name=priv-reg-cred $(HELM_OVERRIDES) scripts/wait-for-webhook.sh -n $(NAMESPACE) -t 60 else $(error Unsupported deployment method for webhook only: $(DEPLOY_WITH)) endif +.PHONY: deploy-prometheus +deploy-prometheus: + helm repo add prometheus-community https://prometheus-community.github.io/helm-charts + helm repo update + helm install $(DEPLOY_WAIT) -n $(PROMETHEUS_NAMESPACE) --create-namespace $(PROMETHEUS_HELM_NAME) $(PROMETHEUS_CHART) --values helm-charts/prometheus/values.yaml $(PROMETHEUS_HELM_OVERRIDES) + +.PHONY: undeploy-prometheus +undeploy-prometheus: + helm uninstall $(PROMETHEUS_HELM_NAME) + .PHONY: undeploy-operator undeploy-operator: ## Undeploy operator that was previously deployed scripts/undeploy.sh $(if $(filter false,$(ignore-not-found)),,-i) From 1c25379a4c7aaccb8a8c050c0a49a782a2d711ae Mon Sep 17 00:00:00 2001 From: Hao Yamg Date: Wed, 25 Dec 2024 08:11:35 +0000 Subject: [PATCH 03/33] update sample service monitor --- helm-charts/prometheus/service-monitor.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/helm-charts/prometheus/service-monitor.yaml b/helm-charts/prometheus/service-monitor.yaml index 03fbfd8ed..25142a3c3 100644 --- a/helm-charts/prometheus/service-monitor.yaml +++ b/helm-charts/prometheus/service-monitor.yaml @@ -16,7 +16,10 @@ metadata: spec: selector: matchLabels: - app.kubernetes.io/name: vertica + app.kubernetes.io/instance: verticadb-sample + namespaceSelector: + matchNames: + - default endpoints: - basicAuth: password: @@ -25,9 +28,9 @@ spec: username: key: username name: dbadmin - interval: 1s + interval: 5s path: /v1/metrics - port: "8443" + port: vertica-http scheme: https tlsConfig: insecureSkipVerify: true From 6cf5e694f6e14b31d64a8dfb45ce7af11e077a50 Mon Sep 17 00:00:00 2001 From: Hao Yamg Date: Wed, 25 Dec 2024 09:16:36 +0000 Subject: [PATCH 04/33] update example values --- Makefile | 2 +- helm-charts/prometheus/service-monitor.yaml | 13 ++----------- helm-charts/prometheus/values.yaml | 2 +- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 992694dbf..76f8cb6de 100644 --- a/Makefile +++ b/Makefile @@ -247,7 +247,7 @@ DEPLOY_WAIT?=--wait # Name of the test OLM catalog that we will create and deploy with in e2e tests OLM_TEST_CATALOG_SOURCE=e2e-test-catalog # Name of the namespace to deploy the operator in -NAMESPACE?=default +NAMESPACE?=verticadb-operator # Name of the namespace to deploy prometheus PROMETHEUS_NAMESPACE?=default diff --git a/helm-charts/prometheus/service-monitor.yaml b/helm-charts/prometheus/service-monitor.yaml index 25142a3c3..e89a5c259 100644 --- a/helm-charts/prometheus/service-monitor.yaml +++ b/helm-charts/prometheus/service-monitor.yaml @@ -1,12 +1,3 @@ -apiVersion: v1 -kind: Secret -metadata: - name: dbadmin -data: - username: ZGJhZG1pbg== - password: '' -type: Opaque ---- apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: @@ -24,10 +15,10 @@ spec: - basicAuth: password: key: password - name: dbadmin + name: su-passwd username: key: username - name: dbadmin + name: su-passwd interval: 5s path: /v1/metrics port: vertica-http diff --git a/helm-charts/prometheus/values.yaml b/helm-charts/prometheus/values.yaml index ca16a6ba8..1e907d18d 100644 --- a/helm-charts/prometheus/values.yaml +++ b/helm-charts/prometheus/values.yaml @@ -19,6 +19,6 @@ kubeScheduler: kubeStateMetrics: enabled: true nodeExporter: - enabled: false + enabled: true prometheus: enabled: true From dd38f9277cb10de9049d207bd1eb1b3416d3a261 Mon Sep 17 00:00:00 2001 From: Hao Yamg Date: Thu, 26 Dec 2024 08:27:16 +0000 Subject: [PATCH 05/33] create script --- scripts/deploy-prometheus.sh | 210 +++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100755 scripts/deploy-prometheus.sh diff --git a/scripts/deploy-prometheus.sh b/scripts/deploy-prometheus.sh new file mode 100755 index 000000000..7d027bfcd --- /dev/null +++ b/scripts/deploy-prometheus.sh @@ -0,0 +1,210 @@ +#!/bin/bash + +# (c) Copyright [2021-2024] Open Text. +# 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. + +# A script that will deploy the prometheus service monitor and secret. It assumes the prometheus operator is deployed. + + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +REPO_DIR=$(dirname $SCRIPT_DIR) +LABEL='' +ACTION='' +NAMESPACE='' +USERNAME='' +PASSWORD='' +DBNAME='' + +function usage() { + echo "usage: $(basename $0) [-n ] [-l