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

Prom exporter release #277

Merged
merged 16 commits into from
Dec 6, 2023
94 changes: 94 additions & 0 deletions .github/workflows/prometheus-exporter-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Release Prometheus Prefect Exporter Helm Chart

"on":
push:
tags:
# prefect-prometheus-exporter-2023.9.1, but not prefect-prometheus-exporter-2023.09.01
# prefect-prometheus-exporter-2023.11.5, but not prefect-prometheus-exporter-2023.11.05
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- 'prefect-prometheus-exporter-2[0-9][2-9][3-9].1?[0-9].[1-3]?[0-9]'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense as the release name, is it also the tag name??

Also - should we convert to doing this for the other charts. i think we used to back in the day?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'll create an issue to do the same w/ the other charts. This is also the tag name, yes


jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get the version tags
id: get_version
run: |
# Enable pipefail so git command failures do not result in null versions downstream
set -x
export "FULL_RELEASE=$(echo $GITHUB_REF | cut -d / -f 3)"
echo "RELEASE_VERSION=$(echo $FULL_RELEASE | cut -d - -f 4)" >> $GITHUB_OUTPUT
echo "PROMETHEUS_PREFECT_EXPORTER_VERSION=$(\
git ls-remote --tags --refs --sort="v:refname" \
https://github.com/PrefectHQ/prometheus-prefect-exporter | tail -n1 | sed 's/.*\///' \
)" >> $GITHUB_OUTPUT

- name: Copy Artifact Hub metadata
run: |
mkdir -p /tmp/chart
cp artifacthub-repo.yml /tmp/chart

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"

- name: Set up Helm
uses: azure/[email protected]

- name: Prepare GPG key for signing
run: |
gpg_dir=/tmp/.gpg
mkdir "$gpg_dir"
keyring="$gpg_dir/secring.gpg"
base64 -d <<< "$GPG_KEYRING_BASE64" > "$keyring"
passphrase_file="$gpg_dir/passphrase"
echo "$GPG_PASSPHRASE" > "$passphrase_file"
echo "SIGN_PASSPHRASE_FILE=$passphrase_file" >> "$GITHUB_ENV"
echo "SIGN_KEYRING=$keyring" >> "$GITHUB_ENV"
env:
GPG_KEYRING_BASE64: "${{ secrets.GPG_KEYRING_BASE64 }}"
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}"

- name: Package Prometheus Exporter helm chart
run: |
mkdir -p /tmp/chart
cd charts
# Update the prefect version tag in values.yaml
sed -i "s/tag:.*$/tag: $PROMETHEUS_PREFECT_EXPORTER_VERSION/g" prometheus-prefect-exporter/values.yaml
helm package prometheus-prefect-exporter \
--destination /tmp/chart \
--dependency-update \
--version $RELEASE_VERSION \
--app-version $PROMETHEUS_PREFECT_EXPORTER_VERSION \
--sign --key '[email protected]' \
--keyring $SIGN_KEYRING \
--passphrase-file $SIGN_PASSPHRASE_FILE
env:
RELEASE_VERSION: ${{ steps.get_version.outputs.RELEASE_VERSION }}
PROMETHEUS_PREFECT_EXPORTER_VERSION: ${{ steps.get_version.outputs.PROMETHEUS_PREFECT_EXPORTER_VERSION }}
SIGN_KEYRING: ${{ env.SIGN_KEYRING }}
SIGN_PASSPHRASE_FILE: ${{ env.SIGN_PASSPHRASE_FILE }}

- name: Update chart index
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I need to add all charts to the index? Will something break if I don't?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think so but idk!

run: |
git stash # Stash changes to the values.yaml so checkout doesn't complain
git checkout gh-pages
helm repo index /tmp/chart --url https://prefecthq.github.io/prefect-helm/charts --merge ./index.yaml

- name: Commit and push
run: |
cp /tmp/chart/artifacthub-repo.yml .
cp /tmp/chart/index.yaml .
cp /tmp/chart/prometheus-prefect-exporter-$RELEASE_VERSION.* ./charts
git add ./artifacthub-repo.yml ./index.yaml prometheus-prefect-exporter-$RELEASE_VERSION.*
git commit -m "Release $RELEASE_VERSION"
git push origin gh-pages
env:
RELEASE_VERSION: ${{ steps.get_version.outputs.RELEASE_VERSION }}
19 changes: 19 additions & 0 deletions charts/prometheus-prefect-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
appVersion: "latest"
description: A Helm chart to deploy Prometheus Prefect Exporter
home: https://github.com/PrefectHQ
keywords:
- prometheus-prefect-exporter
maintainers:
- name: jamiezieziula
email: [email protected]
- name: jimid27
email: [email protected]
- name: parkedwards
email: [email protected]
name: prometheus-prefect-exporter
sources:
- https://github.com/PrefectHQ/prefect-helm
type: application
# This version is never actually shipped. github actions will package add the appropriate version at build-time
version: 2023.11.4
85 changes: 85 additions & 0 deletions charts/prometheus-prefect-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# prometheus-prefect-exporter

## Overview

