Skip to content

Commit

Permalink
feat: aws-health-exporter chart
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreZiviani committed Apr 3, 2023
1 parent 397bc35 commit e677bd6
Show file tree
Hide file tree
Showing 9 changed files with 429 additions and 0 deletions.
8 changes: 8 additions & 0 deletions charts/aws-health-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v2
name: aws-health-exporter
description: Sends AWS Health events to slack
type: application
appVersion: v0.0.1
version: 0.0.1
maintainers:
- name: AndreZiviani
52 changes: 52 additions & 0 deletions charts/aws-health-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# aws-health-exporter

Sends AWS Health events to slack

## Chart Repo

Add the following repo to use the chart:

```console
helm repo add andreziviani https://andreziviani.github.io/helm-charts
```

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| annotations | object | `{}` | |
| args | list | `[]` | |
| containerSecurityContext.privileged | bool | `false` | |
| containerSecurityContext.runAsUser | int | `1000` | |
| fullnameOverride | string | `nil` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.registry | string | `"docker.io"` | |
| image.repository | string | `"andreziviani/aws-health-exporter"` | |
| image.tag | string | `nil` | Overrides the image tag whose default is the chart's appVersion |
| imagePullSecrets | list | `[]` | |
| nameOverride | string | `nil` | |
| podAnnotations | object | `{}` | |
| podLabels | object | `{}` | |
| podPortName | string | `"http-metrics"` | |
| podSecurityContext | object | `{}` | |
| resources.requests.cpu | string | `"50m"` | |
| resources.requests.memory | string | `"128Mi"` | |
| service.annotations | object | `{}` | |
| service.enabled | bool | `true` | |
| service.labels | object | `{}` | |
| service.port | int | `80` | |
| service.portName | string | `"http-metrics"` | |
| service.targetPort | int | `8080` | |
| service.type | string | `"ClusterIP"` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.labels | object | `{}` | |
| serviceAccount.name | string | `nil` | |
| serviceMonitor.enabled | bool | `false` | |
| serviceMonitor.interval | string | `"30s"` | |
| serviceMonitor.labels | object | `{}` | |
| serviceMonitor.path | string | `"/metrics"` | |
| serviceMonitor.relabelings | list | `[]` | |
| serviceMonitor.scheme | string | `"http"` | |
| serviceMonitor.scrapeTimeout | string | `"30s"` | |
| serviceMonitor.tlsConfig | object | `{}` | |
| updateStrategy.type | string | `"RollingUpdate"` | |
17 changes: 17 additions & 0 deletions charts/aws-health-exporter/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{ template "chart.header" . }}

{{ template "chart.description" . }}

{{ template "chart.sourcesSection" . }}

{{ template "chart.requirementsSection" . }}

## Chart Repo

Add the following repo to use the chart:

```console
helm repo add andreziviani https://andreziviani.github.io/helm-charts
```

{{ template "chart.valuesSection" . }}
62 changes: 62 additions & 0 deletions charts/aws-health-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "aws-health-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 "aws-health-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 -}}

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

{{/*
Common labels
*/}}
{{- define "aws-health-exporter.labels" -}}
helm.sh/chart: {{ include "aws-health-exporter.chart" . }}
{{ include "aws-health-exporter.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

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

{{/*
Create the name of the service account
*/}}
{{- define "aws-health-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "aws-health-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
77 changes: 77 additions & 0 deletions charts/aws-health-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "aws-health-exporter.fullname" . }}
labels:
{{- include "aws-health-exporter.labels" . | nindent 4 }}
{{- with .Values.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "aws-health-exporter.selectorLabels" . | nindent 6 }}
replicas: 1
template:
metadata:
labels:
{{- include "aws-health-exporter.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | indent 8 }}
{{- end }}
annotations:
{{- with .Values.podAnnotations }}
{{- toYaml . | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "aws-health-exporter.serviceAccountName" . }}
{{- with .Values.priorityClassName }}
priorityClassName: {{ . }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: aws-health-exporter
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
{{- with .Values.args }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.env }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: {{ .Values.podPortName }}
containerPort: {{ .Values.service.targetPort }}
protocol: TCP
{{- if .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- tpl (.Values.topologySpreadConstraints) . | nindent 8 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{- tpl (.Values.nodeSelector) . | nindent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations:
{{- tpl (.Values.tolerations) . | nindent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{- tpl (.Values.affinity) . | nindent 8 }}
{{- end }}
54 changes: 54 additions & 0 deletions charts/aws-health-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{- if .Values.service.enabled }}
{{- $root := . }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "aws-health-exporter.fullname" . }}
labels:
{{- include "aws-health-exporter.labels" . | nindent 4 }}
{{- with .Values.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.service.annotations }}
annotations:
{{- tpl (toYaml . | nindent 4) $root }}
{{- end }}
spec:
{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }}
type: ClusterIP
{{- with .Values.service.clusterIP }}
clusterIP: {{ . }}
{{- end }}
{{- else if eq .Values.service.type "LoadBalancer" }}
type: {{ .Values.service.type }}
{{- with .Values.service.loadBalancerIP }}
loadBalancerIP: {{ . }}
{{- end }}
{{- with .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- else }}
type: {{ .Values.service.type }}
{{- end }}
{{- with .Values.service.externalIPs }}
externalIPs:
{{- toYaml . | nindent 4 }}
{{- end }}
ports:
- name: {{ .Values.service.portName }}
port: {{ .Values.service.port }}
protocol: TCP
targetPort: {{ .Values.service.targetPort }}
{{- with .Values.service.appProtocol }}
appProtocol: {{ . }}
{{- end }}
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
{{- with .Values.extraExposePorts }}
{{- tpl (toYaml . | nindent 4) $root }}
{{- end }}
selector:
{{- include "aws-health-exporter.selectorLabels" . | nindent 4 }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/aws-health-exporter/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.serviceAccount.create }}
{{- $root := . -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
{{- include "aws-health-exporter.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- tpl (toYaml . | nindent 4) $root }}
{{- end }}
name: {{ include "aws-health-exporter.serviceAccountName" . }}
{{- end }}
42 changes: 42 additions & 0 deletions charts/aws-health-exporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if .Values.serviceMonitor.enabled }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "aws-health-exporter.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ tpl .Values.serviceMonitor.namespace . }}
{{- end }}
labels:
{{- include "aws-health-exporter.labels" . | nindent 4 }}
{{- with .Values.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: {{ .Values.service.portName }}
{{- with .Values.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
honorLabels: true
path: {{ .Values.serviceMonitor.path }}
scheme: {{ .Values.serviceMonitor.scheme }}
{{- with .Values.serviceMonitor.tlsConfig }}
tlsConfig:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
jobLabel: "{{ .Release.Name }}"
selector:
matchLabels:
{{- include "aws-health-exporter.selectorLabels" . | nindent 6 }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end }}
Loading

0 comments on commit e677bd6

Please sign in to comment.