Skip to content

Commit 037aa3e

Browse files
author
Darryl Weaver
authored
Merge pull request #177 from weaveworks/add-local-path-provisioner
add local-path-provisioner profile for LM and Kind clusters
2 parents 0d23dc6 + 5e941c5 commit 037aa3e

20 files changed

+678
-0
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: local-path-provisioner
3+
repository: ""
4+
version: v0.0.22-dev
5+
digest: sha256:6c957a41ce1261989090a9d5a4cd73697c5c4ea2743b25841ddc6d2e0a269551
6+
generated: "2022-09-02T10:12:19.378410737+01:00"
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: v2
2+
description: Weaveworks profile for HostPath for persistent local storage with Kubernetes based on Rancher
3+
name: local-path-provisioner
4+
version: 0.0.3
5+
appVersion: "v0.0.22-dev"
6+
kubeVersion: ">=1.12.0-r0"
7+
home: https://github.com/weaveworks/profiles-catalog
8+
sources:
9+
- https://github.com/rancher/local-path-provisioner.git
10+
dependencies:
11+
- name: local-path-provisioner
12+
version: "v0.0.22-dev"
13+
keywords:
14+
- local-path-provisioner
15+
- kind
16+
- storage
17+
- hostpath
18+
maintainers:
19+
- name: Weaveworks
20+
21+
annotations:
22+
"weave.works/profile": local-path-provisioner
23+
"weave.works/category": Storage
24+
"weave.works/layer": layer-0
25+
"weave.works/links": |
26+
- name: Chart Sources
27+
url: https://github.com/weaveworks/profiles-catalog.git
28+
- name: Upstream Project
29+
url: https://github.com/rancher/local-path-provisioner.git
30+
"weave.works/profile-ci": |
31+
- "kind"
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Local path provisioner profile for weave gitops
2+
3+
This profile is based on the local-path-provisioner from Rancher.
4+
The Rancher Helm chart is used as a subchart.
5+
6+
This profile will set the local-path-provisioner as the default storage class.
7+
8+
## Uupgrading the Rancher chart
9+
10+
As the Rancher chart is not published in a Helm repository,
11+
to update the version you will have to download the chart from:
12+
https://github.com/rancher/local-path-provisioner/tree/master/deploy/chart/local-path-provisioner
13+
And copy that into the /charts folder.
14+
15+
Also remember to update the version in the profile's Chart.yaml to refer to the Rancher chart version.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
.vscode/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
description: Use HostPath for persistent local storage with Kubernetes
3+
name: local-path-provisioner
4+
version: 0.0.22-dev
5+
appVersion: "v0.0.22-dev"
6+
keywords:
7+
- storage
8+
- hostpath
9+
kubeVersion: ">=1.12.0-r0"
10+
home: https://github.com/rancher/local-path-provisioner
11+
sources:
12+
- https://github.com/rancher/local-path-provisioner.git
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Local Path Provisioner
2+
3+
[Local Path Provisioner](https://github.com/rancher/local-path-provisioner) provides a way for the Kubernetes users to
4+
utilize the local storage in each node. Based on the user configuration, the Local Path Provisioner will create
5+
`hostPath` based persistent volume on the node automatically. It utilizes the features introduced by Kubernetes [Local
6+
Persistent Volume feature](https://kubernetes.io/blog/2018/04/13/local-persistent-volumes-beta/), but make it a simpler
7+
solution than the built-in `local` volume feature in Kubernetes.
8+
9+
## TL;DR;
10+
11+
```console
12+
$ git clone https://github.com/rancher/local-path-provisioner.git
13+
$ cd local-path-provisioner
14+
$ helm install --name local-path-storage --namespace local-path-storage ./deploy/chart/
15+
```
16+
17+
## Introduction
18+
19+
This chart bootstraps a [Local Path Provisioner](https://github.com/rancher/local-path-provisioner) deployment on a
20+
[Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
21+
22+
## Prerequisites
23+
24+
- Kubernetes 1.12+ with Beta APIs enabled
25+
26+
## Installing the Chart
27+
28+
To install the chart with the release name `local-path-storage`:
29+
30+
```console
31+
$ git clone https://github.com/rancher/local-path-provisioner.git
32+
$ cd local-path-provisioner
33+
$ helm install ./deploy/chart/ --name local-path-storage --namespace local-path-storage
34+
```
35+
36+
The command deploys Local Path Provisioner on the Kubernetes cluster in the default configuration. The
37+
[configuration](#configuration) section lists the parameters that can be configured during installation.
38+
39+
> **Tip**: List all releases using `helm list`
40+
41+
## Uninstalling the Chart
42+
43+
To uninstall/delete the `local-path-storage` deployment:
44+
45+
```console
46+
$ helm delete --purge local-path-storage
47+
```
48+
49+
The command removes all the Kubernetes components associated with the chart and deletes the release.
50+
51+
## Configuration
52+
53+
The following table lists the configurable parameters of the Local Path Provisioner for Kubernetes chart and their
54+
default values.
55+
56+
| Parameter | Description | Default |
57+
| ----------------------------------- | ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
58+
| `image.repository` | Local Path Provisioner image name | `rancher/local-path-provisioner` |
59+
| `image.tag` | Local Path Provisioner image tag | `master-head` |
60+
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
61+
| `storageClass.create` | If true, create a `StorageClass` | `true` |
62+
| `storageClass.provisionerName` | The provisioner name for the storage class | `nil` |
63+
| `storageClass.defaultClass` | If true, set the created `StorageClass` as the cluster's default `StorageClass` | `false` |
64+
| `storageClass.name` | The name to assign the created StorageClass | local-path |
65+
| `storageClass.reclaimPolicy` | ReclaimPolicy field of the class | Delete |
66+
| `nodePathMap` | Configuration of where to store the data on each node | `[{node: DEFAULT_PATH_FOR_NON_LISTED_NODES, paths: [/opt/local-path-provisioner]}]` |
67+
| `resources` | Local Path Provisioner resource requests & limits | `{}` |
68+
| `rbac.create` | If true, create & use RBAC resources | `true` |
69+
| `serviceAccount.create` | If true, create the Local Path Provisioner service account | `true` |
70+
| `serviceAccount.name` | Name of the Local Path Provisioner service account to use or create | `nil` |
71+
| `nodeSelector` | Node labels for Local Path Provisioner pod assignment | `{}` |
72+
| `tolerations` | Node taints to tolerate | `[]` |
73+
| `affinity` | Pod affinity | `{}` |
74+
| `configmap.setup` | Configuration of script to execute setup operations on each node | #!/bin/sh<br>while getopts "m:s:p:" opt<br>do<br>&emsp;case $opt in <br>&emsp;&emsp;p)<br>&emsp;&emsp;absolutePath=$OPTARG<br>&emsp;&emsp;;;<br>&emsp;&emsp;s)<br>&emsp;&emsp;sizeInBytes=$OPTARG<br>&emsp;&emsp;;;<br>&emsp;&emsp;m)<br>&emsp;&emsp;volMode=$OPTARG<br>&emsp;&emsp;;;<br>&emsp;esac<br>done<br>mkdir -m 0777 -p ${absolutePath} |
75+
| `configmap.teardown` | Configuration of script to execute teardown operations on each node | #!/bin/sh<br>while getopts "m:s:p:" opt<br>do<br>&emsp;case $opt in <br>&emsp;&emsp;p)<br>&emsp;&emsp;absolutePath=$OPTARG<br>&emsp;&emsp;;;<br>&emsp;&emsp;s)<br>&emsp;&emsp;sizeInBytes=$OPTARG<br>&emsp;&emsp;;;<br>&emsp;&emsp;m)<br>&emsp;&emsp;volMode=$OPTARG<br>&emsp;&emsp;;;<br>&emsp;esac<br>done<br>rm -rf ${absolutePath} |
76+
| `configmap.name` | configmap name | `local-path-config` |
77+
| `configmap.helperPod` | helper pod yaml file | apiVersion: v1<br>kind: Pod<br>metadata:<br>&emsp;name: helper-pod<br>spec:<br>&emsp;containers:<br>&emsp;- name: helper-pod<br>&emsp;&emsp;image: busybox |
78+
79+
80+
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
81+
82+
```console
83+
$ helm install ./deploy/chart/ --name local-path-storage --namespace local-path-storage --set storageClass.provisionerName=rancher.io/local-path
84+
```
85+
86+
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the
87+
chart. For example,
88+
89+
```console
90+
$ helm install --name local-path-storage --namespace local-path-storage ./deploy/chart/ -f values.yaml
91+
```
92+
93+
> **Tip**: You can use the default [values.yaml](values.yaml)
94+
95+
## RBAC
96+
97+
By default the chart will install the recommended RBAC roles and rolebindings.
98+
99+
You need to have the flag `--authorization-mode=RBAC` on the api server. See the following document for how to enable
100+
[RBAC](https://kubernetes.io/docs/admin/authorization/rbac/).
101+
102+
To determine if your cluster supports RBAC, run the following command:
103+
104+
```console
105+
$ kubectl api-versions | grep rbac
106+
```
107+
108+
If the output contains "beta", you may install the chart with RBAC enabled (see below).
109+
110+
### Enable RBAC role/rolebinding creation
111+
112+
To enable the creation of RBAC resources (On clusters with RBAC). Do the following:
113+
114+
```console
115+
$ helm install ./deploy/chart/ --name local-path-storage --namespace local-path-storage --set rbac.create=true
116+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
You can create a hostpath-backed persistent volume with a persistent volume claim like this:
2+
3+
apiVersion: v1
4+
kind: PersistentVolumeClaim
5+
metadata:
6+
name: local-path-pvc
7+
spec:
8+
accessModes:
9+
- ReadWriteOnce
10+
storageClassName: {{ .Values.storageClass.name }}
11+
resources:
12+
requests:
13+
storage: 2Gi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "local-path-provisioner.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "local-path-provisioner.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "local-path-provisioner.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "local-path-provisioner.labels" -}}
38+
app.kubernetes.io/name: {{ include "local-path-provisioner.name" . }}
39+
helm.sh/chart: {{ include "local-path-provisioner.chart" . }}
40+
app.kubernetes.io/instance: {{ .Release.Name }}
41+
{{- if .Chart.AppVersion }}
42+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
43+
{{- end }}
44+
app.kubernetes.io/managed-by: {{ .Release.Service }}
45+
{{- end -}}
46+
47+
{{/*
48+
Create the name of the service account to use.
49+
*/}}
50+
{{- define "local-path-provisioner.serviceAccountName" -}}
51+
{{- if .Values.serviceAccount.create -}}
52+
{{ default (include "local-path-provisioner.fullname" .) .Values.serviceAccount.name }}
53+
{{- else -}}
54+
{{ default "default" .Values.serviceAccount.name }}
55+
{{- end -}}
56+
{{- end -}}
57+
58+
{{/*
59+
Create the name of the provisioner to use.
60+
*/}}
61+
{{- define "local-path-provisioner.provisionerName" -}}
62+
{{- if .Values.storageClass.provisionerName -}}
63+
{{- printf .Values.storageClass.provisionerName -}}
64+
{{- else -}}
65+
cluster.local/{{ template "local-path-provisioner.fullname" . -}}
66+
{{- end -}}
67+
{{- end -}}
68+
69+
{{- define "local-path-provisioner.secret" }}
70+
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.privateRegistry.registryUrl (printf "%s:%s" .Values.privateRegistry.registryUser .Values.privateRegistry.registryPasswd | b64enc) | b64enc }}
71+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{- if .Values.rbac.create -}}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ include "local-path-provisioner.fullname" . }}
6+
labels:
7+
{{ include "local-path-provisioner.labels" . | indent 4 }}
8+
rules:
9+
- apiGroups: [""]
10+
resources: ["nodes", "persistentvolumeclaims", "configmaps"]
11+
verbs: ["get", "list", "watch"]
12+
- apiGroups: [""]
13+
resources: ["endpoints", "persistentvolumes", "pods"]
14+
verbs: ["*"]
15+
- apiGroups: [""]
16+
resources: ["events"]
17+
verbs: ["create", "patch"]
18+
- apiGroups: ["storage.k8s.io"]
19+
resources: ["storageclasses"]
20+
verbs: ["get", "list", "watch"]
21+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.rbac.create -}}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRoleBinding
4+
metadata:
5+
name: {{ include "local-path-provisioner.fullname" . }}
6+
labels:
7+
{{ include "local-path-provisioner.labels" . | indent 4 }}
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: ClusterRole
11+
name: {{ template "local-path-provisioner.fullname" . }}
12+
subjects:
13+
- kind: ServiceAccount
14+
name: {{ template "local-path-provisioner.serviceAccountName" . }}
15+
namespace: {{ .Release.Namespace }}
16+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ .Values.configmap.name }}
5+
labels:
6+
{{ include "local-path-provisioner.labels" . | indent 4 }}
7+
data:
8+
config.json: |-
9+
{
10+
"nodePathMap": {{ .Values.nodePathMap | toPrettyJson | nindent 8 }}
11+
}
12+
setup: |-
13+
{{ .Values.configmap.setup | nindent 4 }}
14+
teardown: |-
15+
{{ .Values.configmap.teardown | nindent 4 }}
16+
helperPod.yaml: |-
17+
apiVersion: v1
18+
kind: Pod
19+
metadata:
20+
name: helper-pod
21+
spec:
22+
containers:
23+
- name: helper-pod
24+
{{- if .Values.privateRegistry.registryUrl }}
25+
image: {{ .Values.privateRegistry.registryUrl }}/{{ .Values.helperImage.repository }}:{{ .Values.helperImage.tag }}
26+
{{- else }}
27+
image: {{ .Values.helperImage.repository }}:{{ .Values.helperImage.tag }}
28+
{{- end }}
29+
imagePullPolicy: {{ .Values.image.pullPolicy }}

0 commit comments

Comments
 (0)