Skip to content

Commit

Permalink
Merge pull request #57 from MaxFedotov/controler-volume-create-delete
Browse files Browse the repository at this point in the history
Dynamic Volume Provisioning
  • Loading branch information
kitt1987 authored Jun 4, 2023
2 parents 08ca39d + 045eba0 commit 9810c51
Show file tree
Hide file tree
Showing 21 changed files with 884 additions and 260 deletions.
71 changes: 71 additions & 0 deletions charts/warm-metal-csi-driver/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "warm-metal-csi-driver.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 "warm-metal-csi-driver.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 "warm-metal-csi-driver.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{- define "warm-metal-csi-driver.nodeplugin.labels" -}}
component: nodeplugin
{{ include "warm-metal-csi-driver.labels" . }}
{{- end }}

{{- define "warm-metal-csi-driver.controllerplugin.labels" -}}
component: controllerplugin
{{ include "warm-metal-csi-driver.labels" . }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "warm-metal-csi-driver.selectorLabels" -}}
app.kubernetes.io/name: {{ include "warm-metal-csi-driver.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "warm-metal-csi-driver.nodeplugin.selectorLabels" -}}
component: nodeplugin
{{ include "warm-metal-csi-driver.selectorLabels" . }}
{{- end }}

{{- define "warm-metal-csi-driver.controllerplugin.selectorLabels" -}}
component: controllerplugin
{{ include "warm-metal-csi-driver.selectorLabels" . }}
{{- end }}
71 changes: 71 additions & 0 deletions charts/warm-metal-csi-driver/templates/controller-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "warm-metal-csi-driver.fullname" . }}-controller
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "warm-metal-csi-driver.fullname" . }}-controller
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["csinodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["get", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "warm-metal-csi-driver.fullname" . }}-controller
subjects:
- kind: ServiceAccount
name: {{ include "warm-metal-csi-driver.fullname" . }}-controller
namespace: {{.Release.Namespace}}
roleRef:
kind: ClusterRole
name: {{ include "warm-metal-csi-driver.fullname" . }}-controller
apiGroup: rbac.authorization.k8s.io
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "warm-metal-csi-driver.fullname" . }}-controller
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "watch", "list", "delete", "update", "create"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "warm-metal-csi-driver.fullname" . }}-controller
namespace: {{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
name: {{ include "warm-metal-csi-driver.fullname" . }}-controller
namespace: {{ .Release.Namespace }}
roleRef:
kind: Role
name: {{ include "warm-metal-csi-driver.fullname" . }}-controller
apiGroup: rbac.authorization.k8s.io
120 changes: 120 additions & 0 deletions charts/warm-metal-csi-driver/templates/controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "warm-metal-csi-driver.fullname" . }}-controller
labels:
{{- include "warm-metal-csi-driver.controllerplugin.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "warm-metal-csi-driver.controllerplugin.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "warm-metal-csi-driver.controllerplugin.labels" . | nindent 8 }}
spec:
containers:
- name: csi-provisioner
image: "{{ .Values.csiExternalProvisioner.image.repository }}:{{ .Values.csiExternalProvisioner.image.tag }}"
imagePullPolicy: {{ .Values.csiLivenessProbe.image.pullPolicy }}
args:
- "--csi-address=/csi/csi.sock"
{{- with .Values.csiExternalProvisioner.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- mountPath: /csi
name: socket-dir
- name: liveness-probe
image: "{{ .Values.csiLivenessProbe.image.repository }}:{{ .Values.csiLivenessProbe.image.tag }}"
imagePullPolicy: {{ .Values.csiLivenessProbe.image.pullPolicy }}
args:
- "--csi-address=/csi/csi.sock"
- "--http-endpoint=:9809"
- "-v={{ .Values.logLevel }}"
{{- with .Values.csiLivenessProbe.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- mountPath: /csi
name: socket-dir
- name: csi-plugin
args:
- --endpoint=$(CSI_ENDPOINT)
- --node=$(KUBE_NODE_NAME)
- --runtime-addr=$(CRI_ADDR)
- --node-plugin-sa={{ include "warm-metal-csi-driver.fullname" . }}-nodeplugin
- "-v={{ .Values.logLevel }}"
- "--mode=controller"
env:
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
- name: CRI_ADDR
value: {{ .Values.runtime.engine }}://{{ .Values.runtime.socketPath }}
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
{{- with .Values.csiPlugin.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
image: "{{ .Values.csiPlugin.image.repository }}:{{ .Values.csiPlugin.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.csiPlugin.image.pullPolicy }}
ports:
- containerPort: 9809
name: metrics
protocol: TCP
livenessProbe:
{{- toYaml .Values.csiPlugin.livenessProbe | nindent 12}}
securityContext:
privileged: true
volumeMounts:
- mountPath: /csi
name: socket-dir
- mountPath: {{ .Values.kubeletRoot }}/pods
mountPropagation: Bidirectional
name: mountpoint-dir
- mountPath: {{ .Values.runtime.socketPath }}
name: runtime-socket
- mountPath: {{ .Values.snapshotRoot }}
mountPropagation: Bidirectional
name: snapshot-root-0
serviceAccountName: {{ include "warm-metal-csi-driver.fullname" . }}-controller
volumes:
- hostPath:
path: {{ .Values.kubeletRoot }}/plugins/csi-image.warm-metal.tech
type: DirectoryOrCreate
name: socket-dir
- hostPath:
path: {{ .Values.kubeletRoot }}/pods
type: DirectoryOrCreate
name: mountpoint-dir
- hostPath:
path: {{ .Values.kubeletRoot }}/plugins_registry
type: Directory
name: registration-dir
- hostPath:
path: {{ .Values.runtime.socketPath }}
type: Socket
name: runtime-socket
- hostPath:
path: {{ .Values.snapshotRoot }}
type: Directory
name: snapshot-root-0
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
3 changes: 2 additions & 1 deletion charts/warm-metal-csi-driver/templates/csi-driver.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: csi-image.warm-metal.tech
labels:
{{- include "warm-metal-csi-driver.labels" . | nindent 4 }}
spec:
attachRequired: false
podInfoOnMount: true
Expand Down
96 changes: 0 additions & 96 deletions charts/warm-metal-csi-driver/templates/daemon-set.yaml

This file was deleted.

Loading

0 comments on commit 9810c51

Please sign in to comment.