From 4e33fc6c26c873816561391ccd20300da073815e Mon Sep 17 00:00:00 2001 From: acondrat Date: Fri, 24 Nov 2017 12:20:17 +0200 Subject: [PATCH] Adding prometheus-to-sd chart (#2363) * Adding prometheus-to-sd chart * Updated description * #1785 namespace defined templates with chart name * updating Chart.yaml * aligned the parameters table * do not limit resources by default and allow the user adjust as needed * Making the linter happy * use {{ .Release.Name }} for resource naming * Revert "use {{ .Release.Name }} for resource naming" This reverts commit 518ad934b66ec2f39218615539d8fb41bb8e23d5. * fullname to match .Release.Name * updated apiVersion for deployment resource * github username * Adding nodeSelector default value and docs --- stable/prometheus-to-sd/.helmignore | 21 ++++++ stable/prometheus-to-sd/Chart.yaml | 12 ++++ stable/prometheus-to-sd/README.md | 67 +++++++++++++++++++ stable/prometheus-to-sd/templates/NOTES.txt | 2 + .../prometheus-to-sd/templates/_helpers.tpl | 15 +++++ .../templates/deployment.yaml | 36 ++++++++++ stable/prometheus-to-sd/values.yaml | 9 +++ 7 files changed, 162 insertions(+) create mode 100644 stable/prometheus-to-sd/.helmignore create mode 100644 stable/prometheus-to-sd/Chart.yaml create mode 100644 stable/prometheus-to-sd/README.md create mode 100644 stable/prometheus-to-sd/templates/NOTES.txt create mode 100644 stable/prometheus-to-sd/templates/_helpers.tpl create mode 100644 stable/prometheus-to-sd/templates/deployment.yaml create mode 100644 stable/prometheus-to-sd/values.yaml diff --git a/stable/prometheus-to-sd/.helmignore b/stable/prometheus-to-sd/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/stable/prometheus-to-sd/.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/prometheus-to-sd/Chart.yaml b/stable/prometheus-to-sd/Chart.yaml new file mode 100644 index 0000000000..a6b153fb80 --- /dev/null +++ b/stable/prometheus-to-sd/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +appVersion: 0.2.2 +description: Scrape metrics stored in prometheus format and push them to the Stackdriver +home: https://github.com/GoogleCloudPlatform/k8s-stackdriver/tree/master/prometheus-to-sd +keywords: +- prometheus +- stackdriver +maintainers: +- name: acondrat + email: arcadie.condrat@gmail.com +name: prometheus-to-sd +version: 0.1.0 diff --git a/stable/prometheus-to-sd/README.md b/stable/prometheus-to-sd/README.md new file mode 100644 index 0000000000..a66912fb2d --- /dev/null +++ b/stable/prometheus-to-sd/README.md @@ -0,0 +1,67 @@ +# prometheus-to-sd + +[prometheus-to-sd](https://github.com/GoogleCloudPlatform/k8s-stackdriver/tree/master/prometheus-to-sd) is a simple component that can scrape metrics stored in prometheus text format from one or multiple components and push them to the Stackdriver + +## TL;DR; + +```bash +$ helm install stable/prometheus-to-sd +``` + + +## Prerequisites + +- a service exposing metrics in prometheus format +- k8s cluster should run on GCE or GKE + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +$ helm install --name my-release stable/prometheus-to-sd +``` + +The command deploys prometheus-to-sd on the Kubernetes cluster in the default configuration. + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```bash +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following tables lists the configurable parameters and their default values. + +| Parameter | Description | Default | +| ------------------ | ----------------------------------------------------------------------------------------- | ------------------------------------------- | +| `image.repository` | prometheus-to-sd image repository | `gcr.io/google-containers/prometheus-to-sd` | +| `image.tag` | prometheus-to-sd image tag | `v0.2.2` | +| `image.pullPolicy` | Image pull policy | `IfNotPresent` | +| `resources` | CPU/Memory resource requests/limits | `{}` | +| `port` | Profiler port | `6060` | +| `metricSources` | Sources for metrics in the next format: component-name:http://host:port?whitelisted=a,b,c | `{}` | +| `nodeSelector` | node labels for pod assignment | `{}` | + +For more information please refer to the [prometheus-to-sd](https://github.com/GoogleCloudPlatform/k8s-stackdriver/tree/master/prometheus-to-sd) documentation. + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```bash +$ helm install --name my-release \ + --set "metricsSources.kube-state-metrics=http://kube-state-metrics:8080" \ + stable/prometheus-to-sd +``` + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```bash +$ helm install --name my-release -f values.yaml stable/prometheus-to-sd +``` + +Multiple metrics sources can be defined. diff --git a/stable/prometheus-to-sd/templates/NOTES.txt b/stable/prometheus-to-sd/templates/NOTES.txt new file mode 100644 index 0000000000..932cb80e17 --- /dev/null +++ b/stable/prometheus-to-sd/templates/NOTES.txt @@ -0,0 +1,2 @@ +Check prometheus-to-sd pod + $ kubectl get pods --namespace={{ .Release.Namespace }} diff --git a/stable/prometheus-to-sd/templates/_helpers.tpl b/stable/prometheus-to-sd/templates/_helpers.tpl new file mode 100644 index 0000000000..6ad4a0a6b4 --- /dev/null +++ b/stable/prometheus-to-sd/templates/_helpers.tpl @@ -0,0 +1,15 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "prometheus-to-sd.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). +*/}} +{{- define "prometheus-to-sd.fullname" -}} +{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/stable/prometheus-to-sd/templates/deployment.yaml b/stable/prometheus-to-sd/templates/deployment.yaml new file mode 100644 index 0000000000..8e1523339b --- /dev/null +++ b/stable/prometheus-to-sd/templates/deployment.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1beta1 +kind: Deployment +metadata: + name: {{ template "prometheus-to-sd.fullname" . }} + labels: + app: {{ template "prometheus-to-sd.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "prometheus-to-sd.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: profiler + containerPort: {{ .Values.port }} + command: + - /monitor + - --stackdriver-prefix=custom.googleapis.com + {{- range $key, $value := .Values.metricsSources }} + - --source={{ $key }}:{{ $value }} + {{- end }} + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/stable/prometheus-to-sd/values.yaml b/stable/prometheus-to-sd/values.yaml new file mode 100644 index 0000000000..5ba9bfe5a3 --- /dev/null +++ b/stable/prometheus-to-sd/values.yaml @@ -0,0 +1,9 @@ +replicaCount: 1 +image: + repository: gcr.io/google-containers/prometheus-to-sd + tag: v0.2.2 + pullPolicy: IfNotPresent +resources: {} +port: 6060 +metricsSources: {} +nodeSelector: {}