Skip to content

Commit

Permalink
chore(charts): add ndm helm3 charts (#488)
Browse files Browse the repository at this point in the history
**NOTE:** This PR should be merged only after #491 and #490 
This PR adds helm3 charts for NDM installation.

NDM  component will have its own service account and RBAC. So following Kubernetes resource are 
created for NDM that is not shared with other OpenEBS components:
1. ClusterRole: ( Default name is `openebs-ndm`)
2. ClusterRoleBinding: ( Default name is `openebs-ndm`)
3. ServiceAccount : ( Default name is `openebs-ndm`)

NDM Daemonset default name : `openebs-ndm`
NDM deployment default name: `openebs-ndm-operator`
NDM configmap default name:  `openebs-ndm-config`

#### Special notes for your reviewer:


- There has been a change in match label selectors for the NDM pods. See the following for the comparison 

**Older Helm Chart Based NDM Daemon Set:** 

```
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: {{ template "openebs.fullname" . }}-ndm
  labels:
    app: {{ template "openebs.name" . }}
    chart: {{ template "openebs.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
    component: ndm
    openebs.io/component-name: ndm
    openebs.io/version: {{ .Values.release.version }}
spec:
  updateStrategy:
    type: "RollingUpdate"
  selector:
    matchLabels:
      app: {{ template "openebs.name" . }}
      release: {{ .Release.Name }}
      component: ndm
  template:
    metadata:
      labels:
        app: {{ template "openebs.name" . }}
        release: {{ .Release.Name }}
        component: ndm
        openebs.io/component-name: ndm
        name: openebs-ndm
        openebs.io/version: {{ .Values.release.version }}
```

**Current Helm Chart Based NDM Daemon Set:** 

```
apiVersion: apps/v1
kind: DaemonSet
metadata:
  annotations:
    deprecated.daemonset.template.generation: "1"
    meta.helm.sh/release-name: pascal
    meta.helm.sh/release-namespace: openebs
  creationTimestamp: "2020-08-26T15:28:33Z"
  generation: 1
  labels:
    app: openebs-ndm
    app.kubernetes.io/managed-by: Helm
    chart: openebs-ndm-0.8.0
    component: ndm
    heritage: Helm
    openebs.io/component-name: ndm
    openebs.io/version: 0.8.0
    release: pascal
spec:
  selector:
    matchLabels:
      app: openebs-ndm
      component: ndm
      release: pascal
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: openebs-ndm
        chart: openebs-ndm-0.8.0
        component: ndm
        heritage: Helm
        name: openebs-ndm
        openebs.io/component-name: ndm
        openebs.io/version: 0.8.0
        release: pascal
```

**Older Helm Chart Based NDM Operator:** 

```
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "openebs.fullname" . }}-ndm-operator
  labels:
    app: {{ template "openebs.name" . }}
    chart: {{ template "openebs.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
    component: ndm-operator
    openebs.io/component-name: ndm-operator
    openebs.io/version: {{ .Values.release.version }}
    name: ndm-operator
spec:
  replicas: {{ .Values.ndmOperator.replicas }}
  strategy:
    type: "Recreate"
    rollingUpdate: null
  selector:
    matchLabels:
      app: {{ template "openebs.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "openebs.name" . }}
        release: {{ .Release.Name }}
        component: ndm-operator
        name: ndm-operator
        openebs.io/component-name: ndm-operator
        openebs.io/version: {{ .Values.release.version }}
```

**Current Helm Chart Based NDM operator:**

```
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
    meta.helm.sh/release-name: pascal
    meta.helm.sh/release-namespace: openebs
  creationTimestamp: "2020-08-26T15:28:33Z"
  generation: 1
  labels:
    app: openebs-ndm-operator
    app.kubernetes.io/managed-by: Helm
    chart: openebs-ndm-0.8.0
    component: openebs-ndm-operator
    heritage: Helm
    openebs.io/component-name: openebs-ndm-operator
    openebs.io/version: 0.8.0
    release: pascal
spec:
  replicas: 1
  selector:
    matchLabels:
      app: openebs-ndm-operator
      component: openebs-ndm-operator
      release: pascal
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: openebs-ndm-operator
        chart: openebs-ndm-0.8.0
        component: openebs-ndm-operator
        heritage: Helm
        openebs.io/component-name: openebs-ndm-operator
        openebs.io/version: 0.8.0
        release: pascal

``` 

**Notable Changes As Part of Best Practice:**
- The labels of ndm daemonset and ndm operator yaml comes from `helper.tpl`. This is more maintainable and less error prone.
- Clean up container image values is segregated in Values.yaml file.

Signed-off-by: Ashutosh Kumar <[email protected]>
  • Loading branch information
Ashutosh Kumar authored Nov 11, 2020
1 parent 459587c commit 4119e95
Show file tree
Hide file tree
Showing 9 changed files with 676 additions and 0 deletions.
22 changes: 22 additions & 0 deletions deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v2
name: openebs-ndm
description: Kubernetes Storage Device Management. Also used to maintain the inventory of block devices.
version: 0.9.1
appVersion: 0.9.1
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/openebs/icon/color/openebs-icon-color.png
home: http://www.openebs.io/
keywords:
- cloud-native-storage
- block-storage
- ndm
- disk-inventory
- storage
sources:
- https://github.com/openebs/node-disk-manager
maintainers:
- name: akhilerm
email: [email protected]
- name: xUnholy
email: [email protected]
- name: prateekpandey14
email: [email protected]
39 changes: 39 additions & 0 deletions deploy/helm/crds/blockdevice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: blockdevices.openebs.io
spec:
additionalPrinterColumns:
- JSONPath: .spec.nodeAttributes.nodeName
name: NodeName
type: string
- JSONPath: .spec.path
name: Path
priority: 1
type: string
- JSONPath: .spec.filesystem.fsType
name: FSType
priority: 1
type: string
- JSONPath: .spec.capacity.storage
name: Size
type: string
- JSONPath: .status.claimState
name: ClaimState
type: string
- JSONPath: .status.state
name: Status
type: string
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: openebs.io
version: v1alpha1
scope: Namespaced
names:
kind: BlockDevice
listKind: BlockDeviceList
plural: blockdevices
singular: blockdevice
shortNames:
- bd
25 changes: 25 additions & 0 deletions deploy/helm/crds/blockdeviceclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: blockdeviceclaims.openebs.io
spec:
additionalPrinterColumns:
- JSONPath: .spec.blockDeviceName
name: BlockDeviceName
type: string
- JSONPath: .status.phase
name: Phase
type: string
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: openebs.io
version: v1alpha1
scope: Namespaced
names:
kind: BlockDeviceClaim
listKind: BlockDeviceClaimList
plural: blockdeviceclaims
shortNames:
- bdc
singular: blockdeviceclaim
132 changes: 132 additions & 0 deletions deploy/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
This name is used for ndm daemonset
*/}}
{{- define "openebs-ndm.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "openebs-ndm.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified ndm daemonset 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 "openebs-ndm.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.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.operator.name" -}}
{{- $ndmName := default .Chart.Name .Values.ndmOperator.nameOverride | trunc 63 | trimSuffix "-" }}
{{- $componentName := .Values.ndmOperator.name | trunc 63 | trimSuffix "-" }}
{{- printf "%s-%s" $ndmName $componentName | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{- $name := default $ndmOperatorName .Values.ndmOperator.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
*/}}
{{- define "openebs-ndm.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "openebs-ndm.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Define meta labels for ndm components
*/}}
{{- define "openebs-ndm.common.metaLabels" -}}
chart: {{ template "openebs-ndm.chart" . }}
heritage: {{ .Release.Service }}
openebs.io/version: {{ .Values.release.version | quote }}
{{- end -}}


{{/*
Create match labels for ndm daemonset component
*/}}
{{- define "openebs-ndm.matchLabels" -}}
app: {{ template "openebs-ndm.name" . }}
release: {{ .Release.Name }}
component: {{ .Values.ndm.componentName | quote }}
{{- end -}}

{{/*
Create component labels for ndm daemonset component
*/}}
{{- define "openebs-ndm.componentLabels" -}}
openebs.io/component-name: {{ .Values.ndm.componentName | quote }}
{{- end -}}


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

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

{{/*
Create component labels for ndm operator component
*/}}
{{- define "openebs-ndm.operator.componentLabels" -}}
openebs.io/component-name: {{ default (include "openebs-ndm.operator.name" .) .Values.ndmOperator.componentName }}
{{- end -}}


{{/*
Create labels for ndm operator component
*/}}
{{- define "openebs-ndm.operator.labels" -}}
{{ include "openebs-ndm.common.metaLabels" . }}
{{ include "openebs-ndm.operator.matchLabels" . }}
{{ include "openebs-ndm.operator.componentLabels" . }}
{{- end -}}
38 changes: 38 additions & 0 deletions deploy/helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "openebs-ndm.fullname" . }}-config
data:
# node-disk-manager-config contains config of available probes and filters.
# Probes and Filters will initialize with default values if config for that
# filter or probe are not present in configmap

# udev-probe is default or primary probe it should be enabled to run ndm
# filterconfigs contains configs of filters. To provide a group of include
# and exclude values add it as , separated string
node-disk-manager.config: |
probeconfigs:
- key: udev-probe
name: udev probe
state: {{ .Values.ndm.probes.enableUdevProbe }}
- key: seachest-probe
name: seachest probe
state: {{ .Values.ndm.probes.enableSeachest }}
- key: smart-probe
name: smart probe
state: {{ .Values.ndm.probes.enableSmartProbe }}
filterconfigs:
- key: os-disk-exclude-filter
name: os disk exclude filter
state: {{ .Values.ndm.filters.enableOsDiskExcludeFilter }}
exclude: "/,/etc/hosts,/boot"
- key: vendor-filter
name: vendor filter
state: {{ .Values.ndm.filters.enableVendorFilter }}
include: ""
exclude: "{{ .Values.ndm.filters.excludeVendors }}"
- key: path-filter
name: path filter
state: {{ .Values.ndm.filters.enablePathFilter }}
include: "{{ .Values.ndm.filters.includePaths }}"
exclude: "{{ .Values.ndm.filters.excludePaths }}"
Loading

0 comments on commit 4119e95

Please sign in to comment.