From caba2ae0baabab3fe3adc5b9ddacfb636bffc406 Mon Sep 17 00:00:00 2001 From: phillip-toohill Date: Mon, 26 Feb 2024 13:54:37 -0600 Subject: [PATCH] Monitoring adding openstack metrics exporter --- ...lm-prometheus-openstack-api-exporter.yaml} | 2 +- ...prometheus-openstack-metrics-exporter.yaml | 50 +++++++++++++ docs/openstack-exporter.md | 24 +++++++ ...stack-metrics-exporter-helm-overrides.yaml | 2 +- .../aio/kustomization.yaml | 2 +- .../base/hpa-openstack-api-exporter.yaml | 4 +- .../aio/kustomization.yaml | 14 ++++ .../base/hpa-openstack-metrics-exporter.yaml | 19 +++++ .../base/kustomization.yaml | 3 + .../openstack-metrics-exporter/clouds-yaml | 11 --- .../kustomization.yaml | 9 --- .../openstack-metrics-exporter/values.yaml | 71 ------------------- 12 files changed, 115 insertions(+), 96 deletions(-) rename .github/workflows/{helm-openstack-api-exporter.yaml => helm-prometheus-openstack-api-exporter.yaml} (97%) create mode 100644 .github/workflows/helm-prometheus-openstack-metrics-exporter.yaml create mode 100644 docs/openstack-exporter.md create mode 100644 kustomize/monitoring/openstack-metrics-exporter/aio/kustomization.yaml create mode 100644 kustomize/monitoring/openstack-metrics-exporter/base/hpa-openstack-metrics-exporter.yaml create mode 100644 kustomize/monitoring/openstack-metrics-exporter/base/kustomization.yaml delete mode 100644 kustomize/monitoring/openstack-metrics-exporter/clouds-yaml delete mode 100644 kustomize/monitoring/openstack-metrics-exporter/kustomization.yaml delete mode 100644 kustomize/monitoring/openstack-metrics-exporter/values.yaml diff --git a/.github/workflows/helm-openstack-api-exporter.yaml b/.github/workflows/helm-prometheus-openstack-api-exporter.yaml similarity index 97% rename from .github/workflows/helm-openstack-api-exporter.yaml rename to .github/workflows/helm-prometheus-openstack-api-exporter.yaml index ef2c067a..69d754f9 100644 --- a/.github/workflows/helm-openstack-api-exporter.yaml +++ b/.github/workflows/helm-prometheus-openstack-api-exporter.yaml @@ -1,4 +1,4 @@ -name: Helm GitHub Actions for openstack-exporter +name: Helm GitHub Actions for openstack-api-exporter on: pull_request: diff --git a/.github/workflows/helm-prometheus-openstack-metrics-exporter.yaml b/.github/workflows/helm-prometheus-openstack-metrics-exporter.yaml new file mode 100644 index 00000000..338b954b --- /dev/null +++ b/.github/workflows/helm-prometheus-openstack-metrics-exporter.yaml @@ -0,0 +1,50 @@ +name: Helm GitHub Actions for openstack-metrics-exporter + +on: + pull_request: + paths: + - helm-configs/monitoring/openstack-metrics-exporter/** + - kustomize/monitoring/openstack-metrics-exporter/** + - .github/workflows/helm-openstack-metrics-exporter.yaml +jobs: + helm: + strategy: + matrix: + overlays: + - base + - aio + name: Helm + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: azure/setup-helm@v3 + with: + version: latest + token: "${{ secrets.GITHUB_TOKEN }}" + id: helm + - name: Kubectl Install + working-directory: /usr/local/bin/ + run: | + if [ ! -f /usr/local/bin/kubectl ]; then + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + chmod +x ./kubectl + fi + - name: Pull Openstack Exporter submodules + run: | + git submodule update --init submodules/openstack-exporter + - name: Run Helm Template + run: | + cd submodules/openstack-helm-infra + ${{ steps.helm.outputs.helm-path }} template os-metrics ./prometheus-openstack-exporter \ + --namespace=openstack \ + --wait \ + --timeout 120m \ + -f ${{ github.workspace }}/helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml \ + --post-renderer ${{ github.workspace }}/kustomize/kustomize.sh \ + --post-renderer-args monitoring/openstack-metrics-exporter/${{ matrix.overlays }} > /tmp/rendered.yaml + - name: Return helm Build + uses: actions/upload-artifact@v2 + with: + name: helm-openstack-exporter-artifact-${{ matrix.overlays }} + path: /tmp/rendered.yaml diff --git a/docs/openstack-exporter.md b/docs/openstack-exporter.md new file mode 100644 index 00000000..c1e9ea6d --- /dev/null +++ b/docs/openstack-exporter.md @@ -0,0 +1,24 @@ +##Openstack Exporter + +We are using Prometheus for monitoring and metrics collection backend along with the openstack exporter to gather openstack resource metrics +For more information see: https://prometheus.io and https://github.com/openstack-exporter/openstack-exporter + +## Deploy the Prometheus Openstack Exporter + +### Create clouds-yaml secret +Modify genestack/helm-configs/monitoring/openstack-metrics-exporter/clouds-yaml with the appropriate settings and create the secret. + +```shell +kubectl create secret generic clouds-yaml-secret --from-file /opt/genestack/helm-configs/monitoring/openstack-metrics-exporter/clouds-yaml +``` + +### Install openstack-metrics-exporter helm chart +```shell +cd /opt/genestack/submodules/openstack-exporter/helm-charts/charts + +helm upgrade --install os-metrics ./prometheus-openstack-exporter \ + --namespace=openstack \ + --timeout 15m \ + -f /opt/genestack/helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml \ + --set clouds_yaml_config="$(kubectl get secret clouds-yaml-secret -o jsonpath='{.data.clouds-yaml}' | base64 -d)" +``` diff --git a/helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml b/helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml index 7772c4a4..0854e377 100644 --- a/helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml +++ b/helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml @@ -12,7 +12,7 @@ image: pullPolicy: Always serviceMonitor: - interval: 1m + interval: 3m scrapeTimeout: 30s multicloud: diff --git a/kustomize/monitoring/openstack-api-exporter/aio/kustomization.yaml b/kustomize/monitoring/openstack-api-exporter/aio/kustomization.yaml index 1b804cba..bdf62461 100644 --- a/kustomize/monitoring/openstack-api-exporter/aio/kustomization.yaml +++ b/kustomize/monitoring/openstack-api-exporter/aio/kustomization.yaml @@ -4,7 +4,7 @@ bases: patches: - target: kind: HorizontalPodAutoscaler - name: prometheus-openstack-exporter + name: os-api-prometheus-openstack-exporter patch: |- - op: replace path: /spec/minReplicas diff --git a/kustomize/monitoring/openstack-api-exporter/base/hpa-openstack-api-exporter.yaml b/kustomize/monitoring/openstack-api-exporter/base/hpa-openstack-api-exporter.yaml index dcaaf8db..946c2140 100644 --- a/kustomize/monitoring/openstack-api-exporter/base/hpa-openstack-api-exporter.yaml +++ b/kustomize/monitoring/openstack-api-exporter/base/hpa-openstack-api-exporter.yaml @@ -1,7 +1,7 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: - name: prometheus-openstack-exporter + name: os-api-prometheus-openstack-exporter namespace: openstack spec: maxReplicas: 3 @@ -16,4 +16,4 @@ spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment - name: prometheus-openstack-exporter + name: os-api-prometheus-openstack-exporter diff --git a/kustomize/monitoring/openstack-metrics-exporter/aio/kustomization.yaml b/kustomize/monitoring/openstack-metrics-exporter/aio/kustomization.yaml new file mode 100644 index 00000000..38ff2cde --- /dev/null +++ b/kustomize/monitoring/openstack-metrics-exporter/aio/kustomization.yaml @@ -0,0 +1,14 @@ +bases: + - ../base + +patches: + - target: + kind: HorizontalPodAutoscaler + name: os-metrics-prometheus-openstack-exporter + patch: |- + - op: replace + path: /spec/minReplicas + value: 1 + - op: replace + path: /spec/maxReplicas + value: 1 diff --git a/kustomize/monitoring/openstack-metrics-exporter/base/hpa-openstack-metrics-exporter.yaml b/kustomize/monitoring/openstack-metrics-exporter/base/hpa-openstack-metrics-exporter.yaml new file mode 100644 index 00000000..1287db78 --- /dev/null +++ b/kustomize/monitoring/openstack-metrics-exporter/base/hpa-openstack-metrics-exporter.yaml @@ -0,0 +1,19 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: os-metrics-prometheus-openstack-exporter + namespace: openstack +spec: + maxReplicas: 3 + minReplicas: 1 + metrics: + - resource: + name: cpu + target: + averageUtilization: 50 + type: Utilization + type: Resource + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: os-metrics-prometheus-openstack-exporter diff --git a/kustomize/monitoring/openstack-metrics-exporter/base/kustomization.yaml b/kustomize/monitoring/openstack-metrics-exporter/base/kustomization.yaml new file mode 100644 index 00000000..215a38fe --- /dev/null +++ b/kustomize/monitoring/openstack-metrics-exporter/base/kustomization.yaml @@ -0,0 +1,3 @@ +resources: + - hpa-openstack-metrics-exporter.yaml + - all.yaml diff --git a/kustomize/monitoring/openstack-metrics-exporter/clouds-yaml b/kustomize/monitoring/openstack-metrics-exporter/clouds-yaml deleted file mode 100644 index 9e0e1a1b..00000000 --- a/kustomize/monitoring/openstack-metrics-exporter/clouds-yaml +++ /dev/null @@ -1,11 +0,0 @@ -clouds.yaml: | - clouds: - default: - region_name: RegionOne - auth: - username: your-user-here - password: your-password-here - project_name: your-project-here - project_domain_name: 'Default' - user_domain_name: 'Default' - auth_url: 'http://your-url-here:5000/v3' \ No newline at end of file diff --git a/kustomize/monitoring/openstack-metrics-exporter/kustomization.yaml b/kustomize/monitoring/openstack-metrics-exporter/kustomization.yaml deleted file mode 100644 index 8369d111..00000000 --- a/kustomize/monitoring/openstack-metrics-exporter/kustomization.yaml +++ /dev/null @@ -1,9 +0,0 @@ - -helmCharts: - - name: prometheus-openstack-exporter - repo: https://openstack-exporter.github.io/helm-charts - releaseName: prometheus-openstack-exporter - namespace: prometheus - includeCRDs: true - valuesFile: values.yaml - diff --git a/kustomize/monitoring/openstack-metrics-exporter/values.yaml b/kustomize/monitoring/openstack-metrics-exporter/values.yaml deleted file mode 100644 index 50d954f9..00000000 --- a/kustomize/monitoring/openstack-metrics-exporter/values.yaml +++ /dev/null @@ -1,71 +0,0 @@ ---- -# Choose endpoint type (this will override the value of clouds.yaml) -endpoint_type: internal -# Ignored when multicloud.enabled: true -cloud: default - -replicaCount: 1 - -image: - repository: ghcr.io/openstack-exporter/openstack-exporter - tag: 1.6.0 - pullPolicy: Always - -serviceMonitor: - interval: 1m - scrapeTimeout: 30s - -multicloud: - # Enable multicloud (i.e. /probe?... targets) - # Doc: https://github.com/openstack-exporter/openstack-exporter#description - enabled: false - # Monitor the exporter's internal metrics (i.e. /metrics) - selfmonitor: false - # List of clouds to scrape, and the services to scrape from them - #clouds: - # - name: cloud1 - # services: - # - volume - # - name: cloud2 - # services: - # - volume - # - image - # - identity - # - compute - # - network - # - placement # NB this needs the openstack-exporter release > 1.4.0 - -# Add extra args to the exporter. -# Doc: https://github.com/openstack-exporter/openstack-exporter#command-line-options -#extraArgs: -# - --disable-service.baremetal -# - --disable-service.container-infra -# - --disable-service.object-store - -# Add extra environment variables -# extraEnvs: -# "ENV_VAR": "value" - -# Add extra labels -#commonLabels: -# prometheus.io/monitor: "true" - -# Generate a secret for clouds.yaml -# Doc: https://github.com/openstack-exporter/openstack-exporter#openstack-configuration -clouds_yaml_config: | - clouds.yaml: | - clouds: - default: - region_name: your-region-here - auth: - username: your-user-here - password: your-password-here - project_name: your-project-here - project_domain_name: 'Default' - user_domain_name: 'Default' - auth_url: 'http://your-url-here:5000/v3' -# In case of multicloud.enabled -# cloud1: -# ... -# cloud2: -# ...