Skip to content

Commit

Permalink
feat: add drl exporter chart
Browse files Browse the repository at this point in the history
  • Loading branch information
kha7iq committed Aug 30, 2024
1 parent 12199f8 commit 1435c4c
Show file tree
Hide file tree
Showing 14 changed files with 615 additions and 0 deletions.
58 changes: 58 additions & 0 deletions charts/drl-exporter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Useful `.gitignore` templates:
# https://github.com/github/gitignore

# ----------------------------------------------------------------------
# | Linux |
# ----------------------------------------------------------------------

*~
_local
dist
site
.choco


# ----------------------------------------------------------------------
# | Miscellaneous |
# ----------------------------------------------------------------------

# Node.js, npm, and yarn.

node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*


# ----------------------------------------------------------------------
# | macOS |
# ----------------------------------------------------------------------

._*
.AppleDouble
.DS_Store
.localized
.LSOverride
.Spotlight-V100
.Trashes


# ----------------------------------------------------------------------
# | Vim |
# ----------------------------------------------------------------------

%*
*.sw[a-z]
*.un~
.netrwhist
Session.vim


# ----------------------------------------------------------------------
# | Windows |
# ----------------------------------------------------------------------

Desktop.ini
ehthumbs.db
Thumbs.db

23 changes: 23 additions & 0 deletions charts/drl-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
# OWNERS file for Kubernetes
OWNERS
15 changes: 15 additions & 0 deletions charts/drl-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v2
name: drl-exporter
version: 0.1.1
description: Prometheus exporter for dockerhub rate limits
type: application
keywords:
- prometheus
- exporter
- dockerhub
home: https://charts.lmno.pk
maintainers:
- name: Abdul Khaliq
email: a.khaliq@outlook.my
url: https://github.com/kha7iq/charts
appVersion: 2.1.2
62 changes: 62 additions & 0 deletions charts/drl-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Rate Limit Exporter

### This chart can be used to deploy [DRL Exporter](https://github.com/kha7iq/drl-exporter).

![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.1.2](https://img.shields.io/badge/AppVersion-2.1.2-informational?style=flat-square)

## Installing the Chart

To install the chart with the release name `drl-exporter`

```console
$ helm repo add lmno http://charts.lmno.pk
$ helm install drl-exporter lmno/drl-exporter
```

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Configure [affinity and anti-affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity). |
| args | list | `[]` | Override default image arguments. |
| command | list | `[]` | Override default image command. |
| dnsConfig | object | `{}` | Specify a custom dns config [dnsConfig](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-dns-config). |
| dnsPolicy | string | `"ClusterFirst"` | Specify dns policy [dnsPolicy](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy). |
| env | list | `[]` | Define environment variables. |
| envFrom | list | `[]` | Define environment variables from existing ConfigMap or Secret data. |
| exporter.auth.dockerHubPassword | string | `""` | Dockerhub passowrd |
| exporter.auth.dockerHubUsername | string | `""` | Dockerhub username |
| exporter.auth.enableFileAuth | object | `{"configFileLocation":"","enabled":false}` | Docker config file based authentication |
| exporter.auth.enableFileAuth.configFileLocation | string | `""` | Config file location |
| exporter.auth.enableFileAuth.enabled | bool | `false` | Enable file based authentication |
| exporter.auth.enabled | bool | `false` | Enable/disable authentication for given account |
| exporter.listenPort | int | `2121` | |
| global.commonLabels | object | `{}` | Apply labels to all resources. |
| global.fullnameOverride | string | `""` | Override the fully qualified app name. |
| global.nameOverride | string | `""` | Override the name of the app. |
| image.name | string | `"khaliq/drl-exporter"` | Specify the image name to use (relative to `image.repository`). |
| image.pullPolicy | string | `"Always"` | Specify the [pullPolicy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy). |
| image.pullSecrets | list | `[]` | Specify the image pull secrets if pulling from private registry [imagePullSecrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod). |
| image.repository | string | `"docker.io"` | Specify the image repository to use. |
| image.tag | string | `"latest"` | Specify the image tag to use. ( latest or specific release ) |
| lifecycle | object | `{}` | Specify lifecycle hooks for Containers. |
| livenessProbe | object | `{}` | Specify the livenessProbe [configuration](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes). |
| nodeSelector | object | `{}` | Configure [nodeSelector](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector). |
| podAnnotations | object | `{}` | Set annotations on Pods. |
| podHostNetwork | bool | `false` | Enable the hostNetwork option on Pods. |
| podLabels | object | `{}` | Set labels on Pods. |
| podPriorityClassName | string | `""` | Set the [priorityClassName](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass). |
| readinessProbe | object | `{}` | Specify the readinessProbe [configuration](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes). |
| resources | object | `{"limits":{"cpu":"500m","memory":"256Mi"},"requests":{"cpu":"100m","memory":"128Mi"}}` | Specify resource requests and limits. |
| serviceAccount.create | bool | `true` | |
| serviceMonitor.enabled | bool | `false` | |
| serviceMonitor.interval | string | `"1m"` | |
| serviceMonitor.labels | object | `{}` | |
| serviceMonitor.path | string | `"/metrics"` | |
| serviceMonitor.relabelings | list | `[]` | |
| serviceMonitor.scheme | string | `"http"` | |
| serviceMonitor.scrapeTimeout | string | `"30s"` | |
| serviceMonitor.tlsConfig | object | `{}` | |
| tolerations | list | `[]` | Configure [taints and tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/). |
| topologySpreadConstraints | list | `[]` | Configure [topology spread constraints](https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/). |

21 changes: 21 additions & 0 deletions charts/drl-exporter/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Rate Limit Exporter

### This chart can be used to deploy [DRL Exporter](https://github.com/kha7iq/drl-exporter).

{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}



## Installing the Chart

To install the chart with the release name `drl-exporter`

```console
$ helm repo add lmno http://charts.lmno.pk
$ helm install drl-exporter lmno/{{ template "chart.name" . }}
```

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}

