Skip to content

Commit

Permalink
feat(helm): Added support for additional volumes
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Hipwell <steve.hipwell@gmail.com>
  • Loading branch information
stevehipwell committed Aug 7, 2023
1 parent a1c19d5 commit 2e3e0a3
Show file tree
Hide file tree
Showing 6 changed files with 297 additions and 95 deletions.
108 changes: 56 additions & 52 deletions helm/README.md

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions helm/examples/additional-volumes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
additionalVolumes:
- name: init-config
configMap:
name: init-config
- name: signal
emptyDir: {}

additionalVolumeMounts:
- name: signal
mountPath: /etc/signal
readOnly: true

initContainers:
- name: test
image: alpine:3
command: ["/bin/sh"]
args:
- -c
- /etc/init/run.sh
volumeMounts:
- name: init-config
mountPath: /etc/init
- name: signal
mountPath: /etc/signal
168 changes: 168 additions & 0 deletions helm/generated_examples/additional-volumes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
---
# Source: local-static-provisioner/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: local-static-provisioner
namespace: default
labels:
helm.sh/chart: local-static-provisioner-1.0.0
app.kubernetes.io/name: local-static-provisioner
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: local-static-provisioner
---
# Source: local-static-provisioner/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: local-static-provisioner-config
namespace: default
labels:
helm.sh/chart: local-static-provisioner-1.0.0
app.kubernetes.io/name: local-static-provisioner
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: local-static-provisioner
data:
storageClassMap: |
fast-disks:
hostDir: /mnt/fast-disks
mountDir: /mnt/fast-disks
blockCleanerCommand:
- "/scripts/shred.sh"
- "2"
volumeMode: Filesystem
fsType: ext4
namePattern: "*"
---
# Source: local-static-provisioner/templates/rbac.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: local-static-provisioner-node-clusterrole
labels:
helm.sh/chart: local-static-provisioner-1.0.0
app.kubernetes.io/name: local-static-provisioner
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: local-static-provisioner
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["watch"]
- apiGroups: ["", "events.k8s.io"]
resources: ["events"]
verbs: ["create", "update", "patch"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get"]
---
# Source: local-static-provisioner/templates/rbac.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: local-static-provisioner-node-binding
labels:
helm.sh/chart: local-static-provisioner-1.0.0
app.kubernetes.io/name: local-static-provisioner
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: local-static-provisioner
subjects:
- kind: ServiceAccount
name: local-static-provisioner
namespace: default
roleRef:
kind: ClusterRole
name: local-static-provisioner-node-clusterrole
apiGroup: rbac.authorization.k8s.io
---
# Source: local-static-provisioner/templates/daemonset_linux.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: local-static-provisioner
namespace: default
labels:
helm.sh/chart: local-static-provisioner-1.0.0
app.kubernetes.io/name: local-static-provisioner
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: local-static-provisioner
spec:
selector:
matchLabels:
app.kubernetes.io/name: local-static-provisioner
app.kubernetes.io/instance: local-static-provisioner
template:
metadata:
labels:
app.kubernetes.io/name: local-static-provisioner
app.kubernetes.io/instance: local-static-provisioner
annotations:
checksum/config: fbfc9e88fedc172393c69523b113ad18a015df9a3331a28ebd22fbddf52b4c8e
spec:
serviceAccountName: local-static-provisioner
nodeSelector:
kubernetes.io/os: linux
initContainers:
- args:
- -c
- /etc/init/run.sh
command:
- /bin/sh
image: alpine:3
name: test
volumeMounts:
- mountPath: /etc/init
name: init-config
- mountPath: /etc/signal
name: signal
containers:
- name: provisioner
image: registry.k8s.io/sig-storage/local-volume-provisioner:v2.5.0
securityContext:
privileged: true
env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: MY_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: JOB_CONTAINER_IMAGE
value: registry.k8s.io/sig-storage/local-volume-provisioner:v2.5.0
ports:
- name: metrics
containerPort: 8080
volumeMounts:
- name: provisioner-config
mountPath: /etc/provisioner/config
readOnly: true
- name: provisioner-dev
mountPath: /dev
- name: fast-disks
mountPath: /mnt/fast-disks
mountPropagation: HostToContainer
- mountPath: /etc/signal
name: signal
readOnly: true
volumes:
- name: provisioner-config
configMap:
name: local-static-provisioner-config
- name: provisioner-dev
hostPath:
path: /dev
- name: fast-disks
hostPath:
path: /mnt/fast-disks
- configMap:
name: init-config
name: init-config
- emptyDir: {}
name: signal
35 changes: 18 additions & 17 deletions helm/provisioner/templates/daemonset_linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,32 @@ spec:
- name: provisioner-config
mountPath: /etc/provisioner/config
readOnly: true
{{- if .Values.mountDevVolume }}
{{- if .Values.mountDevVolume }}
- name: provisioner-dev
mountPath: /dev
{{- end }}
{{- range $classConfig := .Values.classes }}
- name: {{ $classConfig.name }}
mountPath: {{ $classConfig.mountDir | default $classConfig.hostDir }}
{{- end }}
{{- range .Values.classes }}
- name: {{ .name }}
mountPath: {{ default .hostDir .mountDir }}
mountPropagation: HostToContainer
{{- end }}
{{- end }}
{{- with .Values.additionalVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: provisioner-config
configMap:
name: {{ template "provisioner.fullname" . }}-config
{{- if .Values.mountDevVolume }}
{{- if .Values.mountDevVolume }}
- name: provisioner-dev
hostPath:
path: /dev
{{- end }}
{{- range $classConfig := .Values.classes }}
- name: {{ $classConfig.name }}
{{- end }}
{{- range .Values.classes }}
- name: {{ .name }}
hostPath:
path: {{ $classConfig.hostDir }}
{{- end }}
{{- range $name, $path := .Values.additionalHostPathVolumes }}
- name: {{ quote $name }}
hostPath:
path: {{ quote $path }}
{{- end }}
path: {{ .hostDir }}
{{- end }}
{{- with .Values.additionalVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
41 changes: 21 additions & 20 deletions helm/provisioner/templates/daemonset_windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@ spec:
- name: provisioner-config
mountPath: /etc/provisioner/config
readOnly: true
{{- if .Values.mountDevVolume }}
- name: provisioner-dev
mountPath: /dev
{{- end }}
{{- range $classConfig := .Values.classes }}
- name: {{ $classConfig.name }}
mountPath: {{ $classConfig.mountDir | default $classConfig.hostDir }}
mountPropagation: HostToContainer
{{- end }}
- name: csi-proxy-volume-v1
mountPath: \\.\pipe\csi-proxy-volume-v1
- name: csi-proxy-filesystem-v1
Expand All @@ -104,6 +95,18 @@ spec:
mountPath: \\.\pipe\csi-proxy-volume-v1beta2
- name: csi-proxy-filesystem-v1beta2
mountPath: \\.\pipe\csi-proxy-filesystem-v1beta2
{{- if .Values.mountDevVolume }}
- name: provisioner-dev
mountPath: /dev
{{- end }}
{{- range .Values.classes }}
- name: {{ .name }}
mountPath: {{ default .hostDir .mountDir }}
mountPropagation: HostToContainer
{{- end }}
{{- with .Values.additionalVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: csi-proxy-volume-v1
hostPath:
Expand All @@ -126,23 +129,21 @@ spec:
- name: provisioner-config
configMap:
name: {{ template "provisioner.fullname" . }}-config
{{- if .Values.mountDevVolume }}
{{- if .Values.mountDevVolume }}
- name: provisioner-dev
hostPath:
path: "C:\\dev"
# If nothing exists at the given path, an empty directory will be
# created there as needed with permission set to 0755,
# having the same group and ownership with Kubelet.
type: DirectoryOrCreate
{{- end }}
{{- range $classConfig := .Values.classes }}
- name: {{ $classConfig.name }}
{{- end }}
{{- range .Values.classes }}
- name: {{ .name }}
hostPath:
path: {{ $classConfig.hostDir }}
{{- end }}
{{- range $name, $path := .Values.additionalHostPathVolumes }}
- name: {{ quote $name }}
hostPath:
path: {{ quote $path }}
{{- end }}
path: {{ .hostDir }}
{{- end }}
{{- with .Values.additionalVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
16 changes: 10 additions & 6 deletions helm/provisioner/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ useNodeNameOnly: false
# 2*minResyncPeriod. Default: 5m0s.
#minResyncPeriod: 5m0s

# Additional volumes to create, for the default container and init containers
# to consume
additionalVolumes: []

# Mount the host's `/dev/` by default so that block device symlinks can be
# resolved by the containers
mountDevVolume: true

# A mapping of additional HostPath volume names to host paths to create, for
# your init container to consume
additionalHostPathVolumes: {}
# provisioner-proc: /proc
# provisioner-mnt: /mnt
# Additional volumes to mount to the default container, the volumes should
# either be host paths or defined by additionalVolumes
additionalVolumeMounts: []

# Map of label key-value pairs to apply to the PVs created by the
# provisioner. Uncomment to add labels to the list.
Expand Down Expand Up @@ -124,7 +126,8 @@ affinity: {}
#
# If configured, resources will set the requests/limits field to the Daemonset PodSpec.
# Ref: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
resources: {}
resources:
{}
# limits:
# memory: "512Mi"
# cpu: "1000m"
Expand All @@ -134,6 +137,7 @@ resources: {}
#
# If set to false, containers created by the Provisioner Daemonset will run without extra privileges.
privileged: true

# Any init containers can be configured here.
# Ref: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
initContainers: []
Expand Down

0 comments on commit 2e3e0a3

Please sign in to comment.