Helm chart for creating smb-flexvols

This commit is contained in:
Seth Nickell 2020-04-28 00:26:22 -10:00
Родитель fea2d57483
Коммит bb5d403e8c
7 изменённых файлов: 187 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,22 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

Просмотреть файл

@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for adding a smb-flexvol to a Kubernetes cluster
name: smb-flexvol
version: 0.1.0

Просмотреть файл

@ -0,0 +1,56 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "smb-flexvol.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 "smb-flexvol.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 "smb-flexvol.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "smb-flexvol.labels" -}}
app.kubernetes.io/name: {{ include "smb-flexvol.name" . }}
helm.sh/chart: {{ include "smb-flexvol.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "smb-flexvol.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "smb-flexvol.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

Просмотреть файл

@ -0,0 +1,23 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ include "smb-flexvol.fullname" . }}
labels:
{{ include "smb-flexvol.labels" . | indent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ include "smb-flexvol.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
capacity:
storage: {{ .Values.smb.storageCapacity }}
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
flexVolume:
driver: "microsoft.com/smb"
secretRef:
name: {{ .Values.smb.credsSecretName }}
options:
source: //{{ .Values.smb.server }}/{{ .Values.smb.share }}
mountoptions: {{ .Values.smb.mountOptions }}

Просмотреть файл

@ -0,0 +1,18 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "smb-flexvol.fullname" . }}
labels:
{{ include "smb-flexvol.labels" . | indent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ include "smb-flexvol.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
accessModes:
- ReadWriteMany
resources:
requests:
storage: {{ .Values.storageRequest }}
volumeName: {{ include "smb-flexvol.fullname" . }}
storageClassName: ""

Просмотреть файл

@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "smb-flexvol.fullname" . }}-smb-flexvol-installer
labels:
k8s-app: smb
{{ include "smb-flexvol.labels" . | indent 4 }}
namespace: kube-system
spec:
selector:
matchLabels:
name: smb
app.kubernetes.io/name: {{ include "smb-flexvol.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
name: smb
app.kubernetes.io/name: {{ include "smb-flexvol.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
containers:
- name: smb-flexvol-installer
image: mcr.microsoft.com/k8s/flexvolume/smb-flexvolume
imagePullPolicy: Always
volumeMounts:
- name: volplugins
mountPath: /etc/kubernetes/volumeplugins/
- name: varlog
mountPath: /var/log/
volumes:
- name: varlog
hostPath:
path: /var/log/
- name: volplugins
hostPath:
path: {{ .Values.flexVolumePluginPath }}
type: DirectoryOrCreate
nodeSelector:
beta.kubernetes.io/os: linux

Просмотреть файл

@ -0,0 +1,23 @@
smb:
server: "STORAGE-ACCOUNT.file.core.windows.net"
share: "SHARE-NAME"
credsSecretName: # name of k8s secrets to ref
storageCapacity: 100Gi
# more mount options: https://linux.die.net/man/8/mount.cifs:
mountOptions: "vers=3.0,dir_mode=0777,file_mode=0777"
storageRequest: 10Gi
# You MUST configure the path your k8s platform searches for flex volume plugins
# See https://rook.io/docs/rook/master/flexvolume.html for helpful per-platform tips
# "Default" location:
# flexVolumePluginPath: /usr/libexec/kubernetes/kubelet-plugins/volume/exec/
# Azure AKS:
flexVolumePluginPath: /etc/kubernetes/volumeplugins
# Google GKE:
# flexVolumePluginPath: /etc/kubernetes/volumeplugins/
labels: {}