-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
local-storage-provisioner-template.yaml
98 lines (94 loc) · 2.78 KB
/
local-storage-provisioner-template.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
apiVersion: v1
kind: Template
metadata:
name: "local-storage-provisioner"
objects:
# $SERVICE_ACCOUNT must be able to manipulate with PVs
- apiVersion: v1
kind: ClusterRoleBinding
metadata:
name: local-storage:provisioner-pv-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:persistent-volume-provisioner
subjects:
- kind: ServiceAccount
name: ${SERVICE_ACCOUNT}
namespace: ${NAMESPACE}
# $SERVICE_ACCOUNT must be able to list nodes
- apiVersion: v1
kind: ClusterRoleBinding
metadata:
name: local-storage:provisioner-node-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:node
subjects:
- kind: ServiceAccount
name: ${SERVICE_ACCOUNT}
namespace: ${NAMESPACE}
# DaemonSet with provisioners
- apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: local-volume-provisioner
spec:
template:
metadata:
labels:
app: local-volume-provisioner
spec:
containers:
- env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: MY_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: VOLUME_CONFIG_NAME
value: ${CONFIGMAP}
image: ${PROVISIONER_IMAGE}
name: provisioner
securityContext:
runAsUser: 0
seLinuxOptions:
# Trump SELinux contexts of all pods that could write files to local volume - the provisioner must be able to clean their files.
level: "s0:c0.c1023"
volumeMounts:
- mountPath: /mnt/local-storage
name: local-storage
- mountPath: /etc/provisioner/config
name: provisioner-config
readOnly: true
serviceAccountName: "${SERVICE_ACCOUNT}"
volumes:
- hostPath:
path: /mnt/local-storage
name: local-storage
- configMap:
name: ${CONFIGMAP}
name: provisioner-config
parameters:
- name: SERVICE_ACCOUNT
description: Name of service account that is able to run pods as root and use HostPath volumes.
required: true
value: local-storage-admin
- name: NAMESPACE
description: Name of namespace where local provisioners run
required: true
value: local-storage
- name: CONFIGMAP
description: Name of ConfigMap with local provisioner configuration.
required: true
value: local-storage-admin
- name: PROVISIONER_IMAGE
description: Name of image with local provisioner.
required: true
value: quay.io/external_storage/local-volume-provisioner:v1.0.1