Skip to content

Commit

Permalink
add helmchart for local-path-provisioner
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed Sep 15, 2023
1 parent 7b98dcc commit c0b1077
Show file tree
Hide file tree
Showing 11 changed files with 381 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/local-path-provisioner/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
13 changes: 13 additions & 0 deletions charts/local-path-provisioner/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v2
name: local-path-provisioner
description: Dynamically provisioning persistent local storage with Kubernetes

type: application

version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.0.24"
32 changes: 32 additions & 0 deletions charts/local-path-provisioner/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: test-statefulset
spec:
selector:
matchLabels:
app: nginx
minReadySeconds: 10 # by default is 0
template:
metadata:
labels:
app: nginx # has to match .spec.selector.matchLabels
spec:
containers:
- name: nginx
image: registry.k8s.io/nginx-slim:0.8
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "{{ include "local-path-provisioner.fullname" . }}"
resources:
requests:
storage: 1Gi
62 changes: 62 additions & 0 deletions charts/local-path-provisioner/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "local-path-provisioner.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 "local-path-provisioner.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 "local-path-provisioner.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "local-path-provisioner.selectorLabels" -}}
app.kubernetes.io/name: {{ include "local-path-provisioner.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "local-path-provisioner.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "local-path-provisioner.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/local-path-provisioner/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "local-path-provisioner.fullname" . }}
rules:
- apiGroups: [ "" ]
resources: [ "nodes", "persistentvolumeclaims", "configmaps" ]
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "" ]
resources: [ "endpoints", "persistentvolumes", "pods" ]
verbs: [ "*" ]
- apiGroups: [ "" ]
resources: [ "events" ]
verbs: [ "create", "patch" ]
- apiGroups: [ "storage.k8s.io" ]
resources: [ "storageclasses" ]
verbs: [ "get", "list", "watch" ]
12 changes: 12 additions & 0 deletions charts/local-path-provisioner/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "local-path-provisioner.fullname" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "local-path-provisioner.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "local-path-provisioner.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
33 changes: 33 additions & 0 deletions charts/local-path-provisioner/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ include "local-path-provisioner.fullname" . }}
data:
config.json: |-
{{ toPrettyJson .Values.app.config | nindent 4 }}
setup: |-
{{ .Values.app.setup | nindent 4 }}
teardown: |-
{{ .Values.app.teardown | nindent 4 }}
helperPod.yaml: |-
{{ if .Values.helper.overwritePodDefinition -}}
{{ .Values.helper.podDefinition | nindent 4 }}
{{- else -}}
apiVersion: v1
kind: Pod
metadata:
name: {{ include "local-path-provisioner.fullname" . }}-helper
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.helper.podSecurityContext | nindent 8 }}
containers:
- name: helper-pod
image: "{{ .Values.helper.image.repository }}:{{ .Values.helper.image.tag }}"
imagePullPolicy: {{ .Values.helper.image.pullPolicy }}
resources:
{{- toYaml .Values.helper.resources | nindent 12 }}
{{- end }}
75 changes: 75 additions & 0 deletions charts/local-path-provisioner/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "local-path-provisioner.fullname" . }}
labels:
{{- include "local-path-provisioner.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "local-path-provisioner.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "local-path-provisioner.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "local-path-provisioner.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- local-path-provisioner
- --debug
- start
- --config
- /etc/config/config.json
- --configmap-name
- "{{ include "local-path-provisioner.fullname" . }}"
- --service-account-name
- "{{ include "local-path-provisioner.serviceAccountName" . }}"
- --worker-threads
- "{{ .Values.app.workerThreads }}"
- --provisioning-retry-count
- "{{ .Values.app.provisioningRetryCount }}"
- --deletion-retry-count
- "{{ .Values.app.deletionRetryCount }}"
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config-volume
mountPath: /etc/config/
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumes:
- name: config-volume
configMap:
name: {{ include "local-path-provisioner.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
10 changes: 10 additions & 0 deletions charts/local-path-provisioner/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "local-path-provisioner.serviceAccountName" . }}
labels:
{{- include "local-path-provisioner.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
9 changes: 9 additions & 0 deletions charts/local-path-provisioner/templates/storageclass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: {{ include "local-path-provisioner.fullname" . }}
labels:
{{- include "local-path-provisioner.labels" . | nindent 4 }}
provisioner: rancher.io/local-path
volumeBindingMode: {{ .Values.storageClass.volumeBindingMode }}
reclaimPolicy: {{ .Values.storageClass.reclaimPolicy }}
95 changes: 95 additions & 0 deletions charts/local-path-provisioner/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Default values for local-path-provisioner.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

image:
repository: rancher/local-path-provisioner
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

helper:
image:
repository: alpine
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "3.18"
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

overwritePodDefinition: false
podDefinition: |
apiVersion: v1
kind: Pod
metadata:
name: helper-pod
spec:
containers:
- name: helper-pod
image: busybox
imagePullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

storageClass:
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete

app:
provisioningRetryCount: 15
deletionRetryCount: 15
workerThreads: 4
config:
nodePathMap:
- node: DEFAULT_PATH_FOR_NON_LISTED_NODES
paths:
- /opt/local-path-provisioner
setup: |
#!/bin/sh
set -eu
mkdir -m 0777 -p "$VOL_DIR"
teardown: |
#!/bin/sh
set -eu
rm -rf "$VOL_DIR"
serviceAccount:
create: true
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit c0b1077

Please sign in to comment.