From 280399df813065e072e6f3b82541db90099ee950 Mon Sep 17 00:00:00 2001 From: huiwq1990 Date: Mon, 4 Jan 2021 12:39:30 +0800 Subject: [PATCH] support chart deploy --- charts/kube-event-exporter/.gitignore | 1 + charts/kube-event-exporter/.helmignore | 3 ++ charts/kube-event-exporter/Chart.yaml | 4 ++ charts/kube-event-exporter/README.md | 25 ++++++++++ .../templates/_helpers.tpl | 39 +++++++++++++++ .../kube-event-exporter/templates/config.yaml | 13 +++++ .../templates/deployment.yaml | 47 +++++++++++++++++++ .../kube-event-exporter/templates/roles.yaml | 26 ++++++++++ charts/kube-event-exporter/values.yaml | 22 +++++++++ 9 files changed, 180 insertions(+) create mode 100644 charts/kube-event-exporter/.gitignore create mode 100644 charts/kube-event-exporter/.helmignore create mode 100644 charts/kube-event-exporter/Chart.yaml create mode 100644 charts/kube-event-exporter/README.md create mode 100644 charts/kube-event-exporter/templates/_helpers.tpl create mode 100644 charts/kube-event-exporter/templates/config.yaml create mode 100644 charts/kube-event-exporter/templates/deployment.yaml create mode 100644 charts/kube-event-exporter/templates/roles.yaml create mode 100644 charts/kube-event-exporter/values.yaml diff --git a/charts/kube-event-exporter/.gitignore b/charts/kube-event-exporter/.gitignore new file mode 100644 index 00000000..68d93c64 --- /dev/null +++ b/charts/kube-event-exporter/.gitignore @@ -0,0 +1 @@ +requirements.lock diff --git a/charts/kube-event-exporter/.helmignore b/charts/kube-event-exporter/.helmignore new file mode 100644 index 00000000..4e50d4fb --- /dev/null +++ b/charts/kube-event-exporter/.helmignore @@ -0,0 +1,3 @@ +# Ignore common backup files +*.swp +*~ diff --git a/charts/kube-event-exporter/Chart.yaml b/charts/kube-event-exporter/Chart.yaml new file mode 100644 index 00000000..4542b47a --- /dev/null +++ b/charts/kube-event-exporter/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v2 +description: Kube event exporter helm chart +name: kube-event-exporter +version: 0.9 diff --git a/charts/kube-event-exporter/README.md b/charts/kube-event-exporter/README.md new file mode 100644 index 00000000..07efeca9 --- /dev/null +++ b/charts/kube-event-exporter/README.md @@ -0,0 +1,25 @@ + +## Kube Event Exporter + +This tool allows exporting the often missed Kubernetes events to various outputs so that they can be used for observability or alerting purposes. + +## Prerequisites + +- Kubernetes 1.14+ +- Helm 3.2+ + +## Installing the Chart + +First, download the git repository. + +```shell +$ helm install kubeevent -n monitoring ./charts/kube-event-exporter +``` + +## Configuration +The following tables lists the configurable parameters of the chart and their default values. + +| Parameter | Description | Default | +| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------| +| imagePullSecrets | Image pull secrets. | [] +| exporter.config | Config values for exporter | dump to stdout diff --git a/charts/kube-event-exporter/templates/_helpers.tpl b/charts/kube-event-exporter/templates/_helpers.tpl new file mode 100644 index 00000000..1a070b43 --- /dev/null +++ b/charts/kube-event-exporter/templates/_helpers.tpl @@ -0,0 +1,39 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "kubeevent.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 "kubeevent.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 "kubeevent.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Allow for the ability to override the release name used as a label in many places. +*/}} +{{- define "kubeevent.releaseLabel" -}} +{{- .Values.releaseLabelOverride | default .Release.Name | trunc 63 -}} +{{- end -}} \ No newline at end of file diff --git a/charts/kube-event-exporter/templates/config.yaml b/charts/kube-event-exporter/templates/config.yaml new file mode 100644 index 00000000..ea243e8a --- /dev/null +++ b/charts/kube-event-exporter/templates/config.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: "{{ include "kubeevent.fullname" . }}-cfg" + labels: + app: {{ template "kubeevent.name" . }} + chart: {{ template "kubeevent.chart" . }} + release: {{ template "kubeevent.releaseLabel" . }} +data: + config.yaml: | + {{- if .Values.exporter.config }} + {{- toYaml .Values.exporter.config | nindent 4 }} + {{- end }} diff --git a/charts/kube-event-exporter/templates/deployment.yaml b/charts/kube-event-exporter/templates/deployment.yaml new file mode 100644 index 00000000..c8f65f4a --- /dev/null +++ b/charts/kube-event-exporter/templates/deployment.yaml @@ -0,0 +1,47 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: "{{ include "kubeevent.fullname" . }}" + labels: + app: {{ template "kubeevent.name" . }} + chart: {{ template "kubeevent.chart" . }} + release: {{ template "kubeevent.releaseLabel" . }} +{{- if .Values.exporter.labels }} +{{ toYaml .Values.exporter.labels | indent 4 }} +{{- end }} +{{- if .Values.exporter.annotations }} + annotations: +{{ toYaml .Values.exporter.annotations | indent 4 }} +{{- end }} +spec: + replicas: {{ toYaml .Values.exporter.replicaCount }} + template: + metadata: + labels: + app: {{ template "kubeevent.name" . }} + release: {{ template "kubeevent.releaseLabel" . }} + version: v1 + spec: + serviceAccountName: "{{ include "kubeevent.fullname" . }}" + {{- if .Values.imagePullSecrets }} + imagePullSecrets: +{{ toYaml .Values.imagePullSecrets | indent 8 }} + {{- end }} + containers: + - name: event-exporter + image: "{{ .Values.exporter.repository }}:{{ .Values.exporter.tag }}" + imagePullPolicy: {{ .Values.exporter.imagePullPolicy }} + args: + - -conf=/data/config.yaml + volumeMounts: + - mountPath: /data + name: cfg + volumes: + - name: cfg + configMap: + name: "{{ include "kubeevent.fullname" . }}-cfg" + selector: + matchLabels: + app: {{ template "kubeevent.name" . }} + release: {{ template "kubeevent.releaseLabel" . }} + version: v1 diff --git a/charts/kube-event-exporter/templates/roles.yaml b/charts/kube-event-exporter/templates/roles.yaml new file mode 100644 index 00000000..e69306a2 --- /dev/null +++ b/charts/kube-event-exporter/templates/roles.yaml @@ -0,0 +1,26 @@ + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: "{{ include "kubeevent.fullname" . }}" + labels: + app: {{ template "kubeevent.name" . }} + chart: {{ template "kubeevent.chart" . }} + release: {{ template "kubeevent.releaseLabel" . }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: "{{ include "kubeevent.fullname" . }}" + labels: + app: {{ template "kubeevent.name" . }} + chart: {{ template "kubeevent.chart" . }} + release: {{ template "kubeevent.releaseLabel" . }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: view +subjects: + - kind: ServiceAccount + namespace: {{ .Release.Namespace }} + name: "{{ include "kubeevent.fullname" . }}" diff --git a/charts/kube-event-exporter/values.yaml b/charts/kube-event-exporter/values.yaml new file mode 100644 index 00000000..e8427046 --- /dev/null +++ b/charts/kube-event-exporter/values.yaml @@ -0,0 +1,22 @@ + +exporter: + annotations: {} + replicaCount: 1 + repository: opsgenie/kubernetes-event-exporter + tag: 0.9 + imagePullPolicy: IfNotPresent + config: + logLevel: error + logFormat: json + route: + routes: + - match: + - receiver: "dump" + receivers: + - name: "dump" + file: + path: "/dev/stdout" + +## Ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] +# - name: secretName