diff --git a/deploy/charts/rawfile-csi/.helmignore b/deploy/charts/rawfile-csi/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/deploy/charts/rawfile-csi/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deploy/charts/rawfile-csi/Chart.yaml b/deploy/charts/rawfile-csi/Chart.yaml new file mode 100644 index 0000000..6ce1b5e --- /dev/null +++ b/deploy/charts/rawfile-csi/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: rawfile-csi +description: RawFile Driver Container Storage Interface +type: application +version: 0.1.0 +appVersion: 0.0.1 diff --git a/deploy/00-driver.yaml b/deploy/charts/rawfile-csi/templates/00-driver.yaml similarity index 70% rename from deploy/00-driver.yaml rename to deploy/charts/rawfile-csi/templates/00-driver.yaml index fd68b54..b24df60 100644 --- a/deploy/00-driver.yaml +++ b/deploy/charts/rawfile-csi/templates/00-driver.yaml @@ -5,5 +5,7 @@ metadata: spec: attachRequired: false podInfoOnMount: true +{{- if semverCompare ">=1.16" .Capabilities.KubeVersion.Version }} volumeLifecycleModes: - Persistent +{{- end }} diff --git a/deploy/00-rbac.yaml b/deploy/charts/rawfile-csi/templates/00-rbac.yaml similarity index 71% rename from deploy/00-rbac.yaml rename to deploy/charts/rawfile-csi/templates/00-rbac.yaml index ae79aa5..513b4c7 100644 --- a/deploy/00-rbac.yaml +++ b/deploy/charts/rawfile-csi/templates/00-rbac.yaml @@ -1,13 +1,14 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: csi-rawfile-driver - namespace: kube-system + name: {{ include "rawfile-csi.fullname" . }}-driver +imagePullSecrets: + {{- toYaml .Values.imagePullSecrets | nindent 2 }} --- kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: csi-rawfile-provisioner + name: {{ include "rawfile-csi.fullname" . }}-provisioner rules: - apiGroups: [""] resources: ["secrets"] @@ -40,20 +41,20 @@ rules: kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: csi-rawfile-provisioner + name: {{ include "rawfile-csi.fullname" . }}-provisioner subjects: - kind: ServiceAccount - name: csi-rawfile-driver - namespace: kube-system + name: {{ include "rawfile-csi.fullname" . }}-driver + namespace: {{ .Release.Namespace }} roleRef: kind: ClusterRole - name: csi-rawfile-provisioner + name: {{ include "rawfile-csi.fullname" . }}-provisioner apiGroup: rbac.authorization.k8s.io --- kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: csi-rawfile-broker + name: {{ include "rawfile-csi.fullname" . }}-broker rules: - apiGroups: [""] resources: ["persistentvolumes"] @@ -65,12 +66,12 @@ rules: kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: csi-rawfile-broker + name: {{ include "rawfile-csi.fullname" . }}-broker subjects: - kind: ServiceAccount - name: csi-rawfile-driver - namespace: kube-system + name: {{ include "rawfile-csi.fullname" . }}-driver + namespace: {{ .Release.Namespace }} roleRef: kind: ClusterRole - name: csi-rawfile-broker + name: {{ include "rawfile-csi.fullname" . }}-broker apiGroup: rbac.authorization.k8s.io diff --git a/deploy/01-controller-plugin.yaml b/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml similarity index 66% rename from deploy/01-controller-plugin.yaml rename to deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml index f2d87a5..6b958bf 100644 --- a/deploy/01-controller-plugin.yaml +++ b/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml @@ -1,20 +1,20 @@ -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: - name: csi-rawfile-controller + name: {{ include "rawfile-csi.fullname" . }}-controller spec: replicas: 1 strategy: type: Recreate selector: - matchLabels: - app: csi-rawfile-controller + matchLabels: &selectorLabels + {{- include "rawfile-csi.selectorLabels" . | nindent 6 }} + component: controller template: metadata: - labels: - app: csi-rawfile-controller + labels: *selectorLabels spec: - serviceAccount: csi-rawfile-driver + serviceAccount: {{ include "rawfile-csi.fullname" . }}-driver priorityClassName: system-cluster-critical tolerations: - key: "node-role.kubernetes.io/master" @@ -26,14 +26,16 @@ spec: emptyDir: {} containers: - name: csi-driver - image: registry.hamdocker.ir/hamravesh/rawfile-csi:master - imagePullPolicy: Always + image: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag }}" + imagePullPolicy: {{ .Values.controller.image.pullPolicy }} env: - name: CSI_ENDPOINT value: unix:///csi/csi.sock volumeMounts: - name: socket-dir mountPath: /csi + resources: + {{- toYaml .Values.controller.resources | nindent 12 }} - name: csi-provisioner image: quay.io/k8scsi/csi-provisioner:v1.6.0 imagePullPolicy: IfNotPresent diff --git a/deploy/01-node-plugin.yaml b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml similarity index 81% rename from deploy/01-node-plugin.yaml rename to deploy/charts/rawfile-csi/templates/01-node-plugin.yaml index b2eefe5..f6ec61f 100644 --- a/deploy/01-node-plugin.yaml +++ b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml @@ -1,22 +1,20 @@ -kind: DaemonSet apiVersion: apps/v1 +kind: DaemonSet metadata: - name: csi-rawfile-node + name: {{ include "rawfile-csi.fullname" . }}-node spec: updateStrategy: rollingUpdate: maxUnavailable: "100%" selector: - matchLabels: - app: csi-rawfile-node + matchLabels: &selectorLabels + {{- include "rawfile-csi.selectorLabels" . | nindent 6 }} + component: node template: metadata: - labels: - app: csi-rawfile-node + labels: *selectorLabels spec: - serviceAccount: csi-rawfile-driver - hostNetwork: true - hostIPC: true + serviceAccount: {{ include "rawfile-csi.fullname" . }}-driver priorityClassName: system-node-critical tolerations: - operator: "Exists" @@ -39,8 +37,10 @@ spec: type: DirectoryOrCreate containers: - name: csi-driver - image: registry.hamdocker.ir/hamravesh/rawfile-csi:master - imagePullPolicy: Always + image: "{{ .Values.node.image.repository }}:{{ .Values.node.image.tag }}" + imagePullPolicy: {{ .Values.node.image.pullPolicy }} + securityContext: + privileged: true env: - name: CSI_ENDPOINT value: unix:///csi/csi.sock @@ -49,8 +49,6 @@ spec: fieldRef: apiVersion: v1 fieldPath: spec.nodeName - securityContext: - privileged: true volumeMounts: - name: socket-dir mountPath: /csi @@ -59,6 +57,8 @@ spec: mountPropagation: "Bidirectional" - name: data-dir mountPath: /data + resources: + {{- toYaml .Values.node.resources | nindent 12 }} - name: node-driver-registrar image: quay.io/k8scsi/csi-node-driver-registrar:v1.2.0 imagePullPolicy: IfNotPresent diff --git a/deploy/charts/rawfile-csi/templates/_helpers.tpl b/deploy/charts/rawfile-csi/templates/_helpers.tpl new file mode 100644 index 0000000..6a093e3 --- /dev/null +++ b/deploy/charts/rawfile-csi/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "rawfile-csi.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 "rawfile-csi.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 "rawfile-csi.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "rawfile-csi.labels" -}} +helm.sh/chart: {{ include "rawfile-csi.chart" . }} +{{ include "rawfile-csi.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "rawfile-csi.selectorLabels" -}} +app.kubernetes.io/name: {{ include "rawfile-csi.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "rawfile-csi.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "rawfile-csi.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deploy/charts/rawfile-csi/values.yaml b/deploy/charts/rawfile-csi/values.yaml new file mode 100644 index 0000000..2380ecf --- /dev/null +++ b/deploy/charts/rawfile-csi/values.yaml @@ -0,0 +1,22 @@ +defaults: &defaults + image: + repository: registry.hamdocker.ir/hamravesh/rawfile-csi + tag: master + pullPolicy: Always + resources: + limits: + cpu: 100m + memory: 100Mi + requests: + cpu: 10m + memory: 100Mi + +controller: + << : *defaults + +node: + << : *defaults + metrics: + enabled: false + +imagePullSecrets: [] diff --git a/templates/task.yaml b/templates/task.yaml index 062b239..99ee24d 100644 --- a/templates/task.yaml +++ b/templates/task.yaml @@ -4,8 +4,6 @@ metadata: name: {name} namespace: {namespace} spec: - # FIXME: hardcoded - serviceAccount: rawfile-csi-controller restartPolicy: Never terminationGracePeriodSeconds: 0 tolerations: @@ -27,9 +25,11 @@ spec: mountPath: /data resources: requests: &rsc + cpu: 10m + memory: 100Mi + limit: cpu: 100m memory: 100Mi - limit: *rsc command: - /bin/sh - -c