diff --git a/charts/aws-health-exporter/Chart.yaml b/charts/aws-health-exporter/Chart.yaml new file mode 100644 index 0000000..b215932 --- /dev/null +++ b/charts/aws-health-exporter/Chart.yaml @@ -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 diff --git a/charts/aws-health-exporter/README.md b/charts/aws-health-exporter/README.md new file mode 100644 index 0000000..8700c3a --- /dev/null +++ b/charts/aws-health-exporter/README.md @@ -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"` | | diff --git a/charts/aws-health-exporter/README.md.gotmpl b/charts/aws-health-exporter/README.md.gotmpl new file mode 100644 index 0000000..3658d37 --- /dev/null +++ b/charts/aws-health-exporter/README.md.gotmpl @@ -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" . }} diff --git a/charts/aws-health-exporter/templates/_helpers.tpl b/charts/aws-health-exporter/templates/_helpers.tpl new file mode 100644 index 0000000..a63b222 --- /dev/null +++ b/charts/aws-health-exporter/templates/_helpers.tpl @@ -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 }} diff --git a/charts/aws-health-exporter/templates/deployment.yaml b/charts/aws-health-exporter/templates/deployment.yaml new file mode 100644 index 0000000..ed9c94a --- /dev/null +++ b/charts/aws-health-exporter/templates/deployment.yaml @@ -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 }} diff --git a/charts/aws-health-exporter/templates/service.yaml b/charts/aws-health-exporter/templates/service.yaml new file mode 100644 index 0000000..1af8d7e --- /dev/null +++ b/charts/aws-health-exporter/templates/service.yaml @@ -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 }} diff --git a/charts/aws-health-exporter/templates/serviceaccount.yaml b/charts/aws-health-exporter/templates/serviceaccount.yaml new file mode 100644 index 0000000..8c617f5 --- /dev/null +++ b/charts/aws-health-exporter/templates/serviceaccount.yaml @@ -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 }} diff --git a/charts/aws-health-exporter/templates/servicemonitor.yaml b/charts/aws-health-exporter/templates/servicemonitor.yaml new file mode 100644 index 0000000..0f32e9a --- /dev/null +++ b/charts/aws-health-exporter/templates/servicemonitor.yaml @@ -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 }} diff --git a/charts/aws-health-exporter/values.yaml b/charts/aws-health-exporter/values.yaml new file mode 100644 index 0000000..dcde3d1 --- /dev/null +++ b/charts/aws-health-exporter/values.yaml @@ -0,0 +1,101 @@ +nameOverride: null +fullnameOverride: null + +image: + registry: docker.io + repository: andreziviani/aws-health-exporter + # -- Overrides the image tag whose default is the chart's appVersion + tag: null + pullPolicy: IfNotPresent + +imagePullSecrets: [] + +args: [] + +#env: +# - name: SLACK_TOKEN +# valueFrom: +# secretKeyRef: +# name: aws-health-exporter +# key: SLACK_TOKEN +# - name: SLACK_CHANNEL +# valueFrom: +# secretKeyRef: +# name: aws-health-exporter +# key: SLACK_CHANNEL + +annotations: {} + +updateStrategy: + type: RollingUpdate + +podLabels: {} + +podAnnotations: {} +# prometheus.io/scrape: "true" +# prometheus.io/port: "http-metrics" + +resources: + requests: + cpu: 50m + memory: 128Mi +# limits: +# cpu: 5m +# memory: 20Mi + +podPortName: http-metrics + +service: + enabled: true + type: ClusterIP + port: 80 + targetPort: 8080 + annotations: {} + labels: {} + portName: http-metrics + +serviceAccount: + create: true + name: null + labels: {} + #annotations: + # eks.amazonaws.com/role-arn: ... + +serviceMonitor: + enabled: false + path: /metrics + labels: {} + interval: 30s + scheme: http + tlsConfig: {} + scrapeTimeout: 30s + relabelings: [] + +#nodeSelector: | +# selector: label +# +#topologySpreadConstraints: | +# - maxSkew: 1 +# topologyKey: topology.kubernetes.io/zone +# whenUnsatisfiable: DoNotSchedule +# labelSelector: +# matchLabels: +# {{- include "aws-health-exporter.selectorLabels" . | nindent 6 }} +# +#affinity: | +# podAntiAffinity: +# requiredDuringSchedulingIgnoredDuringExecution: +# - labelSelector: +# matchLabels: +# {{- include "aws-health-exporter.selectorLabels" . | nindent 10 }} +# topologyKey: kubernetes.io/hostname +# +#tolerations: | +# - effect: NoSchedule +# operator: Exists + +podSecurityContext: {} + +containerSecurityContext: + privileged: false + runAsUser: 1000