Skip to content

Commit

Permalink
prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
Rein-Vanbelleghem committed Apr 29, 2024
1 parent 8dee74a commit e01cd64
Show file tree
Hide file tree
Showing 15 changed files with 570 additions and 0 deletions.
21 changes: 21 additions & 0 deletions charts/prometheus-nginx-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
6 changes: 6 additions & 0 deletions charts/prometheus-nginx-exporter/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: nginx
repository: https://charts.bitnami.com/bitnami
version: 15.3.4
digest: sha256:c5ee96dcdfa5a8ef4aa0a91e734ddedeb3c43f04fa29775a9ec6465f5eeb0192
generated: "2023-10-15T13:18:06.969016+03:00"
35 changes: 35 additions & 0 deletions charts/prometheus-nginx-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
apiVersion: v2
description: A Helm chart for the Prometheus NGINX Exporter
name: prometheus-nginx-exporter
version: 0.2.1
appVersion: 0.11.0
home: https://github.com/nginxinc/nginx-prometheus-exporter
sources:
- https://github.com/nginxinc/nginx-prometheus-exporter
- https://github.com/prometheus-community/helm-charts
keywords:
- prometheus
- nginx
- monitoring
maintainers:
- name: nlamirault
email: [email protected]
- name: zeritti
email: [email protected]
icon: https://raw.githubusercontent.com/cncf/artwork/master/prometheus/icon/color/prometheus-icon-color.svg
annotations:
artifacthub.io/links: |
- name: Chart Source
url: https://github.com/prometheus-community/helm-charts
- name: Nginx exporter
url: https://github.com/nginxinc/nginx-prometheus-exporter
artifacthub.io/maintainers: |
- name: nlamirault
email: [email protected]
dependencies:
- name: nginx
version: "15.3.4"
repository: https://charts.bitnami.com/bitnami
condition: nginx.enabled
48 changes: 48 additions & 0 deletions charts/prometheus-nginx-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# prometheus-nginx-exporter

This chart bootstraps a Prometheus [`Nginx Exporter`](https://github.com/nginxinc/nginx-prometheus-exporter) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Get Repository Info

```console
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
```

_See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentation._

## Install Chart

```console
helm install [RELEASE_NAME] prometheus-community/prometheus-nginx-exporter
```

_See [configuration](#configuring) below._

_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._

## Uninstall Chart

```console
helm uninstall [RELEASE_NAME]
```

This removes all the Kubernetes components associated with the chart and deletes the release.

_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._

## Upgrading Chart

```console
helm upgrade [RELEASE_NAME] [CHART] --install
```

_See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._

## Configuring

See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with detailed comments, visit the chart's [values.yaml](./values.yaml), or run these configuration commands:

```console
helm show values prometheus-community/prometheus-nginx-exporter
```
23 changes: 23 additions & 0 deletions charts/prometheus-nginx-exporter/ci/ci-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
nginxServer: http://ci-nginx:8080/stub_status

nginx:
enabled: true

fullnameOverride: ci-nginx

service:
type: ClusterIP
ports:
http: 8080

serverBlock: |-
server {
listen 0.0.0.0:8080;
root /app;
location / {
index index.html;
}
location /stub_status {
stub_status on;
}
}
1 change: 1 addition & 0 deletions charts/prometheus-nginx-exporter/site.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
imageUrl: "https://logowik.com/content/uploads/images/prometheus-monitoring-system4911.logowik.com.webp"
23 changes: 23 additions & 0 deletions charts/prometheus-nginx-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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 {{ template "prometheus-nginx-exporter.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "prometheus-nginx-exporter.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ template "prometheus-nginx-exporter.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 {{ template "prometheus-nginx-exporter.namespace" . }} svc -w {{ include "prometheus-nginx-exporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ template "prometheus-nginx-exporter.namespace" . }} {{ include "prometheus-nginx-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 {{ template "prometheus-nginx-exporter.namespace" . }} -l "app.kubernetes.io/name={{ include "prometheus-nginx-exporter.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ template "prometheus-nginx-exporter.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 {{ template "prometheus-nginx-exporter.namespace" . }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
103 changes: 103 additions & 0 deletions charts/prometheus-nginx-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "prometheus-nginx-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-nginx-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 -}}

{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
*/}}
{{- define "prometheus-nginx-exporter.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}

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

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

{{/*
Common labels
*/}}
{{- define "prometheus-nginx-exporter.labels" }}
helm.sh/chart: {{ include "prometheus-nginx-exporter.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: metrics
app.kubernetes.io/part-of: {{ template "prometheus-nginx-exporter.name" . }}
{{- include "prometheus-nginx-exporter.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels }}
{{- end }}
{{- end }}

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

{{/*
Pod annotations
*/}}
{{- define "prometheus-nginx-exporter.podAnnotations" }}
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations }}
{{- end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations }}
{{- end }}
{{- end }}

{{/*
Service annotations
*/}}
{{- define "prometheus-nginx-exporter.serviceAnnotations" }}
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations }}
{{- end }}
{{- if .Values.service.annotations }}
{{ toYaml .Values.service.annotations }}
{{- end }}
{{- end }}
75 changes: 75 additions & 0 deletions charts/prometheus-nginx-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "prometheus-nginx-exporter.fullname" . }}
namespace: {{ template "prometheus-nginx-exporter.namespace" . }}
{{- with .Values.additionalAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "prometheus-nginx-exporter.labels" . | indent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "prometheus-nginx-exporter.selectorLabels" . | indent 6 }}
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
{{- include "prometheus-nginx-exporter.labels" . | indent 8 }}
{{- if or .Values.additionalAnnotations .Values.podAnnotations }}
annotations:
{{- include "prometheus-nginx-exporter.podAnnotations" . | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "prometheus-nginx-exporter.serviceAccountName" . }}
{{- with .Values.initContainers }}
initContainers: {{ toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-nginx.scrape-uri={{ tpl .Values.nginxServer . }}"
{{- range $key, $value := .Values.options }}
- "-{{ $key }}{{ if $value }}={{ $value }}{{ end }}"
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | trim | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | trim | nindent 12 }}
{{- with .Values.resources }}
resources: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.extraVolumeMounts }}
volumeMounts: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.extraEnv }}
env: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.extraContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.extraVolumes }}
volumes: {{ toYaml . | nindent 8 }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/prometheus-nginx-exporter/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.rbac.create }}
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "prometheus-nginx-exporter.fullname" . }}
namespace: {{ template "prometheus-nginx-exporter.namespace" . }}
{{- with .Values.additionalAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "prometheus-nginx-exporter.labels" . | indent 4 }}
rules:
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["get"]
{{- end }}
20 changes: 20 additions & 0 deletions charts/prometheus-nginx-exporter/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.rbac.create }}
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "prometheus-nginx-exporter.fullname" . }}
namespace: {{ template "prometheus-nginx-exporter.namespace" . }}
{{- with .Values.additionalAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "prometheus-nginx-exporter.labels" . | indent 4 }}
subjects:
- kind: ServiceAccount
name: {{ template "prometheus-nginx-exporter.serviceAccountName" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ template "prometheus-nginx-exporter.fullname" . }}
{{- end }}
Loading

0 comments on commit e01cd64

Please sign in to comment.