Skip to content

Commit

Permalink
Add slim stackdriver exporter chart.
Browse files Browse the repository at this point in the history
  • Loading branch information
Whyeasy committed Jun 19, 2020
1 parent 1013eb6 commit 1274e46
Show file tree
Hide file tree
Showing 9 changed files with 364 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This repository contains [Helm](https://helm.sh) charts for various projects
- [Prometheus MongoDb Exporter](https://github.com/whyeasy/helm-charts/tree/master/charts/prometheus-mongodb-exporter)
- [k8s Node Termination Handler](https://github.com/whyeasy/helm-charts/tree/master/charts/k8s-node-termination-handler)
- [Gitlab-extra-expoter](https://github.com/Whyeasy/helm-charts/tree/master/charts/gitlab-extra-exporter)
- [Stackdriver-exporter](https://github.com/Whyeasy/helm-charts/tree/master/charts/stackdriver-exporter)

## Installing Charts from this Repository

Expand Down
22 changes: 22 additions & 0 deletions charts/stackdriver-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
.vscode/
6 changes: 6 additions & 0 deletions charts/stackdriver-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: stackdriver-exporter
description: A slim Helm Chart to deploy a GCP Stackdriver exporter, with BYO SA and Secrets.
type: application
version: 0.1.0
appVersion: 0.9.1
42 changes: 42 additions & 0 deletions charts/stackdriver-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
stackdriver-exporter
====================
A slim Helm Chart to deploy a GCP Stackdriver exporter, with BYO SA and Secrets.

Current chart version is `0.1.0`





## Chart Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Adding any affinity for your deployment. |
| exporter.listenAddress | int | `9255` | What port should be used for the exporter to run on. |
| exporter.path | string | `"/metrics"` | What path should be used for the exporter to run on. |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | Pull Policy to use within Cluster. |
| image.repository | string | `"prometheuscommunity/stackdriver-exporter"` | Image repository to use. |
| image.tag | string | `"v0.9.1"` | Image tag to use. |
| imagePullSecrets | list | `[]` | Providing image pull secrets when needed. |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | Adding a Node selector for your deployment. |
| podSecurityContext | object | `{}` | |
| replicaCount | int | `1` | Amount of replicas to run. |
| resources | object | `{"limits":{"memory":"128Mi"},"requests":{"cpu":"100m","memory":"128Mi"}}` | define custom resources to use for your deployment. |
| securityContext | object | `{}` | |
| service.port | int | `80` | Define which port to for your service. |
| service.type | string | `"ClusterIP"` | Define service type to deploy. |
| serviceMonitor.additionalLabels | object | `{}` | Adding any additional labels to the service monitor. |
| serviceMonitor.enabled | bool | `false` | Deploy a Prometheus Service Monitor along with the exporter. |
| serviceMonitor.honorLabels | bool | `true` | if true, label conflicts are resolved by keeping label values from the scraped data |
| serviceMonitor.interval | string | `""` | Set scraping interval for the service monitor. |
| serviceMonitor.scrapeTimeout | string | `""` | Set scraping time out for the service monitor. |
| stackdriver.metrics.interval | string | `"5m"` | Interval in which stackdriver should be queried. |
| stackdriver.metrics.offset | string | `"0s"` | Set off set of data to retrieve, may be needed for some metrics. |
| stackdriver.metrics.typePrefixes | string | `"compute.googleapis.com/instance/cpu"` | Comma seperated list of metrics to query in stackdriver. |
| stackdriver.projectId | string | `""` | Define which google Project to query for stackdriver metrics. |
| stackdriver.serivceAccount.items | list | `[]` | |
| stackdriver.serivceAccount.secret | string | `"sd-account"` | |
| tolerations | list | `[]` | Adding any tolerations to your deployment. |
63 changes: 63 additions & 0 deletions charts/stackdriver-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "stackdriver-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 "stackdriver-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 "stackdriver-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "stackdriver-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "stackdriver-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
95 changes: 95 additions & 0 deletions charts/stackdriver-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "stackdriver-exporter.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "stackdriver-exporter.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "stackdriver-exporter.selectorLabels" . | nindent 6 }}
{{- with .Values.strategy }}
strategy: {{ toYaml . | nindent 4 }}
{{- end }}
template:
metadata:
labels:
{{- include "stackdriver-exporter.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.exporter.listenAddress }}
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 30
timeoutSeconds: 10
readinessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 10
timeoutSeconds: 10
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /etc/secrets/service-account/credentials.json
- name: STACKDRIVER_EXPORTER_GOOGLE_PROJECT_ID
value: {{ .Values.stackdriver.projectId | quote }}
- name: STACKDRIVER_EXPORTER_MONITORING_METRICS_TYPE_PREFIXES
value: {{ .Values.stackdriver.metrics.typePrefixes | quote }}
- name: STACKDRIVER_EXPORTER_MONITORING_METRICS_INTERVAL
value: {{ .Values.stackdriver.metrics.interval | quote }}
- name: STACKDRIVER_EXPORTER_MONITORING_METRICS_OFFSET
value: {{ .Values.stackdriver.metrics.offset | quote }}
- name: STACKDRIVER_EXPORTER_WEB_LISTEN_ADDRESS
value: {{ .Values.exporter.listenAddress | quote }}
- name: STACKDRIVER_EXPORTER_WEB_TELEMETRY_PATH
value: {{ .Values.exporter.path | quote }}
{{- with .Values.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: service-account
{{- if .Values.stackdriver.serivceAccount.items }}
mountPath: /etc/secrets/service-account
{{- else }}
mountPath: /etc/secrets/service-account/credentials.json
subPath: credentials.json
{{- end }}
volumes:
- name: service-account
secret:
secretName: {{ .Values.stackdriver.serivceAccount.secret }}
{{- if .Values.stackdriver.serivceAccount.items }}
items: {{- toYaml .Values.stackdriver.serivceAccount.items | nindent 14 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/stackdriver-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "stackdriver-exporter.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "stackdriver-exporter.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "stackdriver-exporter.selectorLabels" . | nindent 4 }}
27 changes: 27 additions & 0 deletions charts/stackdriver-exporter/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "stackdriver-exporter.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "stackdriver-exporter.labels" . | nindent 4 }}
{{- if .Values.serviceMonitor.additionalLabels }}
{{ toYaml .Values.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
spec:
endpoints:
- port: http
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.honorLabels }}
honorLabels: {{ .Values.serviceMonitor.honorLabels }}
{{- end }}
{{- if .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
{{- end }}
selector:
matchLabels:
{{- include "stackdriver-exporter.selectorLabels" . | nindent 6 }}
{{- end }}
92 changes: 92 additions & 0 deletions charts/stackdriver-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Default values for stackdriver-exporter.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

# replicaCount -- Amount of replicas to run.
replicaCount: 1

image:
# image.repository -- Image repository to use.
repository: prometheuscommunity/stackdriver-exporter
# image.tag -- Image tag to use.
tag: v0.9.1
# image.pullPolicy -- Pull Policy to use within Cluster.
pullPolicy: IfNotPresent

# imagePullSecrets -- Providing image pull secrets when needed.
imagePullSecrets: []

nameOverride: ""
fullnameOverride: ""

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

# resources -- define custom resources to use for your deployment.
resources:
limits:
# cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

# nodeSelector -- Adding a Node selector for your deployment.
nodeSelector: {}

# tolerations -- Adding any tolerations to your deployment.
tolerations: []

# affinity -- Adding any affinity for your deployment.
affinity: {}

service:
# service.type -- Define service type to deploy.
type: ClusterIP
# service.port -- Define which port to for your service.
port: 80

stackdriver:
# stackdriver.projectId -- Define which google Project to query for stackdriver metrics.
projectId: ""
serivceAccount:
# stackdriver.serviceAccount.secret -- Define the secret name which stores the SA credentials.
secret: "sd-account"
# stackdriver.serviceAccount.items -- Needed when custom data keys are used. Path should be credentials.json!
items: []
# - key: SD_CONFIG
# path: credentials.json
metrics:
# stackdriver.metrics.typePrefixes -- Comma seperated list of metrics to query in stackdriver.
typePrefixes: compute.googleapis.com/instance/cpu
# stackdriver.metrics.interval -- Interval in which stackdriver should be queried.
interval: 5m
# stackdriver.metrics.offset -- Set off set of data to retrieve, may be needed for some metrics.
offset: 0s

exporter:
# exporter.listenAddress -- What port should be used for the exporter to run on.
listenAddress: 9255
# exporter.path -- What path should be used for the exporter to run on.
path: /metrics


serviceMonitor:
# serviceMonitor.enabled -- Deploy a Prometheus Service Monitor along with the exporter.
enabled: false
# serviceMonitor.additionalLabels -- Adding any additional labels to the service monitor.
additionalLabels: {}
# serviceMonitor.honorLabels -- if true, label conflicts are resolved by keeping label values from the scraped data
honorLabels: true
# serviceMonitor.interval -- Set scraping interval for the service monitor.
interval: ""
# serviceMonitor.scrapeTimeout -- Set scraping time out for the service monitor.
scrapeTimeout: ""

0 comments on commit 1274e46

Please sign in to comment.