From 8439c7450526d7a3814b10d18681868a608d140f Mon Sep 17 00:00:00 2001 From: Havrileck Alexandre Date: Mon, 5 Jul 2021 22:49:34 +0200 Subject: [PATCH] feat: Add prometheus-cachethq chart 1.0.0 --- charts/prometheus-cachethq/.helmignore | 22 +++ charts/prometheus-cachethq/Chart.yaml | 11 ++ .../prometheus-cachethq/templates/NOTES.txt | 21 +++ .../templates/_helpers.tpl | 56 +++++++ .../prometheus-cachethq/templates/config.yaml | 8 + .../templates/deployment.yaml | 78 ++++++++++ .../templates/ingress.yaml | 41 +++++ charts/prometheus-cachethq/templates/pdb.yaml | 19 +++ .../templates/service-monitor.yaml | 38 +++++ .../templates/service.yaml | 41 +++++ .../templates/serviceaccount.yaml | 8 + charts/prometheus-cachethq/values.yaml | 146 ++++++++++++++++++ 12 files changed, 489 insertions(+) create mode 100755 charts/prometheus-cachethq/.helmignore create mode 100755 charts/prometheus-cachethq/Chart.yaml create mode 100755 charts/prometheus-cachethq/templates/NOTES.txt create mode 100755 charts/prometheus-cachethq/templates/_helpers.tpl create mode 100755 charts/prometheus-cachethq/templates/config.yaml create mode 100755 charts/prometheus-cachethq/templates/deployment.yaml create mode 100755 charts/prometheus-cachethq/templates/ingress.yaml create mode 100755 charts/prometheus-cachethq/templates/pdb.yaml create mode 100755 charts/prometheus-cachethq/templates/service-monitor.yaml create mode 100755 charts/prometheus-cachethq/templates/service.yaml create mode 100755 charts/prometheus-cachethq/templates/serviceaccount.yaml create mode 100755 charts/prometheus-cachethq/values.yaml diff --git a/charts/prometheus-cachethq/.helmignore b/charts/prometheus-cachethq/.helmignore new file mode 100755 index 0000000..50af031 --- /dev/null +++ b/charts/prometheus-cachethq/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/charts/prometheus-cachethq/Chart.yaml b/charts/prometheus-cachethq/Chart.yaml new file mode 100755 index 0000000..44bc4b5 --- /dev/null +++ b/charts/prometheus-cachethq/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +appVersion: 1.0.0 +description: A Helm chart for Kubernetes to deploy Prometheus-CachetHQ +home: https://github.com/oxyno-zeta/prometheus-cachethq +maintainers: +- email: havrileckalexandre@gmail.com + name: oxyno-zeta +name: prometheus-cachethq +sources: +- https://github.com/oxyno-zeta/prometheus-cachethq +version: 1.0.0 diff --git a/charts/prometheus-cachethq/templates/NOTES.txt b/charts/prometheus-cachethq/templates/NOTES.txt new file mode 100755 index 0000000..7968ef7 --- /dev/null +++ b/charts/prometheus-cachethq/templates/NOTES.txt @@ -0,0 +1,21 @@ +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 }}{{ . }} + {{- 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-cachethq.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-cachethq.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "prometheus-cachethq.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-cachethq.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/prometheus-cachethq/templates/_helpers.tpl b/charts/prometheus-cachethq/templates/_helpers.tpl new file mode 100755 index 0000000..925fe70 --- /dev/null +++ b/charts/prometheus-cachethq/templates/_helpers.tpl @@ -0,0 +1,56 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "prometheus-cachethq.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-cachethq.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-cachethq.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "prometheus-cachethq.labels" -}} +app.kubernetes.io/name: {{ include "prometheus-cachethq.name" . }} +helm.sh/chart: {{ include "prometheus-cachethq.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "prometheus-cachethq.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "prometheus-cachethq.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/prometheus-cachethq/templates/config.yaml b/charts/prometheus-cachethq/templates/config.yaml new file mode 100755 index 0000000..454841d --- /dev/null +++ b/charts/prometheus-cachethq/templates/config.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "prometheus-cachethq.fullname" . }}-config + labels: +{{ include "prometheus-cachethq.labels" . | indent 4 }} +data: + config.yaml: {{ .Values.config | quote }} diff --git a/charts/prometheus-cachethq/templates/deployment.yaml b/charts/prometheus-cachethq/templates/deployment.yaml new file mode 100755 index 0000000..0115766 --- /dev/null +++ b/charts/prometheus-cachethq/templates/deployment.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "prometheus-cachethq.fullname" . }} + labels: +{{ include "prometheus-cachethq.labels" . | indent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "prometheus-cachethq.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }} + {{- if .Values.podAnnotations }} + {{- toYaml .Values.podAnnotations | nindent 8 -}} + {{- end }} + labels: + app.kubernetes.io/name: {{ include "prometheus-cachethq.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ template "prometheus-cachethq.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + - name: internal + containerPort: 9090 + protocol: TCP + livenessProbe: + {{ if .Values.livenessProbe }} + {{- toYaml .Values.livenessProbe | nindent 12 }} + {{- end -}} + httpGet: + path: /health + port: internal + readinessProbe: + {{ if .Values.readinessProbe }} + {{- toYaml .Values.readinessProbe | nindent 12 }} + {{- end -}} + httpGet: + path: /health + port: internal + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: config-volume + mountPath: /conf + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: config-volume + configMap: + name: {{ include "prometheus-cachethq.fullname" . }}-config diff --git a/charts/prometheus-cachethq/templates/ingress.yaml b/charts/prometheus-cachethq/templates/ingress.yaml new file mode 100755 index 0000000..30b7456 --- /dev/null +++ b/charts/prometheus-cachethq/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "prometheus-cachethq.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: +{{ include "prometheus-cachethq.labels" . | indent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/prometheus-cachethq/templates/pdb.yaml b/charts/prometheus-cachethq/templates/pdb.yaml new file mode 100755 index 0000000..9364689 --- /dev/null +++ b/charts/prometheus-cachethq/templates/pdb.yaml @@ -0,0 +1,19 @@ +{{- if .Values.podDisruptionBudget.enabled -}} +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + name: {{ include "prometheus-cachethq.fullname" . }} + labels: +{{ include "prometheus-cachethq.labels" . | indent 4 }} +spec: + {{- if .Values.podDisruptionBudget.minAvailable }} + minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} + {{- end }} + {{- if .Values.podDisruptionBudget.maxUnavailable }} + maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }} + {{- end }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "prometheus-cachethq.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} \ No newline at end of file diff --git a/charts/prometheus-cachethq/templates/service-monitor.yaml b/charts/prometheus-cachethq/templates/service-monitor.yaml new file mode 100755 index 0000000..dda602b --- /dev/null +++ b/charts/prometheus-cachethq/templates/service-monitor.yaml @@ -0,0 +1,38 @@ +{{- if .Values.prometheus.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "prometheus-cachethq.fullname" . }} + {{- if .Values.prometheus.serviceMonitor.namespace }} + namespace: {{ .Values.prometheus.serviceMonitor.namespace }} + {{- end }} + labels: +{{ include "prometheus-cachethq.labels" . | indent 4 }} + {{- if .Values.prometheus.serviceMonitor.labels }} + {{- toYaml .Values.prometheus.serviceMonitor.labels | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: metrics + {{- if .Values.prometheus.serviceMonitor.interval }} + interval: {{ .Values.prometheus.serviceMonitor.interval }} + {{- end }} + {{ if .Values.prometheus.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.prometheus.serviceMonitor.scrapeTimeout }} + {{- end }} + {{ if .Values.prometheus.serviceMonitor.metricRelabelings }} + metricRelabelings: {{ .Values.prometheus.serviceMonitor.metricRelabelings }} + {{- end }} + {{ if .Values.prometheus.serviceMonitor.relabelings }} + relabelings: {{ .Values.prometheus.serviceMonitor.relabelings }} + {{- end }} + scheme: {{ .Values.prometheus.serviceMonitor.scheme }} + jobLabel: "{{ .Release.Name }}" + selector: + matchLabels: + app.kubernetes.io/name: {{ include "prometheus-cachethq.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} +{{- end }} \ No newline at end of file diff --git a/charts/prometheus-cachethq/templates/service.yaml b/charts/prometheus-cachethq/templates/service.yaml new file mode 100755 index 0000000..8c6af74 --- /dev/null +++ b/charts/prometheus-cachethq/templates/service.yaml @@ -0,0 +1,41 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "prometheus-cachethq.fullname" . }} + labels: +{{ include "prometheus-cachethq.labels" . | indent 4 }} +{{- if .Values.service.annotations }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} +{{- end }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http +{{- if hasKey .Values.service "nodePort" }} + nodePort: {{ .Values.service.nodePort }} +{{- end }} + - port: 9090 + targetPort: internal + protocol: TCP + name: metrics + {{- if .Values.service.clusterIP }} + clusterIP: "{{ .Values.service.clusterIP }}" + {{- end }} + {{- if .Values.service.externalIPs }} + externalIPs: + {{ toYaml .Values.service.externalIPs | nindent 4 }} + {{- end }} + {{- if .Values.service.loadBalancerIP }} + loadBalancerIP: "{{ .Values.service.loadBalancerIP }}" + {{- end }} + {{- if .Values.service.loadBalancerSourceRanges }} + loadBalancerSourceRanges: +{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }} + {{- end }} + selector: + app.kubernetes.io/name: {{ include "prometheus-cachethq.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/charts/prometheus-cachethq/templates/serviceaccount.yaml b/charts/prometheus-cachethq/templates/serviceaccount.yaml new file mode 100755 index 0000000..ee61b05 --- /dev/null +++ b/charts/prometheus-cachethq/templates/serviceaccount.yaml @@ -0,0 +1,8 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "prometheus-cachethq.serviceAccountName" . }} + labels: +{{ include "prometheus-cachethq.labels" . | indent 4 }} +{{- end -}} diff --git a/charts/prometheus-cachethq/values.yaml b/charts/prometheus-cachethq/values.yaml new file mode 100755 index 0000000..eff9437 --- /dev/null +++ b/charts/prometheus-cachethq/values.yaml @@ -0,0 +1,146 @@ +# Default values for prometheus-cachethq. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: oxyno-zeta/prometheus-cachethq + tag: 1.0.0 + pullPolicy: IfNotPresent + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + # nodePort: 8888 + # clusterIP: + # externalIPs: [] + # loadBalancerIP: + # loadBalancerSourceRanges: [] + # annotations: {} + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +config: |- + # + # See configuration of project: https://oxyno-zeta.github.io/prometheus-cachethq/ + # + # Log configuration + # log: + # # Log level + # level: info + # # Log format + # format: json + # Cachet configuration + cachet: + url: http://localhost + apiKey: API_KEY + # Targets + targets: + - component: + name: COMPONENT_NAME + status: PARTIAL_OUTAGE + alerts: + - name: SERVICE_OFFLINE + # - labels: + # label1: value1 + # incident: + # name: "" + # content: "" + # status: INVESTIGATING + # public: true + + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# livenessProbe: +# initialDelaySeconds: 0 +# periodSeconds: 10 +# timeoutSeconds: 1 +# successThreshold: 1 +# failureThreshold: 3 + +# readinessProbe: +# initialDelaySeconds: 0 +# periodSeconds: 10 +# timeoutSeconds: 1 +# successThreshold: 1 +# failureThreshold: 3 + +## ServiceMonitor configuration in case you are using Prometheus Operator +prometheus: + serviceMonitor: + ## If true a ServiceMonitor for each enabled exporter will be installed + enabled: false + ## The namespace where the ServiceMonitor(s) will be installed + # namespace: monitoring + ## The selector the Prometheus instance is searching for + ## [Default Prometheus Operator selector] (https://github.com/helm/charts/blob/f5a751f174263971fafd21eee4e35416d6612a3d/stable/prometheus-operator/templates/prometheus/prometheus.yaml#L74) + labels: {} + scheme: http + # interval: 30s + # scrapeTimeout: 30s + # metricRelabelings: [] + # relabelings: [] + +# Arbitrary non-identifying metadata for prometheus-cachethq pods. +podAnnotations: {} + # prometheus.io/scrape: "true" + # prometheus.io/path: "/metrics" + # prometheus.io/port: "9090" + +podDisruptionBudget: + # https://kubernetes.io/docs/tasks/run-application/configure-pdb/ + enabled: false + minAvailable: 1 + maxUnavailable: