Skip to content

Commit

Permalink
feat(exporter): Add ndm exporters support from helm chart (#612)
Browse files Browse the repository at this point in the history
* added ndm exporters in helm charts
* updated helm chart README
* removed unrequired fields from README and automgenerate ndm-operator yaml
* bumped up chart vesion, chart appVersion and images version

Signed-off-by: Abhishek Agarwal <abhishek.agarwal@mayadata.io>
  • Loading branch information
Abhishek Agarwal authored Aug 13, 2021
1 parent 37af3c2 commit 4278a9f
Show file tree
Hide file tree
Showing 11 changed files with 369 additions and 8 deletions.
4 changes: 2 additions & 2 deletions deploy/helm/charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v2
name: openebs-ndm
description: Helm chart for OpenEBS Node Disk Manager - a Kubernetes native storage device management solution. For instructions on how to install, refer to https://openebs.github.io/node-disk-manager/.
version: 1.6.0
appVersion: 1.6.0
version: 1.6.1
appVersion: 1.6.1
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/openebs/icon/color/openebs-icon-color.png
home: http://www.openebs.io/
keywords:
Expand Down
7 changes: 7 additions & 0 deletions deploy/helm/charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ The following table lists the configurable parameters of the OpenEBS NDM chart a
| `ndmOperator.nodeSelector` | Nodeselector for operator pods | `""` |
| `ndmOperator.tolerations` | NDM operator's pod toleration values | `""` |
| `ndmOperator.securityContext` | Seurity context for container | `""` |
| `ndmExporter.enabled` | Enable NDM Exporters | `false` |
| `ndmExporter.image.registry` | Registry for NDM Exporters image | `""` |
| `ndmExporter.repository` | Image repository for NDM Exporters | `openebs/node-disk-exporter` |
| `ndmExporter.pullPolicy` | Image pull policy for NDM Exporters | `IfNotPresent` |
| `ndmExporter.tag` | Image tag for NDM Exporters | `1.6.0` |
| `ndmExporter.nodeExporter.metricsPort` | The TCP port number used for exposing NDM node exporter metrics | `9101` |
| `ndmExporter.clusterExporter.metricsPort` | The TCP port number used for exposing NDM cluster exporter metrics | `9100` |
| `featureGates.APIService.enabled` | Enable the gRPC API service of NDM | `false` |
| `featureGates.UseOSDisk.enabled` | Enable feature-gate to use free space on OS disk | `false` |
| `featureGates.MountChangeDetection.enabled` | Enable feature-gate to detect mountpoint/filesystem changes | `false` |
Expand Down
112 changes: 112 additions & 0 deletions deploy/helm/charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,64 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{- define "openebs-ndm.cluster-exporter.name" -}}
{{- $ndmName := default .Chart.Name .Values.ndmExporter.clusterExporter.nameOverride | trunc 63 | trimSuffix "-" }}
{{- $componentName := .Values.ndmExporter.clusterExporter.name | trunc 63 | trimSuffix "-" }}
{{- printf "%s-%s" $ndmName $componentName | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified ndm cluster exporter 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 "openebs-ndm.cluster-exporter.fullname" -}}
{{- if .Values.ndmExporter.clusterExporter.fullnameOverride }}
{{- .Values.ndmExporter.clusterExporter.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $ndmClusterExporterName := include "openebs-ndm.cluster-exporter.name" .}}

{{- $name := default $ndmClusterExporterName .Values.ndmExporter.clusterExporter.nameOverride }}
{{- if contains .Release.Name $name }}
{{- $name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{- define "openebs-ndm.exporter.name" -}}
{{- $ndmName := default .Chart.Name .Values.ndmExporter.nameOverride | trunc 63 | trimSuffix "-" }}
{{- $componentName := "exporter" | trunc 63 | trimSuffix "-" }}
{{- printf "%s-%s" $ndmName $componentName | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "openebs-ndm.node-exporter.name" -}}
{{- $ndmName := default .Chart.Name .Values.ndmExporter.nodeExporter.nameOverride | trunc 63 | trimSuffix "-" }}
{{- $componentName := .Values.ndmExporter.nodeExporter.name | trunc 63 | trimSuffix "-" }}
{{- printf "%s-%s" $ndmName $componentName | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified ndm node exporter 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 "openebs-ndm.node-exporter.fullname" -}}
{{- if .Values.ndmExporter.nodeExporter.fullnameOverride }}
{{- .Values.ndmExporter.nodeExporter.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $ndmNodeExporterName := include "openebs-ndm.node-exporter.name" .}}

{{- $name := default $ndmNodeExporterName .Values.ndmExporter.nodeExporter.nameOverride }}
{{- if contains .Release.Name $name }}
{{- $name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
Expand Down Expand Up @@ -130,3 +188,57 @@ Create labels for ndm operator component
{{ include "openebs-ndm.operator.matchLabels" . }}
{{ include "openebs-ndm.operator.componentLabels" . }}
{{- end -}}

{{/*
Create match labels for ndm cluster exporter deployment
*/}}
{{- define "openebs-ndm.cluster-exporter.matchLabels" -}}
app: {{ template "openebs-ndm.cluster-exporter.name" . }}
release: {{ .Release.Name }}
component: {{ default (include "openebs-ndm.cluster-exporter.name" .) .Values.ndmExporter.clusterExporter.componentName }}
{{- end -}}

{{/*
Create component labels for ndm cluster exporter component
*/}}
{{- define "openebs-ndm.cluster-exporter.componentLabels" -}}
name: {{ template "openebs-ndm.exporter.name" . }}
openebs.io/component-name: {{ default (include "openebs-ndm.cluster-exporter.name" .) .Values.ndmExporter.clusterExporter.componentName }}
{{- end -}}


{{/*
Create labels for ndm cluster exporter component
*/}}
{{- define "openebs-ndm.cluster-exporter.labels" -}}
{{ include "openebs-ndm.common.metaLabels" . }}
{{ include "openebs-ndm.cluster-exporter.matchLabels" . }}
{{ include "openebs-ndm.cluster-exporter.componentLabels" . }}
{{- end -}}

{{/*
Create match labels for ndm node exporter deployment
*/}}
{{- define "openebs-ndm.node-exporter.matchLabels" -}}
app: {{ template "openebs-ndm.node-exporter.name" . }}
release: {{ .Release.Name }}
component: {{ default (include "openebs-ndm.node-exporter.name" .) .Values.ndmExporter.nodeExporter.componentName }}
{{- end -}}

{{/*
Create component labels for ndm node exporter component
*/}}
{{- define "openebs-ndm.node-exporter.componentLabels" -}}
name: {{ template "openebs-ndm.exporter.name" . }}
openebs.io/component-name: {{ default (include "openebs-ndm.node-exporter.name" .) .Values.ndmExporter.nodeExporter.componentName }}
{{- end -}}


{{/*
Create labels for ndm cluster node component
*/}}
{{- define "openebs-ndm.node-exporter.labels" -}}
{{ include "openebs-ndm.common.metaLabels" . }}
{{ include "openebs-ndm.node-exporter.matchLabels" . }}
{{ include "openebs-ndm.node-exporter.componentLabels" . }}
{{- end -}}
18 changes: 18 additions & 0 deletions deploy/helm/charts/templates/cluster-exporter-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if and .Values.ndmExporter.enabled .Values.ndmExporter.clusterExporter.metricsPort }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "openebs-ndm.cluster-exporter.fullname" . }}-service
labels:
{{- include "openebs-ndm.cluster-exporter.labels" . | nindent 4 }}
spec:
clusterIP: None
ports:
- name: metrics
port: {{ .Values.ndmExporter.clusterExporter.metricsPort }}
targetPort: {{ .Values.ndmExporter.clusterExporter.metricsPort }}
selector:
{{- with .Values.ndmExporter.clusterExporter.podLabels }}
{{ toYaml . }}
{{- end }}
{{- end }}
48 changes: 48 additions & 0 deletions deploy/helm/charts/templates/cluster-exporter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- if .Values.ndmExporter.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "openebs-ndm.cluster-exporter.fullname" . }}
labels:
{{- include "openebs-ndm.cluster-exporter.labels" . | nindent 4 }}
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
{{- include "openebs-ndm.cluster-exporter.matchLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "openebs-ndm.cluster-exporter.labels" . | nindent 8 }}
{{- with .Values.ndmExporter.clusterExporter.podLabels }}
{{ toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "openebs-ndm.serviceAccountName" . }}
containers:
- name: {{ template "openebs-ndm.cluster-exporter.fullname" . }}
image: "{{ .Values.ndmExporter.image.registry }}{{ .Values.ndmExporter.image.repository }}:{{ .Values.ndmExporter.image.tag }}"
command:
- /usr/local/bin/exporter
args:
- "start"
- "--mode=cluster"
- "--port=$(METRICS_LISTEN_PORT)"
- "--metrics=/metrics"
ports:
- containerPort: {{ .Values.ndmExporter.clusterExporter.metricsPort }}
protocol: TCP
name: metrics
imagePullPolicy: {{ .Values.ndmExporter.image.pullPolicy }}
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{{- if .Values.ndmExporter.clusterExporter.metricsPort }}
- name: METRICS_LISTEN_PORT
value: :{{ .Values.ndmExporter.clusterExporter.metricsPort }}
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions deploy/helm/charts/templates/node-exporter-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if and .Values.ndmExporter.enabled .Values.ndmExporter.nodeExporter.metricsPort }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "openebs-ndm.node-exporter.fullname" . }}-service
labels:
{{- include "openebs-ndm.node-exporter.labels" . | nindent 4 }}
spec:
clusterIP: None
ports:
- name: metrics
port: {{ .Values.ndmExporter.nodeExporter.metricsPort }}
targetPort: {{ .Values.ndmExporter.nodeExporter.metricsPort }}
selector:
{{- with .Values.ndmExporter.nodeExporter.podLabels }}
{{ toYaml . }}
{{- end }}
{{- end }}
49 changes: 49 additions & 0 deletions deploy/helm/charts/templates/node-exporter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{- if .Values.ndmExporter.enabled }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ template "openebs-ndm.node-exporter.fullname" . }}
labels:
{{- include "openebs-ndm.node-exporter.labels" . | nindent 4 }}
spec:
updateStrategy:
type: RollingUpdate
selector:
matchLabels:
{{- include "openebs-ndm.node-exporter.matchLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "openebs-ndm.node-exporter.labels" . | nindent 8 }}
{{- with .Values.ndmExporter.nodeExporter.podLabels }}
{{ toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "openebs-ndm.serviceAccountName" . }}
containers:
- name: {{ template "openebs-ndm.node-exporter.fullname" . }}
image: "{{ .Values.ndmExporter.image.registry }}{{ .Values.ndmExporter.image.repository }}:{{ .Values.ndmExporter.image.tag }}"
command:
- /usr/local/bin/exporter
args:
- "start"
- "--mode=node"
- "--port=$(METRICS_LISTEN_PORT)"
- "--metrics=/metrics"
ports:
- containerPort: {{ .Values.ndmExporter.nodeExporter.metricsPort }}
protocol: TCP
name: metrics
imagePullPolicy: {{ .Values.ndmExporter.image.pullPolicy }}
securityContext:
privileged: true
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{{- if .Values.ndmExporter.nodeExporter.metricsPort }}
- name: METRICS_LISTEN_PORT
value: :{{ .Values.ndmExporter.nodeExporter.metricsPort }}
{{- end }}
{{- end }}
29 changes: 27 additions & 2 deletions deploy/helm/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ndm:
repository: openebs/node-disk-manager
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 1.6.0
tag: 1.6.1
sparse:
path: "/var/openebs/sparse"
size: "10737418240"
Expand Down Expand Up @@ -63,7 +63,7 @@ ndmOperator:
repository: openebs/node-disk-operator
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 1.6.0
tag: 1.6.1
podLabels:
name: openebs-ndm-operator
annotations: {}
Expand All @@ -81,6 +81,31 @@ ndmOperator:
replicas: 1
upgradeStrategy: Recreate

ndmExporter:
enabled: false
image:
registry:
repository: openebs/node-disk-exporter
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 1.6.1
nodeExporter:
name: node-exporter
podLabels:
name: openebs-ndm-node-exporter
# The TCP port number used for exposing ndm-node-exporter metrics.
# If not set, service will not be created to expose metrics endpoint to serviceMonitor
# and listen-port flag will not be set and container port will be empty.
metricsPort: 9101
clusterExporter:
name: cluster-exporter
podLabels:
name: openebs-ndm-cluster-exporter
# The TCP port number used for exposing ndm-cluster-exporter metrics.
# If not set, service will not be created to expose metrics endpoint to serviceMonitor
# and listen-port flag will not be set and container port will be empty.
metricsPort: 9100

helperPod:
image:
registry: ""
Expand Down
Loading

0 comments on commit 4278a9f

Please sign in to comment.