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

chore(prometheus-prefect-exporter): make further use of common library chart #356

Merged
merged 7 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions charts/prometheus-prefect-exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ Shoutout to @ialejandro for the original work on this chart!
| 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 |
| fullnameOverride | string | `""` | String to fully override common.names.fullname template |
| image | object | `{"pullPolicy":"IfNotPresent","repository":"prefecthq/prometheus-prefect-exporter","tag":"1.1.0"}` | 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 |
| livenessProbe | bool | `false` | Enable livenessProbe |
| nameOverride | string | `""` | String to partially override prometheus-prefect-exporter.fullname template (will maintain the release name) |
| nameOverride | string | `""` | String to partially override common.names.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 |
Expand Down
8 changes: 4 additions & 4 deletions charts/prometheus-prefect-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
{{- 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_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.names.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 }}"}}")
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "common.names.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.names.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 POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "common.names.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
Expand Down
54 changes: 1 addition & 53 deletions charts/prometheus-prefect-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,61 +1,9 @@
{{/*
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 }}
{{- default (include "common.names.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Expand Down
10 changes: 5 additions & 5 deletions charts/prometheus-prefect-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "prometheus-prefect-exporter.fullname" . }}
name: {{ include "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels:
{{- include "prometheus-prefect-exporter.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "prometheus-prefect-exporter.selectorLabels" . | nindent 6 }}
{{- include "common.labels.matchLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "prometheus-prefect-exporter.selectorLabels" . | nindent 8 }}
{{- include "common.labels.matchLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand All @@ -36,7 +36,7 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: {{ include "common.images.image" (dict "imageRoot" .Values.image)}}
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
{{- if .Values.containerArgs }}
Expand Down
6 changes: 3 additions & 3 deletions charts/prometheus-prefect-exporter/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "prometheus-prefect-exporter.fullname" . }}
name: {{ include "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels:
{{- include "prometheus-prefect-exporter.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "prometheus-prefect-exporter.fullname" . }}
name: {{ include "common.names.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
Expand Down
6 changes: 3 additions & 3 deletions charts/prometheus-prefect-exporter/templates/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ template "prometheus-prefect-exporter.fullname" . }}
name: {{ template "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels:
{{- include "prometheus-prefect-exporter.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "prometheus-prefect-exporter.selectorLabels" . | nindent 6 }}
{{- include "common.labels.matchLabels" . | nindent 6 }}
{{ toYaml .Values.podDisruptionBudget | indent 2 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ template "prometheus-prefect-exporter.fullname" . }}
name: {{ template "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels:
{{- include "prometheus-prefect-exporter.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.prometheusRule.additionalLabels -}}
{{- toYaml . | nindent 4 -}}
{{- end }}
Expand Down
6 changes: 3 additions & 3 deletions charts/prometheus-prefect-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "prometheus-prefect-exporter.fullname" . }}
name: {{ include "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels:
{{- include "prometheus-prefect-exporter.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
Expand All @@ -13,4 +13,4 @@ spec:
protocol: TCP
name: http
selector:
{{- include "prometheus-prefect-exporter.selectorLabels" . | nindent 4 }}
{{- include "common.labels.matchLabels" . | nindent 4 }}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: {{ include "prometheus-prefect-exporter.serviceAccountName" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels:
{{- include "prometheus-prefect-exporter.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "prometheus-prefect-exporter.fullname" . }}
name: {{ include "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels:
{{- include "prometheus-prefect-exporter.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
jobLabel: "{{ .Release.Name }}"
selector:
matchLabels:
{{- include "prometheus-prefect-exporter.selectorLabels" . | nindent 8 }}
{{- include "common.labels.matchLabels" . | nindent 8 }}
endpoints:
- port: http
interval: {{ .Values.serviceMonitor.interval | quote }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "prometheus-prefect-exporter.fullname" . }}-test-connection"
name: "{{ include "common.names.fullname" . }}-test-connection"
labels:
{{- include "prometheus-prefect-exporter.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "prometheus-prefect-exporter.fullname" . }}:{{ .Values.service.targetPort | default .Values.service.port }}']
args: ['{{ include "common.names.fullname" . }}:{{ .Values.service.targetPort | default .Values.service.port }}']
restartPolicy: Never
{{- end }}
4 changes: 2 additions & 2 deletions charts/prometheus-prefect-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ image:
# Overrides the image tag whose default is the chart appVersion.
tag: 1.1.0

# -- String to partially override prometheus-prefect-exporter.fullname template (will maintain the release name)
# -- String to partially override common.names.fullname template (will maintain the release name)
nameOverride: ""

# -- String to fully override prometheus-prefect-exporter.fullname template
# -- String to fully override common.names.fullname template
fullnameOverride: ""

# -- Global Docker registry secret names as an array
Expand Down