From b9d929dfd6efd36135796cf6d1db09fb295a12a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Sun, 30 Oct 2022 23:39:01 +0100 Subject: [PATCH] [jiralert] Setup chart (#2591) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke Signed-off-by: Jan-Otto Kröpke --- .github/CODEOWNERS | 1 + charts/jiralert/.helmignore | 24 +++ charts/jiralert/Chart.yaml | 17 ++ charts/jiralert/Readme.md | 50 ++++++ .../jiralert/ci/example-receivers-values.yaml | 7 + charts/jiralert/templates/_helpers.tpl | 95 +++++++++++ charts/jiralert/templates/deployment.yaml | 73 +++++++++ charts/jiralert/templates/ingress.yaml | 59 +++++++ charts/jiralert/templates/secret.yaml | 12 ++ charts/jiralert/templates/service.yaml | 16 ++ charts/jiralert/templates/serviceaccount.yaml | 16 ++ charts/jiralert/values.yaml | 147 ++++++++++++++++++ 12 files changed, 517 insertions(+) create mode 100755 charts/jiralert/.helmignore create mode 100755 charts/jiralert/Chart.yaml create mode 100644 charts/jiralert/Readme.md create mode 100644 charts/jiralert/ci/example-receivers-values.yaml create mode 100755 charts/jiralert/templates/_helpers.tpl create mode 100755 charts/jiralert/templates/deployment.yaml create mode 100644 charts/jiralert/templates/ingress.yaml create mode 100755 charts/jiralert/templates/secret.yaml create mode 100755 charts/jiralert/templates/service.yaml create mode 100644 charts/jiralert/templates/serviceaccount.yaml create mode 100755 charts/jiralert/values.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f200cff8abbb..00961078a19d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -7,6 +7,7 @@ * @prometheus-community/helm-charts-admins /charts/alertmanager/ @monotek @naseemkullah +/charts/jiralert/ @jkroepke @zanhsieh /charts/kube-prometheus-stack/ @andrewgkew @gianrubio @gkarthiks @GMartinez-Sisti @scottrigby @Xtigyro /charts/kube-state-metrics/ @dotdc @mrueg @tariq1890 /charts/prom-label-proxy/ @jkroepke diff --git a/charts/jiralert/.helmignore b/charts/jiralert/.helmignore new file mode 100755 index 000000000000..bd0d1ac448c6 --- /dev/null +++ b/charts/jiralert/.helmignore @@ -0,0 +1,24 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ +Readme.md diff --git a/charts/jiralert/Chart.yaml b/charts/jiralert/Chart.yaml new file mode 100755 index 000000000000..7b901b4c263b --- /dev/null +++ b/charts/jiralert/Chart.yaml @@ -0,0 +1,17 @@ +apiVersion: v2 +name: jiralert +description: A Helm chart for Kubernetes to install jiralert +type: application +version: 0.1.0 +appVersion: "1.2" +home: "https://github.com/prometheus-community/jiralert" +keywords: + - monitoring + - prometheus + - alerting + - jiralert +maintainers: + - name: jkroepke + email: github@jkroepke.de + - name: zanhsieh + email: zanhsieh@gmail.com diff --git a/charts/jiralert/Readme.md b/charts/jiralert/Readme.md new file mode 100644 index 000000000000..52447ab97cbc --- /dev/null +++ b/charts/jiralert/Readme.md @@ -0,0 +1,50 @@ +# jiralert + +JIRAlert implements Alertmanager's webhook HTTP API and connects to one or more JIRA instances to create highly configurable JIRA issues. + +**Homepage:** + +## 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/jiralert +``` + +_See [configuration](#configuration) 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._ + +## Configuration + +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/jiralert +``` diff --git a/charts/jiralert/ci/example-receivers-values.yaml b/charts/jiralert/ci/example-receivers-values.yaml new file mode 100644 index 000000000000..665604814946 --- /dev/null +++ b/charts/jiralert/ci/example-receivers-values.yaml @@ -0,0 +1,7 @@ +config: + defaults: + user: jiraUser + password: jiraToken + receivers: + - name: 'default' + project: EXAMPLE diff --git a/charts/jiralert/templates/_helpers.tpl b/charts/jiralert/templates/_helpers.tpl new file mode 100755 index 000000000000..221458f8347e --- /dev/null +++ b/charts/jiralert/templates/_helpers.tpl @@ -0,0 +1,95 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "jiralert.name" -}} +{{- default .Release.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 "jiralert.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 "jiralert.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "jiralert.labels" -}} +helm.sh/chart: {{ include "jiralert.chart" . }} +{{ include "jiralert.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "jiralert.selectorLabels" -}} +app.kubernetes.io/name: {{ include "jiralert.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + + +{{/* +Create the name of the service account to use +*/}} +{{- define "jiralert.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "jiralert.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Return the appropriate apiVersion for rbac. +*/}} +{{- define "rbac.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" }} +{{- print "rbac.authorization.k8s.io/v1" -}} +{{- else -}} +{{- print "rbac.authorization.k8s.io/v1beta1" -}} +{{- end -}} +{{- end -}} + +{{- define "jiralert.namespace" -}} + {{- if .Values.namespaceOverride -}} + {{- .Values.namespaceOverride -}} + {{- else -}} + {{- .Release.Namespace -}} + {{- end -}} +{{- end -}} + +{{/* +Return the appropriate apiVersion for ingress. +*/}} +{{- define "jiralert.ingress.apiversion" -}} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "networking.k8s.io/v1" -}} +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "networking.k8s.io/v1beta1" -}} +{{- else -}} +{{- print "extensions/v1beta1" -}} +{{- end }} +{{- end }} diff --git a/charts/jiralert/templates/deployment.yaml b/charts/jiralert/templates/deployment.yaml new file mode 100755 index 000000000000..912b10122de6 --- /dev/null +++ b/charts/jiralert/templates/deployment.yaml @@ -0,0 +1,73 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "jiralert.fullname" . }} + namespace: {{ template "jiralert.namespace" . }} + labels: + {{- include "jiralert.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "jiralert.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "jiralert.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.global.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: jiralert + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "-config=/config/jiralert.yml" + - "-listen-address=:9097" + {{- with .Values.extraArgs }} + {{- toYaml . | nindent 12 }} + {{- end }} + ports: + - name: http + containerPort: 9097 + protocol: TCP + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: config + mountPath: "/config" + readOnly: true + serviceAccountName: {{ include "jiralert.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- end }} + volumes: + - name: config + secret: + secretName: {{ .Values.existingConfigSecret | default (include "jiralert.fullname" .) }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/jiralert/templates/ingress.yaml b/charts/jiralert/templates/ingress.yaml new file mode 100644 index 000000000000..6d48cf9ec8d9 --- /dev/null +++ b/charts/jiralert/templates/ingress.yaml @@ -0,0 +1,59 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "jiralert.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +apiVersion: {{template "jiralert.ingress.apiversion" . }} +kind: Ingress +metadata: + name: {{ $fullName }} + namespace: {{ template "jiralert.namespace" . }} + labels: + {{- include "jiralert.labels" . | nindent 4 }} + {{- with .Values.ingress.labels }} + {{- toYaml . | nindent 4 }} + {{- end}} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- with .Values.ingress.tls }} + tls: + {{- range . }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/jiralert/templates/secret.yaml b/charts/jiralert/templates/secret.yaml new file mode 100755 index 000000000000..5a252d91f181 --- /dev/null +++ b/charts/jiralert/templates/secret.yaml @@ -0,0 +1,12 @@ +{{- if not .Values.existingConfigSecret }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "jiralert.fullname" . }} + namespace: {{ template "jiralert.namespace" . }} + labels: + {{- include "jiralert.labels" . | nindent 4 }} +data: + jiralert.yml: {{ tpl (.Values.config | toYaml) . | b64enc }} + jiralert.tmpl: {{ tpl .Values.issueTemplate . | b64enc }} +{{- end }} diff --git a/charts/jiralert/templates/service.yaml b/charts/jiralert/templates/service.yaml new file mode 100755 index 000000000000..2acedfefcd41 --- /dev/null +++ b/charts/jiralert/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "jiralert.fullname" . }} + namespace: {{ template "jiralert.namespace" . }} + labels: + {{- include "jiralert.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: 9097 + targetPort: http + protocol: TCP + name: http + selector: + {{- include "jiralert.selectorLabels" . | nindent 4 }} diff --git a/charts/jiralert/templates/serviceaccount.yaml b/charts/jiralert/templates/serviceaccount.yaml new file mode 100644 index 000000000000..8223171a9f89 --- /dev/null +++ b/charts/jiralert/templates/serviceaccount.yaml @@ -0,0 +1,16 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "jiralert.serviceAccountName" . }} + namespace: {{ template "jiralert.namespace" . }} + labels: + {{- include "jiralert.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/jiralert/values.yaml b/charts/jiralert/values.yaml new file mode 100755 index 000000000000..f49cd51eb0af --- /dev/null +++ b/charts/jiralert/values.yaml @@ -0,0 +1,147 @@ +global: + imagePullSecrets: [] + +# -- String to partially override jiralert.fullname template (will maintain the release name) +nameOverride: "" + +# -- Override the namespace +namespaceOverride: "" + +# -- String to fully override amazon-eks-pod-identity.fullname template +fullnameOverride: "" + +image: + pullPolicy: IfNotPresent + # -- jiralert image registry + repository: quay.io/jiralert/jiralert-linux-amd64 + # -- jiralert image tag (immutable tags are recommended). + # @default -- `.Chart.AppVersion` + tag: "" + +extraArgs: + - -log.level=debug + +# Number of pod replicas +replicaCount: 1 + +# Container resources +resources: + # -- The resources limits for the jiralert container + ## Example: + ## limits: + ## cpu: 100m + ## memory: 128Mi + limits: + cpu: 200m + memory: 128Mi + # -- The requested resources for the jiralert container + ## Examples: + ## requests: + ## cpu: 100m + ## memory: 128Mi + requests: + cpu: 100m + memory: 64Mi + +# -- Annotations for jiralert pods +podAnnotations: {} + +# -- jiralert pods' Security Context. +podSecurityContext: {} +# fsGroup: 2000 + +# Container security context +securityContext: + runAsUser: 1001 + runAsGroup: 1001 + runAsNonRoot: true + readOnlyRootFilesystem: true + +livenessProbe: + httpGet: + path: /healthz + port: http +readinessProbe: + httpGet: + path: /healthz + port: http + +serviceAccount: + # -- Enable creation of ServiceAccount for nginx pod + create: true + # -- The name of the ServiceAccount to use. + # @default -- A name is generated using the `jiralert.fullname` template + name: '' + # -- Annotations for service account. Evaluated as a template. + annotations: {} + # -- Labels for service account. Evaluated as a template. + labels: {} + +existingConfigSecret: ~ + +config: + # File containing template definitions. Required. + template: jiralert.tmpl + + # Example: https://github.com/prometheus-community/jiralert/blob/master/examples/jiralert.yml + defaults: + # API access fields. + api_url: "https://example.atlassian.net" + # user: {{ .config.jiraUser }} + # password: '{{ .config.jiraToken }}' + summary: '{{`{{ template "jira.summary" . }}`}}' + description: '{{`{{ template "jira.description" . }}`}}' + issue_type: Bug + reopen_state: "To Do" + reopen_duration: 0h + + # Receiver definitions. At least one must be defined. + receivers: [] + # - name: 'default' + # # JIRA project to create the issue in. Required. + # project: + # # Copy all Prometheus labels into separate JIRA labels. Optional (default: false). + # add_group_labels: false + # fields: + # # Set the Environment field + # "customfield_10078": { "value": { { .config.receiver.environment | quote } } } + # # Set the Organization field + # "customfield_10002": [ { { .config.receiver.organizationID } } ] + +# -- Affinity for pod assignment +affinity: {} + +# -- Node labels for pod assignment. Evaluated as a template. +nodeSelector: {} + +# -- Tolerations for pod assignment. Evaluated as a template. +tolerations: [] + +ingress: + enabled: false + className: "" + labels: {} + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +issueTemplate: | + {{`{{ define "jira.summary" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .GroupLabels.SortedPairs.Values | join " " }} {{ if gt (len .CommonLabels) (len .GroupLabels) }}({{ with .CommonLabels.Remove .GroupLabels.Names }}{{ .Values | join " " }}{{ end }}){{ end }}{{ end }} + + {{ define "jira.description" }}{{ range .Alerts.Firing }}Labels: + {{ range .Labels.SortedPairs }} - {{ .Name }} = {{ .Value }} + {{ end }} + Annotations: + {{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }} + {{ end }} + Source: {{ .GeneratorURL }} + {{ end }}{{ end }}`}}