10 changes: 10 additions & 0 deletions charts/drl-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


Thank you for installing {{ .Chart.Name }}, your release {{ .Release.Name }} is deployed.

************************************************************************************
*** PLEASE BE PATIENT: It may take a little while for the release to be available. ***
************************************************************************************

To watch the status of service run:
kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "drl.fullname" . }}
84 changes: 84 additions & 0 deletions charts/drl-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "drl.name" -}}
{{- default .Chart.Name .Values.global.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate strings at 63 characters because some Kubernetes name fields are limited to this (by the DNS naming spec).
If the release name contains a chart name it will be used as a full name.
*/}}
{{- define "drl.fullname" -}}
{{- if .Values.global.fullnameOverride }}
{{- .Values.global.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.global.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 "drl.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}


{{/*
Common template labels.
*/}}
{{- define "drl.template-labels" -}}
app.kubernetes.io/name: {{ include "drl.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Common labels.
*/}}
{{- define "drl.labels" -}}
helm.sh/chart: {{ include "drl.chart" . }}
{{ include "drl.template-labels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Values.image.tag | quote }}
{{- end }}
{{- if .Values.global.commonLabels }}
{{ toYaml .Values.global.commonLabels }}
{{- end }}
{{- end -}}


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


{{/*
Return the target Kubernetes version
*/}}
{{- define "drl.kubeVersion" -}}
{{- .Capabilities.KubeVersion.Version -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for deployment.
*/}}
{{- define "drl.deployment.apiVersion" -}}
{{- if semverCompare "<1.14-0" (include "drl.kubeVersion" .) -}}
{{- print "extensions/v1beta1" -}}
{{- else -}}
{{- print "apps/v1" -}}
{{- end -}}
{{- end -}}
86 changes: 86 additions & 0 deletions charts/drl-exporter/templates/_pod.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{{/*
Defines the PodSpec for exporter.
*/}}
{{- define "drl.pod" -}}
{{- if .Values.podHostNetwork }}
hostNetwork: {{ .Values.podHostNetwork }}
{{- end }}
{{- if .Values.podPriorityClassName }}
priorityClassName: {{ .Values.podPriorityClassName }}
{{- end }}
{{- if .Values.dnsPolicy }}
dnsPolicy: {{ .Values.dnsPolicy }}
{{- end }}
{{- if .Values.dnsConfig }}
dnsConfig: {{ toYaml .Values.dnsConfig | nindent 2 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets: {{ toYaml .Values.image.pullSecrets | nindent 2 }}
{{- end }}
containers:
- name: drl-exporter
image: "{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.serviceAccount.create }}
serviceAccountName: {{ include "drl.fullname" . }}
{{- end }}
ports:
- name: http
containerPort: {{ default "2121" .Values.exporter.listenPort }}
protocol: TCP
{{- if .Values.command }}
command: {{ .Values.command }}
{{- end }}
{{- if .Values.args }}
args: {{ toYaml .Values.args | nindent 6 }}
{{- end }}
env:
- name: EXPORTER_PORT
value: {{ default 2121 .Values.exporter.listenPort | quote }}
{{- if .Values.exporter.auth.enabled -}}
- name: DOCKERHUB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "drl.fullname" . }}-secrets
key: dockerhub-password
- name: DOCKERHUB_USER
valueFrom:
secretKeyRef:
name: {{ include "drl.fullname" . }}-secrets
key: dockerhub-username
{{- end }}
{{- if .Values.exporter.auth.enabled -}}
- name: FILE_AUTH_DIR
valueF: {{ default "/config" .Values.exporter.auth.enableFileAuth.configFileLocation | quote }}
{{- end }}
{{- if .Values.env }}
{{ toYaml .Values.env | indent 4 }}
{{- end }}
{{- if .Values.envFrom }}
envFrom: {{ toYaml .Values.envFrom | nindent 6 }}
{{- end }}
{{- if .Values.livenessProbe }}
livenessProbe: {{ toYaml .Values.livenessProbe | trim | nindent 6 }}
{{- end }}
{{- if .Values.readinessProbe }}
readinessProbe: {{ toYaml .Values.readinessProbe | trim | nindent 6 }}
{{- end }}
{{- if .Values.resources }}
resources: {{ toYaml .Values.resources | nindent 6 }}
{{- end }}
{{- if .Values.lifecycle }}
lifecycle: {{ toYaml .Values.lifecycle | nindent 6 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector: {{ toYaml .Values.nodeSelector | nindent 2 }}
{{- end }}
{{- if .Values.affinity }}
affinity: {{ toYaml .Values.affinity | nindent 2 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations: {{ toYaml .Values.tolerations | nindent 2 }}
{{- end }}
{{- if .Values.topologySpreadConstraints }}
topologySpreadConstraints: {{ toYaml .Values.topologySpreadConstraints | nindent 2 }}
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/drl-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: {{ include "drl.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ include "drl.fullname" . }}
namespace: {{ .Release.Namespace }}
labels: {{ include "drl.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "drl.template-labels" . | nindent 6 }}
template:
metadata:
labels: {{ include "drl.template-labels" . | nindent 8 }}
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
{{- end }}
annotations:
checksum/secret: {{ tpl (toYaml .Values.exporter.auth.dockerHubPassword) . | sha256sum }}
{{- if .Values.podAnnotations }}
{{ tpl (toYaml .Values.podAnnotations) . | indent 8 }}
{{- end }}
spec: {{ include "drl.pod" . | nindent 6 }}
Loading

0 comments on commit 1435c4c

Please sign in to comment.