Skip to content

Commit

Permalink
Merge pull request #64 from ygqygq2/develop
Browse files Browse the repository at this point in the history
feat: add prometheusalert
  • Loading branch information
ygqygq2 authored Nov 20, 2024
2 parents c91f3ea + 79c9f18 commit bd0be7d
Show file tree
Hide file tree
Showing 24 changed files with 2,231 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ygqygq2/prometheusalert/.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
5 changes: 5 additions & 0 deletions ygqygq2/prometheusalert/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 1.0.0 (2024-11-20)

- [ygqygq2/prometheusalert] - Release 1.0.0
29 changes: 29 additions & 0 deletions ygqygq2/prometheusalert/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
annotations:
category: ApplicationServer
licenses: Apache-2.0
images: |
- name: prometheusalert
image: docker.io/feiyu563/prometheus-alert:v4.9.1
apiVersion: v2
appVersion: 4.9.1
dependencies:
- name: common
repository: https://ygqygq2.github.io/charts/
tags:
- bitnami-common
version: 2.x.x
description: Chart for PrometheusAlert
engine: gotpl
name: prometheusalert
version: 1.0.0
home: https://github.com/feiyu563/PrometheusAlert
icon: https://raw.githubusercontent.com/feiyu563/PrometheusAlert/refs/heads/master/static/dist/img/logo.png
keywords:
- prometheus
- alert
- webhook
maintainers:
- email: [email protected]
name: ygqygq2
sources:
- https://github.com/feiyu563/PrometheusAlert
289 changes: 289 additions & 0 deletions ygqygq2/prometheusalert/README.md

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions ygqygq2/prometheusalert/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
CHART NAME: {{ .Chart.Name }}
CHART VERSION: {{ .Chart.Version }}
APP VERSION: {{ .Chart.AppVersion }}
** Please be patient while the chart is being deployed **

prometheusalert can be accessed:

{{ if .Values.ingress.enabled }}
* The application URL:

{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end -}}
{{- end -}}

* Within your cluster, at the following DNS name at port {{ .Values.service.ingressPort }}:

{{ include "common.names.fullname" . }}.{{ .Release.Namespace }}.svc

* From outside the cluster, run these commands in the same shell:
{{- if contains "NodePort" .Values.service.type }}

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 }}

WARNING: You have likely exposed your prometheusalert direct to the internet.
prometheusalert does not implement any security for public facing clusters by default.
As a minimum level of security; switch to ClusterIP/NodePort and place an Nginx gateway infront of the cluster in order to lock down access to dangerous HTTP endpoints and verbs.

NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ include "common.names.fullname" . }}'

export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.names.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.ports.http.port }}
{{- else if contains "ClusterIP" .Values.service.type }}

export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:{{ .Values.service.ports.http.port }} to use prometheusalert"
kubectl port-forward --namespace {{ .Release.Namespace }} $POD_NAME {{ .Values.service.ports.http.port }}:{{ .Values.service.ports.http.port }}
{{- end }}


69 changes: 69 additions & 0 deletions ygqygq2/prometheusalert/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Return the proper NGINX image name
*/}}
{{- define "prometheusalert.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
{{- end -}}

{{/*
Return the proper Prometheus metrics image name
*/}}
{{- define "prometheusalert.metrics.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.metrics.image "global" .Values.global) }}
{{- end -}}

{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "prometheusalert.imagePullSecrets" -}}
{{ include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.metrics.image) "global" .Values.global) }}
{{- end -}}

{{/*
Expand the name of the chart.
*/}}
{{- define "prometheusalert.pvc" -}}
{{- coalesce .Values.persistence.existingClaim (include "common.names.fullname" .) -}}
{{- end -}}



{{/* Check if there are rolling tags in the images */}}
{{- define "prometheusalert.checkRollingTags" -}}
{{- include "common.warnings.rollingTag" .Values.image }}
{{- include "common.warnings.rollingTag" .Values.metrics.image }}
{{- include "common.warnings.rollingTag" .Values.volumePermissions.image }}
{{- end -}}

{{/*
Return the secret containing TLS certificates
*/}}
{{- define "prometheusalert.tlsSecretName" -}}
{{- $secretName := coalesce .Values.tls.existingSecret .Values.tls.secretName -}}
{{- if $secretName -}}
{{- printf "%s" (tpl $secretName $) -}}
{{- else -}}
{{- printf "%s-crt" (include "common.names.fullname" .) -}}
{{- end -}}
{{- end -}}

{{/*
Return true if a TLS secret object should be created
*/}}
{{- define "prometheusalert.createTlsSecret" -}}
{{- if and .Values.tls.enabled .Values.tls.autoGenerated (not .Values.tls.secretName) (not .Values.tls.existingSecret) }}
{{- true -}}
{{- end -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "prometheusalert.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
13 changes: 13 additions & 0 deletions ygqygq2/prometheusalert/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.config.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
{{- toYaml .Values.config.data | nindent 2 }}
{{- end -}}
Loading

0 comments on commit bd0be7d

Please sign in to comment.