From 26772b8d44610649c45f263a89e2129cffef36c4 Mon Sep 17 00:00:00 2001 From: Whyeasy Date: Mon, 22 Jun 2020 13:51:40 +0200 Subject: [PATCH] Add Sonarcloud exporter chart Tune gitlab exporter --- README.md | 5 +- charts/gitlab-extra-exporter/Chart.yaml | 2 +- charts/gitlab-extra-exporter/README.md | 10 +-- .../templates/deployment.yaml | 2 +- .../templates/service.yaml | 1 + .../templates/servicemonitor.yaml | 5 ++ charts/gitlab-extra-exporter/values.yaml | 8 +- charts/sonarcloud-exporter/.helmignore | 22 ++++++ charts/sonarcloud-exporter/Chart.yaml | 6 ++ charts/sonarcloud-exporter/README.md | 36 +++++++++ .../templates/_helpers.tpl | 63 +++++++++++++++ .../templates/deployment.yaml | 74 +++++++++++++++++ .../templates/service.yaml | 16 ++++ .../templates/servicemonitor.yaml | 21 +++++ charts/sonarcloud-exporter/values.yaml | 79 +++++++++++++++++++ 15 files changed, 338 insertions(+), 12 deletions(-) create mode 100644 charts/sonarcloud-exporter/.helmignore create mode 100644 charts/sonarcloud-exporter/Chart.yaml create mode 100644 charts/sonarcloud-exporter/README.md create mode 100644 charts/sonarcloud-exporter/templates/_helpers.tpl create mode 100644 charts/sonarcloud-exporter/templates/deployment.yaml create mode 100644 charts/sonarcloud-exporter/templates/service.yaml create mode 100644 charts/sonarcloud-exporter/templates/servicemonitor.yaml create mode 100644 charts/sonarcloud-exporter/values.yaml diff --git a/README.md b/README.md index 538d52a..d91a096 100644 --- a/README.md +++ b/README.md @@ -7,17 +7,18 @@ This repository contains [Helm](https://helm.sh) charts for various projects - [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) +- [Sonarcloud-exporter](https://github.com/Whyeasy/helm-charts/tree/master/charts/sonarcloud -exporter) ## Installing Charts from this Repository Add the Repository to Helm: ```sh -$ helm repo add whyeasy-helm-charts https://whyeasy.github.io/helm-charts +helm repo add whyeasy-helm-charts https://whyeasy.github.io/helm-charts ``` Install a chart: ```sh -$ helm install whyeasy-helm-charts/[CHART_NAME] +helm install whyeasy-helm-charts/[CHART_NAME] ``` diff --git a/charts/gitlab-extra-exporter/Chart.yaml b/charts/gitlab-extra-exporter/Chart.yaml index 266e7ba..7493128 100644 --- a/charts/gitlab-extra-exporter/Chart.yaml +++ b/charts/gitlab-extra-exporter/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: gitlab-extra-exporter description: A Helm chart to deploy [gitlab-extra-exporter](https://github.com/Whyeasy/gitlab-extra-exporter) type: application -version: 0.1.6 +version: 0.1.7 appVersion: 0.0.6 diff --git a/charts/gitlab-extra-exporter/README.md b/charts/gitlab-extra-exporter/README.md index bce502d..bed5616 100644 --- a/charts/gitlab-extra-exporter/README.md +++ b/charts/gitlab-extra-exporter/README.md @@ -25,11 +25,11 @@ Current chart version is `0.1.6` | podSecurityContext | object | `{}` | | | resources | object | `{}` | custom resource configuration | | securityContext | object | `{}` | | -| service.port | int | `8080` | | -| service.type | string | `"ClusterIP"` | | -| serviceMonitor.enabled | bool | `true` | | -| serviceMonitor.interval | string | `"5m"` | | -| serviceMonitor.scrapeTimeout | string | `"30s"` | | +| service.port | int | `8080` | Service port for the exporter | +| service.type | string | `"ClusterIP"` | Serive type for the exporter | +| serviceMonitor.enabled | bool | `true` | Deploy a service monitor along with the exporter. | +| serviceMonitor.interval | string | `"5m"` | Set scraping interval for the service monitor. | +| serviceMonitor.scrapeTimeout | string | `"30s"` | Set scraping time out for the service monitor. | | strategy.type | string | `"RollingUpdate"` | Strategy for deploying containers | | tolerations | list | `[]` | tolerations for scheduler pod assignment | | volumeMounts | list | `[]` | additional volume mounts | diff --git a/charts/gitlab-extra-exporter/templates/deployment.yaml b/charts/gitlab-extra-exporter/templates/deployment.yaml index ec308ba..6d323a7 100644 --- a/charts/gitlab-extra-exporter/templates/deployment.yaml +++ b/charts/gitlab-extra-exporter/templates/deployment.yaml @@ -47,7 +47,7 @@ spec: {{- with .Values.env }} env: {{- toYaml . | nindent 12 }} - {{- end }} + {{- end }} {{- with .Values.envFrom }} envFrom: {{- toYaml . | nindent 12 }} diff --git a/charts/gitlab-extra-exporter/templates/service.yaml b/charts/gitlab-extra-exporter/templates/service.yaml index b45905a..7074202 100644 --- a/charts/gitlab-extra-exporter/templates/service.yaml +++ b/charts/gitlab-extra-exporter/templates/service.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: {{ include "gitlab-extra-exporter.fullname" . }} + namespace: {{ .Release.Namespace }} labels: {{- include "gitlab-extra-exporter.labels" . | nindent 4 }} spec: diff --git a/charts/gitlab-extra-exporter/templates/servicemonitor.yaml b/charts/gitlab-extra-exporter/templates/servicemonitor.yaml index e619498..33b3037 100644 --- a/charts/gitlab-extra-exporter/templates/servicemonitor.yaml +++ b/charts/gitlab-extra-exporter/templates/servicemonitor.yaml @@ -5,11 +5,16 @@ metadata: name: {{ include "gitlab-extra-exporter.fullname" . }} labels: {{- include "gitlab-extra-exporter.labels" . | nindent 4 }} + namespace: {{ .Release.Namespace }} spec: endpoints: - port: metrics + {{- if .Values.serviceMonitor.interval }} interval: {{ .Values.serviceMonitor.interval }} + {{- end }} + {{- if .Values.serviceMonitor.scrapeTimeout }} scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} + {{- end }} selector: matchLabels: {{- include "gitlab-extra-exporter.selectorLabels" . | nindent 6 }} diff --git a/charts/gitlab-extra-exporter/values.yaml b/charts/gitlab-extra-exporter/values.yaml index 3b125f0..912e847 100644 --- a/charts/gitlab-extra-exporter/values.yaml +++ b/charts/gitlab-extra-exporter/values.yaml @@ -65,13 +65,15 @@ strategy: type: RollingUpdate service: - # service.type - Serive type for the exporter + # service.type -- Serive type for the exporter type: ClusterIP - # service.port - Service port for the exporter + # service.port -- Service port for the exporter port: 8080 serviceMonitor: - # serviceMonitor.enabled - Deploy a service monitor along with the exporter. + # serviceMonitor.enabled -- Deploy a service monitor along with the exporter. enabled: true + # serviceMonitor.interval -- Set scraping interval for the service monitor. interval: 5m + # serviceMonitor.scrapeTimeout -- Set scraping time out for the service monitor. scrapeTimeout: 30s \ No newline at end of file diff --git a/charts/sonarcloud-exporter/.helmignore b/charts/sonarcloud-exporter/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/charts/sonarcloud-exporter/.helmignore @@ -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/ diff --git a/charts/sonarcloud-exporter/Chart.yaml b/charts/sonarcloud-exporter/Chart.yaml new file mode 100644 index 0000000..99e21b0 --- /dev/null +++ b/charts/sonarcloud-exporter/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: sonarcloud-exporter +description: A Helm chart to deploy [sonarcloud-exporter](https://github.com/Whyeasy/sonarcloud-exporter) +type: application +version: 0.1.0 +appVersion: 0.0.1 diff --git a/charts/sonarcloud-exporter/README.md b/charts/sonarcloud-exporter/README.md new file mode 100644 index 0000000..8cf8ab6 --- /dev/null +++ b/charts/sonarcloud-exporter/README.md @@ -0,0 +1,36 @@ +sonarcloud-exporter +=================== +A Helm chart to deploy [sonarcloud-exporter](https://github.com/Whyeasy/sonarcloud-exporter) + +Current chart version is `0.1.0` + + + + + +## Chart Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | affinity for scheduler pod assignment | +| env | list | `[]` | environment variables for the container | +| envFrom | list | `[]` | environment variable sources for the container | +| fullnameOverride | string | `""` | full name of the chart. | +| image.pullPolicy | string | `"IfNotPresent"` | image pull policy | +| image.repository | string | `"whyeasy/sonarcloud-exporter"` | image repository | +| image.tag | string | `"v0.0.1"` | image tag | +| imagePullSecrets | list | `[]` | image pull secret for private images | +| nameOverride | string | `""` | override name of the chart | +| nodeSelector | object | `{}` | node for scheduler pod assignment | +| podSecurityContext | object | `{}` | | +| resources | object | `{}` | custom resource configuration | +| securityContext | object | `{}` | | +| service.port | int | `8080` | Service port for the exporter | +| service.type | string | `"ClusterIP"` | Serive type for the exporter | +| serviceMonitor.enabled | bool | `false` | Deploy a service monitor along with the exporter. | +| serviceMonitor.interval | string | `""` | Set scraping interval for the service monitor. | +| serviceMonitor.scrapeTimeout | string | `""` | Set scraping time out for the service monitor. | +| strategy.type | string | `"RollingUpdate"` | Strategy for deploying containers | +| tolerations | list | `[]` | tolerations for scheduler pod assignment | +| volumeMounts | list | `[]` | additional volume mounts | +| volumes | list | `[]` | volumes | diff --git a/charts/sonarcloud-exporter/templates/_helpers.tpl b/charts/sonarcloud-exporter/templates/_helpers.tpl new file mode 100644 index 0000000..6e94ceb --- /dev/null +++ b/charts/sonarcloud-exporter/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "sonarcloud-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 "sonarcloud-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 "sonarcloud-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "sonarcloud-exporter.labels" -}} +helm.sh/chart: {{ include "sonarcloud-exporter.chart" . }} +{{ include "sonarcloud-exporter.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "sonarcloud-exporter.selectorLabels" -}} +app.kubernetes.io/name: {{ include "sonarcloud-exporter.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "sonarcloud-exporter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "sonarcloud-exporter.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/sonarcloud-exporter/templates/deployment.yaml b/charts/sonarcloud-exporter/templates/deployment.yaml new file mode 100644 index 0000000..1cc23f8 --- /dev/null +++ b/charts/sonarcloud-exporter/templates/deployment.yaml @@ -0,0 +1,74 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "sonarcloud-exporter.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "sonarcloud-exporter.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "sonarcloud-exporter.selectorLabels" . | nindent 6 }} + {{- with .Values.strategy }} + strategy: {{ toYaml . | nindent 4 }} + {{- end }} + template: + metadata: + labels: + {{- include "sonarcloud-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: metrics + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: metrics + readinessProbe: + httpGet: + path: / + port: metrics + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.env }} + env: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.envFrom }} + envFrom: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- 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 }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/sonarcloud-exporter/templates/service.yaml b/charts/sonarcloud-exporter/templates/service.yaml new file mode 100644 index 0000000..50e2a00 --- /dev/null +++ b/charts/sonarcloud-exporter/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "sonarcloud-exporter.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "sonarcloud-exporter.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: metrics + protocol: TCP + name: metrics + selector: + {{- include "sonarcloud-exporter.selectorLabels" . | nindent 4 }} diff --git a/charts/sonarcloud-exporter/templates/servicemonitor.yaml b/charts/sonarcloud-exporter/templates/servicemonitor.yaml new file mode 100644 index 0000000..8aac4bc --- /dev/null +++ b/charts/sonarcloud-exporter/templates/servicemonitor.yaml @@ -0,0 +1,21 @@ +{{ if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "sonarcloud-exporter.fullname" . }} + labels: + {{- include "sonarcloud-exporter.labels" . | nindent 4 }} + namespace: {{ .Release.Namespace }} +spec: + endpoints: + - port: metrics + {{- if .Values.serviceMonitor.interval }} + interval: {{ .Values.serviceMonitor.interval }} + {{- end }} + {{- if .Values.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} + {{- end }} + selector: + matchLabels: + {{- include "sonarcloud-exporter.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/sonarcloud-exporter/values.yaml b/charts/sonarcloud-exporter/values.yaml new file mode 100644 index 0000000..27de9d4 --- /dev/null +++ b/charts/sonarcloud-exporter/values.yaml @@ -0,0 +1,79 @@ +image: + # image.repository -- image repository + repository: whyeasy/sonarcloud-exporter + # image.tag -- image tag + tag: v0.0.1 + # image.pullPolicy -- image pull policy + pullPolicy: IfNotPresent + +# imagePullSecrets -- image pull secret for private images +imagePullSecrets: [] +# nameOverride -- override name of the chart +nameOverride: "" +# fullnameOverride -- full name of the chart. +fullnameOverride: "" + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# resources -- custom resource configuration +resources: {} +# limits: +# cpu: 100m +# memory: 128Mi +# requests: +# cpu: 100m +# memory: 128Mi + +# nodeSelector -- node for scheduler pod assignment +nodeSelector: {} + +# tolerations -- tolerations for scheduler pod assignment +tolerations: [] + +# affinity -- affinity for scheduler pod assignment +affinity: {} + +# volumeMounts -- additional volume mounts +volumeMounts: [] +# - name: some +# mountPath: /volume + +# volumes -- volumes +volumes: [] +# - name: tmp +# emptyDir: {} + +# env -- environment variables for the container +env: [] + +# envFrom -- environment variable sources for the container +envFrom: [] +# - configMapRef: +# name: sonarcloud-exporter-cm + +strategy: + # strategy.type -- Strategy for deploying containers + type: RollingUpdate + +service: + # service.type -- Serive type for the exporter + type: ClusterIP + # service.port -- Service port for the exporter + port: 8080 + +serviceMonitor: + # serviceMonitor.enabled -- Deploy a service monitor along with the exporter. + enabled: false + # serviceMonitor.interval -- Set scraping interval for the service monitor. + interval: "" + # serviceMonitor.scrapeTimeout -- Set scraping time out for the service monitor. + scrapeTimeout: "" \ No newline at end of file