...
1apiVersion: v1
2kind: Namespace
3metadata:
4 name: local-path-storage
5
6---
7apiVersion: v1
8kind: ServiceAccount
9metadata:
10 name: local-path-provisioner-service-account
11 namespace: local-path-storage
12
13---
14apiVersion: rbac.authorization.k8s.io/v1
15kind: Role
16metadata:
17 name: local-path-provisioner-role
18 namespace: local-path-storage
19rules:
20 - apiGroups: [""]
21 resources: ["pods"]
22 verbs: ["get", "list", "watch", "create", "patch", "update", "delete"]
23
24---
25apiVersion: rbac.authorization.k8s.io/v1
26kind: ClusterRole
27metadata:
28 name: local-path-provisioner-role
29rules:
30 - apiGroups: [""]
31 resources: ["nodes", "persistentvolumeclaims", "configmaps", "pods", "pods/log"]
32 verbs: ["get", "list", "watch"]
33 - apiGroups: [""]
34 resources: ["persistentvolumes"]
35 verbs: ["get", "list", "watch", "create", "patch", "update", "delete"]
36 - apiGroups: [""]
37 resources: ["events"]
38 verbs: ["create", "patch"]
39 - apiGroups: ["storage.k8s.io"]
40 resources: ["storageclasses"]
41 verbs: ["get", "list", "watch"]
42
43---
44apiVersion: rbac.authorization.k8s.io/v1
45kind: RoleBinding
46metadata:
47 name: local-path-provisioner-bind
48 namespace: local-path-storage
49roleRef:
50 apiGroup: rbac.authorization.k8s.io
51 kind: Role
52 name: local-path-provisioner-role
53subjects:
54 - kind: ServiceAccount
55 name: local-path-provisioner-service-account
56 namespace: local-path-storage
57
58---
59apiVersion: rbac.authorization.k8s.io/v1
60kind: ClusterRoleBinding
61metadata:
62 name: local-path-provisioner-bind
63roleRef:
64 apiGroup: rbac.authorization.k8s.io
65 kind: ClusterRole
66 name: local-path-provisioner-role
67subjects:
68 - kind: ServiceAccount
69 name: local-path-provisioner-service-account
70 namespace: local-path-storage
71
72---
73apiVersion: apps/v1
74kind: Deployment
75metadata:
76 name: local-path-provisioner
77 namespace: local-path-storage
78spec:
79 replicas: 1
80 selector:
81 matchLabels:
82 app: local-path-provisioner
83 template:
84 metadata:
85 labels:
86 app: local-path-provisioner
87 spec:
88 serviceAccountName: local-path-provisioner-service-account
89 containers:
90 - name: local-path-provisioner
91 image: rancher/local-path-provisioner:v0.0.28
92 imagePullPolicy: IfNotPresent
93 command:
94 - local-path-provisioner
95 - --debug
96 - start
97 - --config
98 - /etc/config/config.json
99 volumeMounts:
100 - name: config-volume
101 mountPath: /etc/config/
102 env:
103 - name: POD_NAMESPACE
104 valueFrom:
105 fieldRef:
106 fieldPath: metadata.namespace
107 - name: CONFIG_MOUNT_PATH
108 value: /etc/config/
109 volumes:
110 - name: config-volume
111 configMap:
112 name: local-path-config
113
114---
115apiVersion: storage.k8s.io/v1
116kind: StorageClass
117metadata:
118 name: local-path
119provisioner: rancher.io/local-path
120volumeBindingMode: WaitForFirstConsumer
121reclaimPolicy: Delete
122
123---
124kind: ConfigMap
125apiVersion: v1
126metadata:
127 name: local-path-config
128 namespace: local-path-storage
129data:
130 config.json: |-
131 {
132 "nodePathMap":[
133 {
134 "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES",
135 "paths":["/opt/local-path-provisioner"]
136 }
137 ]
138 }
139 setup: |-
140 #!/bin/sh
141 set -eu
142 mkdir -m 0777 -p "$VOL_DIR"
143 teardown: |-
144 #!/bin/sh
145 set -eu
146 rm -rf "$VOL_DIR"
147 helperPod.yaml: |-
148 apiVersion: v1
149 kind: Pod
150 metadata:
151 name: helper-pod
152 spec:
153 priorityClassName: system-node-critical
154 tolerations:
155 - key: node.kubernetes.io/disk-pressure
156 operator: Exists
157 effect: NoSchedule
158 containers:
159 - name: helper-pod
160 image: busybox
161 imagePullPolicy: IfNotPresent
View as plain text