From f4b4ea2b30b969606771d9b45233f5d11f400afb Mon Sep 17 00:00:00 2001 From: Shane Starcher Date: Fri, 14 Dec 2018 09:57:36 -0800 Subject: [PATCH] add initial chart for helm-exporter (#9764) Signed-off-by: Shane Starcher --- stable/helm-exporter/.helmignore | 21 +++++++ stable/helm-exporter/Chart.yaml | 11 ++++ stable/helm-exporter/OWNERS | 4 ++ stable/helm-exporter/README.md | 59 +++++++++++++++++++ stable/helm-exporter/templates/NOTES.txt | 4 ++ stable/helm-exporter/templates/_helpers.tpl | 43 ++++++++++++++ .../helm-exporter/templates/deployment.yaml | 56 ++++++++++++++++++ stable/helm-exporter/templates/service.yaml | 22 +++++++ .../templates/serviceaccount.yaml | 11 ++++ stable/helm-exporter/values.yaml | 28 +++++++++ 10 files changed, 259 insertions(+) create mode 100644 stable/helm-exporter/.helmignore create mode 100644 stable/helm-exporter/Chart.yaml create mode 100644 stable/helm-exporter/OWNERS create mode 100644 stable/helm-exporter/README.md create mode 100644 stable/helm-exporter/templates/NOTES.txt create mode 100644 stable/helm-exporter/templates/_helpers.tpl create mode 100644 stable/helm-exporter/templates/deployment.yaml create mode 100644 stable/helm-exporter/templates/service.yaml create mode 100644 stable/helm-exporter/templates/serviceaccount.yaml create mode 100644 stable/helm-exporter/values.yaml diff --git a/stable/helm-exporter/.helmignore b/stable/helm-exporter/.helmignore new file mode 100644 index 000000000000..f0c131944441 --- /dev/null +++ b/stable/helm-exporter/.helmignore @@ -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 diff --git a/stable/helm-exporter/Chart.yaml b/stable/helm-exporter/Chart.yaml new file mode 100644 index 000000000000..289994d1801d --- /dev/null +++ b/stable/helm-exporter/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +appVersion: "0.1.0" +description: Exports helm release stats to prometheus +name: helm-exporter +version: 0.1.0 +home: https://github.com/sstarcher/helm-exporter +sources: +- https://github.com/sstarcher/helm-exporter +maintainers: +- name: sstarcher + email: shane.starcher@gmail.com diff --git a/stable/helm-exporter/OWNERS b/stable/helm-exporter/OWNERS new file mode 100644 index 000000000000..f624005c2f82 --- /dev/null +++ b/stable/helm-exporter/OWNERS @@ -0,0 +1,4 @@ +approvers: +- sstarcher +reviewers: +- sstarcher diff --git a/stable/helm-exporter/README.md b/stable/helm-exporter/README.md new file mode 100644 index 000000000000..5dd94b2d6a52 --- /dev/null +++ b/stable/helm-exporter/README.md @@ -0,0 +1,59 @@ +# helm-exporter + +Installs [helm-exporter](https://github.com/sstarcher/helm-exporter) to export helm stats to prometheus. + +## TL;DR; + +```console +$ helm install stable/helm-exporter +``` + +## Introduction + +This chart bootstraps a [helm-exporter](https://github.com/sstarcher/helm-exporter) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install stable/helm-exporter --name my-release +``` + +The command deploys helm-exporter on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```console +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following table lists the configurable parameters of the helm-exporter chart and their default values. + +Parameter | Description | Default +--- | --- | --- +`affinity` | affinity configuration for pod assignment | `{}` +`image.repository` | Image | `sstarcher/helm-exporter` +`image.tag` | Image tag | `0.1.0` +`image.pullPolicy` | Image pull policy | `IfNotPresent` +`nodeSelector` | node labels for pod assignment | `{}` +`resources` | pod resource requests & limits | `{}` +`tolerations` | List of node taints to tolerate (requires Kubernetes 1.6+) | `[]` + +```console +$ helm install stable/helm-exporter --name my-release +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +$ helm install stable/helm-exporter --name my-release -f values.yaml +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) diff --git a/stable/helm-exporter/templates/NOTES.txt b/stable/helm-exporter/templates/NOTES.txt new file mode 100644 index 000000000000..120127b914a5 --- /dev/null +++ b/stable/helm-exporter/templates/NOTES.txt @@ -0,0 +1,4 @@ +1. Get the application URL by running these commands: + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm-exporter.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:9100 to use your application" + kubectl port-forward $POD_NAME 9100 diff --git a/stable/helm-exporter/templates/_helpers.tpl b/stable/helm-exporter/templates/_helpers.tpl new file mode 100644 index 000000000000..8f7760b1490c --- /dev/null +++ b/stable/helm-exporter/templates/_helpers.tpl @@ -0,0 +1,43 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "helm-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 "helm-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 "helm-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "helm-exporter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "helm-exporter.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/stable/helm-exporter/templates/deployment.yaml b/stable/helm-exporter/templates/deployment.yaml new file mode 100644 index 000000000000..d72fe4ae3385 --- /dev/null +++ b/stable/helm-exporter/templates/deployment.yaml @@ -0,0 +1,56 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "helm-exporter.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "helm-exporter.name" . }} + helm.sh/chart: {{ include "helm-exporter.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "helm-exporter.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "helm-exporter.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 9100 + protocol: TCP + livenessProbe: + httpGet: + path: /metrics + port: http + readinessProbe: + httpGet: + path: /metrics + port: http + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.rbac.create }} + serviceAccountName: {{ template "helm-exporter.fullname" . }} + {{- else }} + serviceAccountName: "{{ .Values.rbac.serviceAccountName }}" + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} diff --git a/stable/helm-exporter/templates/service.yaml b/stable/helm-exporter/templates/service.yaml new file mode 100644 index 000000000000..287c5d65bfb6 --- /dev/null +++ b/stable/helm-exporter/templates/service.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "helm-exporter.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "helm-exporter.name" . }} + helm.sh/chart: {{ include "helm-exporter.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + annotations: + prometheus.io/scrape: "true" +spec: + type: ClusterIP + clusterIP: None + ports: + - port: 9100 + targetPort: http + protocol: TCP + name: metrics + selector: + app.kubernetes.io/name: {{ include "helm-exporter.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/stable/helm-exporter/templates/serviceaccount.yaml b/stable/helm-exporter/templates/serviceaccount.yaml new file mode 100644 index 000000000000..2e02cf469c7e --- /dev/null +++ b/stable/helm-exporter/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/name: {{ include "helm-exporter.name" . }} + helm.sh/chart: {{ include "helm-exporter.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + name: {{ template "helm-exporter.serviceAccountName" . }} +{{- end }} diff --git a/stable/helm-exporter/values.yaml b/stable/helm-exporter/values.yaml new file mode 100644 index 000000000000..3ff600d6fd4d --- /dev/null +++ b/stable/helm-exporter/values.yaml @@ -0,0 +1,28 @@ +replicaCount: 1 + +image: + repository: sstarcher/helm-exporter + tag: 0.1.0 + pullPolicy: Always + +nameOverride: "" +fullnameOverride: "" + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +rbac: + # Specifies whether RBAC resources should be created + create: true + +serviceAccount: + # Specifies whether a ServiceAccount should be created + create: true + # The name of the ServiceAccount to use. + # If not set and create is true, a name is generated using the fullname template + name: