Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add setup-prometheus-adapter #1012

Merged
merged 40 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c2d7603
add setup-prometheus-adapter
qindotguan Dec 23, 2024
b9e2bc9
sample servicemonitor and values
HaoYang0000 Dec 24, 2024
f39bfb2
update make file
HaoYang0000 Dec 24, 2024
1c25379
update sample service monitor
HaoYang0000 Dec 25, 2024
6cf5e69
update example values
HaoYang0000 Dec 25, 2024
dd38f92
create script
HaoYang0000 Dec 26, 2024
b8b2110
update make file
HaoYang0000 Dec 26, 2024
1682e71
remove template file
HaoYang0000 Dec 26, 2024
5c3da03
remove unused content
HaoYang0000 Dec 26, 2024
4cd1754
address comments
HaoYang0000 Dec 26, 2024
593441a
add interval in scrpits and fix bug in namespace
HaoYang0000 Dec 26, 2024
b83799f
add namespace in undeploy
HaoYang0000 Dec 26, 2024
5d8c464
add vdb namespace customize
HaoYang0000 Dec 26, 2024
b0b6b88
revert change
HaoYang0000 Dec 26, 2024
aabad14
revert make file changes
HaoYang0000 Jan 2, 2025
1006b9a
update default values
HaoYang0000 Jan 2, 2025
e878ad6
move values file to prometheus directory
HaoYang0000 Jan 2, 2025
5e260c8
update file path
HaoYang0000 Jan 2, 2025
825cbbc
add e2e test
HaoYang0000 Jan 2, 2025
d1a9398
address comments
HaoYang0000 Jan 2, 2025
bbbe46b
Update Makefile
HaoYang0000 Jan 3, 2025
cabbde9
update e2e test
HaoYang0000 Jan 3, 2025
1e4d33b
rename dbname to vdbname in script
HaoYang0000 Jan 3, 2025
dd194a6
update script with cmd instead of cat f
HaoYang0000 Jan 3, 2025
4e9ca4e
add label for secret
HaoYang0000 Jan 3, 2025
9aa2428
assert service as well in e2e check
HaoYang0000 Jan 3, 2025
cfc65ca
add cr deletetion and fix namespace issue
HaoYang0000 Jan 3, 2025
1910af9
fix namespace issue
HaoYang0000 Jan 3, 2025
da6aea4
fix _
HaoYang0000 Jan 3, 2025
22e4958
add undeploy-prometheus-adapter
qindotguan Jan 3, 2025
e53300b
Merge branch 'deploy-prometheus' into qguan/setup-prometheus-adapter
qindotguan Jan 6, 2025
57ae07c
deploy with configuration file adapter.yaml
qindotguan Jan 6, 2025
7df6b27
correct the tabs
qindotguan Jan 6, 2025
22c2a63
Merge branch 'main' into qguan/setup-prometheus-adapter
qindotguan Jan 6, 2025
9756feb
add prometheus-adapter back after merge
qindotguan Jan 6, 2025
a2c953a
remove prometheustest as it renamed
qindotguan Jan 6, 2025
ef8d289
add PROMETHEUS_ADAPTER_HELM_OVERRIDES that we can use to set more fields
qindotguan Jan 6, 2025
b36b822
add prometheus adapter test
qindotguan Jan 8, 2025
5a1615d
check metrics version only due to permission issue
qindotguan Jan 9, 2025
2ec1cbe
move DB and VDB variables next to prometheus
qindotguan Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,33 @@ OLM_CATALOG_IMG ?= olm-catalog:$(TAG)
endif
export OLM_CATALOG_IMG

# Set this to YES if you want to create a vertica image of minimal size
MINIMAL_VERTICA_IMG ?=
# Name of the helm release that we will install/uninstall
HELM_RELEASE_NAME?=vdb-op
# Name of the namespace to deploy prometheus
PROMETHEUS_NAMESPACE?=prometheus
# Prometheus variables that we wil be used for deployment
PROMETHEUS_HELM_NAME?=prometheus
PROMETHEUS_INTERVAL?=5s
# The Prometheus adapter name and namespace used in VerticaAutoscaler
PROMETHEUS_ADAPTER_NAME ?= prometheus-adapter
PROMETHEUS_ADAPTER_NAMESPACE ?= prometheus-adapter
PROMETHEUS_ADAPTER_REPLICAS ?= 1
# The Prometheus service URL and port for Prometheus adapter to connect to
PROMETHEUS_URL ?= http://$(PROMETHEUS_HELM_NAME)-kube-prometheus-prometheus.$(PROMETHEUS_NAMESPACE).svc
PROMETHEUS_PORT ?= 9090
DB_USER?=dbadmin
DB_PASSWORD?=
VDB_NAME?=verticadb-sample
VDB_NAMESPACE?=default

