Skip to content

Commit 5d8bd7c

Browse files
committed
feat: OSPC-1365: Adding barbican exporter to provide barbican metrics/stats
1 parent 1e92264 commit 5d8bd7c

File tree

7 files changed

+188
-0
lines changed

7 files changed

+188
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Helm GitHub Actions for Barbican Exporter
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- base-helm-configs/barbican-exporter/**
7+
- base-kustomize/barbican-exporter/**
8+
- .github/workflows/helm-barbican-exporter.yaml
9+
jobs:
10+
helm:
11+
strategy:
12+
matrix:
13+
overlays:
14+
- base
15+
name: Helm
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
- uses: azure/setup-helm@v3
21+
with:
22+
version: latest
23+
token: "${{ secrets.GITHUB_TOKEN }}"
24+
id: helm
25+
- name: Add barbican-exporter repo to helm
26+
run: |
27+
${{ steps.helm.outputs.helm-path }} repo add genestack-barbician-exporter-helm-chart https://github.com/rackerlabs/genestack-barbician-exporter-helm-chart
28+
${{ steps.helm.outputs.helm-path }} repo update
29+
- name: Kubectl Install
30+
working-directory: /usr/local/bin/
31+
run: |
32+
if [ ! -f /usr/local/bin/kubectl ]; then
33+
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
34+
chmod +x ./kubectl
35+
fi
36+
- name: Run Helm Template
37+
run: |
38+
${{ steps.helm.outputs.helm-path }} template barbican-exporter genestack-barbician-exporter-helm-chart/barbican-exporter \
39+
--create-namespace \
40+
--namespace=openstack \
41+
--wait \
42+
--timeout 120m \
43+
-f ${{ github.workspace }}/base-helm-configs/barbican-exporter/barbican-exporter-helm-overrides.yaml > /tmp/rendered.yaml
44+
- name: Return helm Build
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: helm-barbican-exporter-artifact-${{ matrix.overlays }}
48+
path: /tmp/rendered.yaml
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# Helm overrides for Barbican Prometheus exporter
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sortOptions:
2+
order: fifo
3+
resources:
4+
- all.yaml

bin/install-barbican-exporter.sh

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
# Description: Fetches the version for SERVICE_NAME from the specified
3+
# YAML file and executes a helm upgrade/install command with dynamic values files.
4+
5+
# Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval)
6+
# shellcheck disable=SC2124,SC2145,SC2294
7+
8+
# Service
9+
SERVICE_NAME="barbican-exporter"
10+
SERVICE_NAMESPACE="openstack"
11+
12+
# Helm
13+
HELM_REPO_NAME="genestack-barbician-exporter-helm-chart"
14+
HELM_REPO_URL="https://github.com/rackerlabs/genestack-barbician-exporter-helm-chart"
15+
16+
# Base directories provided by the environment
17+
GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}"
18+
GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}"
19+
20+
# Define service-specific override directories based on the framework
21+
SERVICE_BASE_OVERRIDES="${GENESTACK_BASE_DIR}/base-helm-configs/${SERVICE_NAME}"
22+
SERVICE_CUSTOM_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/${SERVICE_NAME}"
23+
24+
# Define the Global Overrides directory used in the original script
25+
GLOBAL_OVERRIDES="${GENESTACK_OVERRIDES_DIR}/helm-configs/global_overrides"
26+
27+
# Read the desired chart version from VERSION_FILE
28+
VERSION_FILE="${GENESTACK_OVERRIDES_DIR}/helm-chart-versions.yaml"
29+
30+
if [ ! -f "$VERSION_FILE" ]; then
31+
echo "Error: helm-chart-versions.yaml not found at $VERSION_FILE" >&2
32+
exit 1
33+
fi
34+
35+
# Extract version dynamically.
36+
SERVICE_VERSION=$(grep "^[[:space:]]*${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//")
37+
38+
if [ -z "$SERVICE_VERSION" ]; then
39+
echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2
40+
# exit 1
41+
fi
42+
43+
echo "Found version for $SERVICE_NAME: $SERVICE_VERSION"
44+
45+
# Prepare an array to collect -f arguments
46+
overrides_args=()
47+
48+
# Base Override Files: Check the standard base directory.
49+
if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then
50+
echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES"
51+
for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do
52+
# Check that there is at least one match
53+
if [[ -e "$file" ]]; then
54+
echo " - $file"
55+
overrides_args+=("-f" "$file")
56+
fi
57+
done
58+
else
59+
echo "Warning: Base override directory not found: $SERVICE_BASE_OVERRIDES"
60+
fi
61+
62+
# Include Global Overrides
63+
if [[ -d "$GLOBAL_OVERRIDES" ]]; then
64+
echo "Including global overrides from directory: $GLOBAL_OVERRIDES"
65+
for file in "$GLOBAL_OVERRIDES"/*.yaml; do
66+
if [[ -e "$file" ]]; then
67+
echo " - $file"
68+
overrides_args+=("-f" "$file")
69+
fi
70+
done
71+
else
72+
echo "Warning: Global override directory not found: $GLOBAL_OVERRIDES"
73+
fi
74+
75+
# Include all YAML files from the custom SERVICE configuration directory
76+
if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then
77+
echo "Including overrides from config directory:"
78+
for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do
79+
if [[ -e "$file" ]]; then
80+
echo " - $file"
81+
overrides_args+=("-f" "$file")
82+
fi
83+
done
84+
else
85+
echo "Warning: Config directory not found: $SERVICE_CUSTOM_OVERRIDES"
86+
fi
87+
88+
echo
89+
90+
# --- Helm Repository and Execution ---
91+
helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL"
92+
helm repo update
93+
94+
# Collect all --set arguments, executing commands and quoting safely
95+
set_args=()
96+
97+
helm_command=(
98+
helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME/$SERVICE_NAME"
99+
# --version "${SERVICE_VERSION}"
100+
--namespace="$SERVICE_NAMESPACE"
101+
--timeout 120m
102+
--create-namespace
103+
104+
"${overrides_args[@]}"
105+
"${set_args[@]}"
106+
107+
# Post-renderer configuration
108+
--post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh"
109+
--post-renderer-args "$SERVICE_NAME/overlay"
110+
"$@"
111+
)
112+
113+
echo "Executing Helm command (arguments are quoted safely):"
114+
printf '%q ' "${helm_command[@]}"
115+
echo
116+
117+
# Execute the command directly from the array
118+
"${helm_command[@]}"

docs/monitoring-info.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ use of it, so you do not need to install it unless you plan to do additional
163163
configuration beyond Genestack defaults and specifically plan to monitor some
164164
SNMP-enabled devices.
165165

166+
* ### Barbican Exporter:
167+
The Barbican exporter is used for monitoring of OpenStack's Key Management Service (Barbican) by exposing metrics to Prometheus. It collects metrics about secrets, containers, and other Barbican-specific resources.
168+
166169
* ### Textfile Collector:
167170
It's possible to gather node/host metrics that aren't exposed by any of the above exporters by utilizing the [Node Exporter Textfile Collector](https://github.com/prometheus/node_exporter?tab=readme-ov-file#textfile-collector).
168171
Currently, in Genestack the textfile-collector is used to collect kernel-taint stats. To view more information about the textfile-collector and how to deploy your own custom exporter view the [Custom Metrics Deployment Doc](prometheus-custom-node-metrics.md).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Barbican Exporter
2+
3+
The Barbican exporter allows monitoring of OpenStack's Key Management Service (Barbican) by exposing metrics to Prometheus. It collects metrics about secrets, containers, and other Barbican-specific resources.
4+
5+
#### Install the Barbican Exporter Helm Chart
6+
7+
```shell
8+
bin/install-barbican-exporter.sh
9+
```
10+
11+
!!! success
12+
If the installation is successful, you should see the barbican-exporter pod running in the openstack namespace.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ nav:
240240
- Blackbox Exporter: prometheus-blackbox-exporter.md
241241
- Pushgateway: prometheus-pushgateway.md
242242
- SNMP Exporter: prometheus-snmp-exporter.md
243+
- Barbican Exporter: openstack-barbican-exporter.md
243244
- Custom Node Metrics: prometheus-custom-node-metrics.md
244245
- Alert Manager Examples:
245246
- alertmanager-slack.md

0 commit comments

Comments
 (0)