This chart deploys a [Prometheus Exporter](https://github.com/PrefectHQ/prometheus-prefect-exporter) for Prefect Server, providing relevant metrics from your deployed Prefect Server instance.
Shoutout to @ialejandro for the original work on this chart!

## Installing the Chart

### Prerequisites

1. Add the Prefect Helm repository to your Helm client:

```bash
helm repo add prefect https://prefecthq.github.io/prefect-helm
helm repo update
```

2. Deploy a Prefect Server instance using the [Prefect Server Helm chart](https://github.com/PrefectHQ/prefect-helm/tree/main/charts/prefect-server)

### Install the Prefect Exporter chart

1. Configure the Prefect exporter values as needed
Create a `values.yaml` file to customize the Prometheus Prefect Exporter configuration.

2. Install the chart
```bash
helm install prometheus-prefect-exporter prefect/prometheus-prefect-exporter --namespace=<PREFECT_SERVER_NAMESPACE> -f values.yaml
```

3. Verify the deployment

Check the status of your Prometheus Prefect Exporter deployment:

```bash
kubectl get pods -n prefect

NAME READY STATUS RESTARTS AGE
prometheus-prefect-exporter-76vxqnq 1/1 Running 0 25m
```

You should see the Prometheus Prefect Exporter pod running

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| jamiezieziula | <[email protected]> | |
| jimid27 | <[email protected]> | |
| parkedwards | <[email protected]> | |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Affinity for pod assignment |
| autoscaling | object | `{"enabled":false,"maxReplicas":100,"minReplicas":1,"targetCPUUtilizationPercentage":80}` | Autoscaling with CPU or memory utilization percentage |
| env | object | `{}` | Environment variables to configure application |
| fullnameOverride | string | `""` | String to fully override prometheus-prefect-exporter.fullname template |
| image | object | `{"pullPolicy":"IfNotPresent","repository":"prefecthq/prometheus-prefect-exporter","tag":""}` | Image registry |
| imagePullSecrets | list | `[]` | Global Docker registry secret names as an array |
| ingress | object | `{"annotations":{},"className":"","enabled":false,"hosts":[{"host":"chart-example.local","paths":[{"path":"/","pathType":"ImplementationSpecific"}]}],"tls":[]}` | Ingress configuration to expose app |
| nameOverride | string | `""` | String to partially override prometheus-prefect-exporter.fullname template (will maintain the release name) |
| nodeSelector | object | `{}` | Node labels for pod assignment |
| podAnnotations | object | `{}` | Pod annotations |
| podDisruptionBudget | object | `{}` | Limits the number of Pods of a replicated application that are down simultaneously from voluntary disruptions |
| podSecurityContext | object | `{}` | To specify security settings for a Pod |
| prometheusRule.additionalLabels | object | `{}` | |
| prometheusRule.enabled | bool | `false` | |
| prometheusRule.rules | list | `[]` | |
| replicaCount | int | `1` | Number of replicas |
| resources | object | `{}` | The resources limits and requested |
| securityContext | object | `{}` | Defines privilege and access control settings for a Pod or Container |
| service | object | `{"port":80,"targetPort":8000,"type":"ClusterIP"}` | Kubernetes servide to expose Pod |
| service.port | int | `80` | Kubernetes Service port |
| service.targetPort | int | `8000` | Pod expose port |
| service.type | string | `"ClusterIP"` | Kubernetes Service type. Allowed values: NodePort, LoadBalancer or ClusterIP |
| serviceAccount | object | `{"annotations":{},"create":true,"name":""}` | Enable creation of ServiceAccount |
| serviceMonitor | object | `{"enabled":false,"interval":"30s","metricRelabelings":[],"relabelings":[],"scrapeTimeout":"10s"}` | Enable ServiceMonitor to get metrics ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#servicemonitor |
| serviceMonitor.enabled | bool | `false` | Enable or disable |
| testConnection | bool | `false` | Enable livenessProbe and readinessProbe |
| tolerations | list | `[]` | Tolerations for pod assignment |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.3](https://github.com/norwoodj/helm-docs/releases/v1.11.3)
51 changes: 51 additions & 0 deletions charts/prometheus-prefect-exporter/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{ template "chart.header" . }}

## Overview

This chart deploys a [Prometheus Exporter](https://github.com/PrefectHQ/prometheus-prefect-exporter) for Prefect Server, providing relevant metrics from your deployed Prefect Server instance.
Shoutout to @ialejandro for the original work on this chart!

## Installing the Chart

### Prerequisites

1. Add the Prefect Helm repository to your Helm client:

```bash
helm repo add prefect https://prefecthq.github.io/prefect-helm
helm repo update
```

2. Deploy a Prefect Server instance using the [Prefect Server Helm chart](https://github.com/PrefectHQ/prefect-helm/tree/main/charts/prefect-server)

### Install the Prefect Exporter chart

1. Configure the Prefect exporter values as needed
Create a `values.yaml` file to customize the Prometheus Prefect Exporter configuration.

2. Install the chart
```bash
helm install prometheus-prefect-exporter prefect/prometheus-prefect-exporter --namespace=<PREFECT_SERVER_NAMESPACE> -f values.yaml
```

3. Verify the deployment

Check the status of your Prometheus Prefect Exporter deployment:

```bash
kubectl get pods -n prefect

NAME READY STATUS RESTARTS AGE
prometheus-prefect-exporter-76vxqnq 1/1 Running 0 25m
```

You should see the Prometheus Prefect Exporter pod running


{{ template "chart.maintainersSection" . }}

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}

{{ template "helm-docs.versionFooter" . }}
22 changes: 22 additions & 0 deletions charts/prometheus-prefect-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "prometheus-prefect-exporter.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "prometheus-prefect-exporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "prometheus-prefect-exporter.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "prometheus-prefect-exporter.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions charts/prometheus-prefect-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "prometheus-prefect-exporter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "prometheus-prefect-exporter.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "prometheus-prefect-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "prometheus-prefect-exporter.labels" -}}
helm.sh/chart: {{ include "prometheus-prefect-exporter.chart" . }}
{{ include "prometheus-prefect-exporter.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "prometheus-prefect-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "prometheus-prefect-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "prometheus-prefect-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "prometheus-prefect-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Loading