# Set this to YES if you want to create a vertica image of minimal size
MINIMAL_VERTICA_IMG ?=
# Name of the helm release that we will install/uninstall
HELM_RELEASE_NAME?=vdb-op
# 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?=
HELM_OVERRIDES ?=
PROMETHEUS_HELM_OVERRIDES ?=
PROMETHEUS_ADAPTER_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
Expand Down Expand Up @@ -254,8 +265,6 @@ DEPLOY_WAIT?=--wait
OLM_TEST_CATALOG_SOURCE=e2e-test-catalog
# Name of the namespace to deploy the operator in
NAMESPACE?=verticadb-operator
# Name of the namespace to deploy prometheus
PROMETHEUS_NAMESPACE?=prometheus

# The Go version that we will build the operator with
GO_VERSION?=1.23.2
Expand Down Expand Up @@ -677,6 +686,16 @@ undeploy-prometheus-service-monitor:
undeploy-prometheus-service-monitor-by-release:
scripts/deploy-prometheus.sh -l $(PROMETHEUS_HELM_NAME) -a undeploy_by_release

.PHONY: deploy-prometheus-adapter
deploy-prometheus-adapter: ## Setup prometheus adapter for VerticaAutoscaler
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install $(DEPLOY_WAIT) -n $(PROMETHEUS_ADAPTER_NAMESPACE) --create-namespace $(PROMETHEUS_ADAPTER_NAME) prometheus-community/prometheus-adapter --values prometheus/adapter.yaml --set prometheus.url=$(PROMETHEUS_URL) --set prometheus.port=$(PROMETHEUS_PORT) --set replicas=$(PROMETHEUS_ADAPTER_REPLICAS) $(PROMETHEUS_ADAPTER_HELM_OVERRIDES)

.PHONY: undeploy-prometheus-adapter
undeploy-prometheus-adapter: ## Remove prometheus adapter
helm uninstall $(PROMETHEUS_ADAPTER_NAME) -n $(PROMETHEUS_ADAPTER_NAMESPACE)

.PHONY: undeploy-operator
undeploy-operator: ## Undeploy operator that was previously deployed
scripts/undeploy.sh $(if $(filter false,$(ignore-not-found)),,-i)
Expand Down
15 changes: 15 additions & 0 deletions prometheus/adapter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Customize the adapter configuration to map Prometheus metrics to Kubernetes metrics
rules:
default: false
custom:
- seriesQuery: 'vertica_query_requests_attempted_total{namespace!="", pod!=""}'
resources:
overrides:
namespace:
resource: namespace
pod:
resource: pod
name:
matches: "^(.*)_total$"
as: "${1}_rate_per_second"
metricsQuery: 'sum(increase(vertica_query_requests_attempted_total[5m])) by (namespace, pod)'
25 changes: 25 additions & 0 deletions tests/e2e-leg-11/prometheus-sanity/16-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# (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.

apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus-adapter
status:
replicas: 1
readyReplicas: 1
---
apiVersion: v1
kind: Service
metadata:
name: prometheus-adapter
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# (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.

apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: cd ../../.. && make deploy-prometheus-adapter PROMETHEUS_NAMESPACE=$NAMESPACE PROMETHEUS_ADAPTER_NAMESPACE=$NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# (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.

apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
RESULT=$(kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1)
VERSION=$(echo $RESULT | jq -r '.groupVersion')
if [ "$VERSION" != "custom.metrics.k8s.io/v1beta1" ]; then
echo "Assertion failed: expected group version custom.metrics.k8s.io/v1beta1, got $VERSION."
exit 1
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# (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.

apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: cd ../../.. && make undeploy-prometheus-adapter PROMETHEUS_ADAPTER_NAMESPACE=$NAMESPACE
22 changes: 22 additions & 0 deletions tests/e2e-leg-11/prometheus-sanity/85-errors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# (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.

apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus-adapter
---
apiVersion: v1
kind: Service
metadata:
name: prometheus-adapter
Loading