Skip to content

Commit 3515b1a

Browse files
authored
Merge pull request #97 from pohly/kubernetes-1.16
Kubernetes 1.16 + ephemeral inline volumes
2 parents df74c85 + 39398f1 commit 3515b1a

File tree

15 files changed

+447
-10
lines changed

15 files changed

+447
-10
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@ Follow the following example to create a volume from a volume snapshot:
343343
> ```
344344
345345
## Inline ephemeral support
346-
As of version 1.15 of Kubernetes, the CSI Hostpath driver (starting with version 1.0.1) now includes support for inline ephemeral volume. This means that a volume can be specified directly inside a pod spec without the need to use a persistent volume object.
347-
Find out how to enable or create a CSI inline driver [here](https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html)
346+
The CSI Hostpath driver (starting with version 1.2.0) now includes support for inline ephemeral volumes. This means that a volume can be specified directly inside a pod spec without the need to use a persistent volume object.
347+
Find out how to enable or create a CSI driver with support for such volumes [here](https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html)
348348
349-
To test this feature on Kubernetes 1.15, redeploy the CSI Hostpath plugin YAML by updating the `hostpath` container to use the inline ephemeral mode by setting the `ephemeral` flag, of the driver binary, to true as shown in the following setup:
349+
To test this feature on Kubernetes 1.15 (and only with that release), redeploy the CSI Hostpath plugin YAML by updating the `hostpath` container to use the inline ephemeral mode by setting the `ephemeral` flag, of the driver binary, to true as shown in the following setup:
350350
351351
```yaml
352352
kind: DaemonSet
@@ -369,9 +369,8 @@ spec:
369369
370370
```
371371
Notice the addition of the `ephemeral=true` flag used in the `args:` block in the previous snippet.
372-
This is an intermediate solution for Kubernetes 1.15. Kubernetes 1.16 will provide [additional
373-
information to the driver](https://github.com/kubernetes/kubernetes/pull/79983) which makes it
374-
possible to use the normal deployment for both inline ephemeral volumes and persistent volumes.
372+
This is an intermediate solution for Kubernetes 1.15. With Kubernetes 1.16 and later, the normal
373+
deployment supports both inline ephemeral volumes and persistent volumes.
375374

376375
Once the driver plugin has been deployed, it can be tested by deploying a simple pod which has an inline volume specified in the spec:
377376

deploy/kubernetes-1.13/hostpath/csi-hostpath-plugin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ spec:
6363
name: csi-data-dir
6464

6565
- name: hostpath
66-
image: quay.io/k8scsi/hostpathplugin:v1.2.0-rc6
66+
image: quay.io/k8scsi/hostpathplugin:v1.2.0-rc8
6767
args:
6868
- "--drivername=hostpath.csi.k8s.io"
6969
- "--v=5"

deploy/kubernetes-1.14/hostpath/csi-hostpath-plugin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ spec:
6363
name: csi-data-dir
6464

6565
- name: hostpath
66-
image: quay.io/k8scsi/hostpathplugin:v1.2.0-rc6
66+
image: quay.io/k8scsi/hostpathplugin:v1.2.0-rc8
6767
args:
6868
- "--drivername=hostpath.csi.k8s.io"
6969
- "--v=5"

deploy/kubernetes-1.15/hostpath/csi-hostpath-plugin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ spec:
6363
name: csi-data-dir
6464

6565
- name: hostpath
66-
image: quay.io/k8scsi/hostpathplugin:v1.2.0-rc6
66+
image: quay.io/k8scsi/hostpathplugin:v1.2.0-rc8
6767
args:
6868
- "--drivername=hostpath.csi.k8s.io"
6969
- "--v=5"

deploy/kubernetes-1.16/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The deployment for Kubernetes 1.16 enables ephemeral inline volumes via
2+
its CSIDriverInfo and thus is incompatible with Kubernetes < 1.16
3+
because the `VolumeLifecycleModes` field is rejected by those release.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../util/deploy-hostpath.sh
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: csi-hostpath-attacher
5+
labels:
6+
app: csi-hostpath-attacher
7+
spec:
8+
selector:
9+
app: csi-hostpath-attacher
10+
ports:
11+
- name: dummy
12+
port: 12345
13+
14+
---
15+
kind: StatefulSet
16+
apiVersion: apps/v1
17+
metadata:
18+
name: csi-hostpath-attacher
19+
spec:
20+
serviceName: "csi-hostpath-attacher"
21+
replicas: 1
22+
selector:
23+
matchLabels:
24+
app: csi-hostpath-attacher
25+
template:
26+
metadata:
27+
labels:
28+
app: csi-hostpath-attacher
29+
spec:
30+
affinity:
31+
podAffinity:
32+
requiredDuringSchedulingIgnoredDuringExecution:
33+
- labelSelector:
34+
matchExpressions:
35+
- key: app
36+
operator: In
37+
values:
38+
- csi-hostpathplugin
39+
topologyKey: kubernetes.io/hostname
40+
serviceAccountName: csi-attacher
41+
containers:
42+
- name: csi-attacher
43+
image: quay.io/k8scsi/csi-attacher:v1.2.0
44+
args:
45+
- --v=5
46+
- --csi-address=/csi/csi.sock
47+
volumeMounts:
48+
- mountPath: /csi
49+
name: socket-dir
50+
51+
volumes:
52+
- hostPath:
53+
path: /var/lib/kubelet/plugins/csi-hostpath
54+
type: DirectoryOrCreate
55+
name: socket-dir
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: storage.k8s.io/v1beta1
2+
kind: CSIDriver
3+
metadata:
4+
name: hostpath.csi.k8s.io
5+
spec:
6+
# Supports persistent and ephemeral inline volumes.
7+
volumeLifecycleModes:
8+
- Persistent
9+
- Ephemeral
10+
# To determine at runtime which mode a volume uses, pod info and its
11+
# "csi.storage.k8s.io/ephemeral" entry are needed.
12+
podInfoOnMount: true
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Service defined here, plus serviceName below in StatefulSet,
2+
# are needed only because of condition explained in
3+
# https://github.com/kubernetes/kubernetes/issues/69608
4+
5+
kind: Service
6+
apiVersion: v1
7+
metadata:
8+
name: csi-hostpathplugin
9+
labels:
10+
app: csi-hostpathplugin
11+
spec:
12+
selector:
13+
app: csi-hostpathplugin
14+
ports:
15+
- name: dummy
16+
port: 12345
17+
---
18+
kind: StatefulSet
19+
apiVersion: apps/v1
20+
metadata:
21+
name: csi-hostpathplugin
22+
spec:
23+
serviceName: "csi-hostpathplugin"
24+
# One replica only:
25+
# Host path driver only works when everything runs
26+
# on a single node. We achieve that by starting it once and then
27+
# co-locate all other pods via inter-pod affinity
28+
replicas: 1
29+
selector:
30+
matchLabels:
31+
app: csi-hostpathplugin
32+
template:
33+
metadata:
34+
labels:
35+
app: csi-hostpathplugin
36+
spec:
37+
hostNetwork: true
38+
containers:
39+
- name: node-driver-registrar
40+
image: quay.io/k8scsi/csi-node-driver-registrar:v1.1.0
41+
lifecycle:
42+
preStop:
43+
exec:
44+
command: ["/bin/sh", "-c", "rm -rf /registration/csi-hostpath /registration/csi-hostpath-reg.sock"]
45+
args:
46+
- --v=5
47+
- --csi-address=/csi/csi.sock
48+
- --kubelet-registration-path=/var/lib/kubelet/plugins/csi-hostpath/csi.sock
49+
securityContext:
50+
privileged: true
51+
env:
52+
- name: KUBE_NODE_NAME
53+
valueFrom:
54+
fieldRef:
55+
apiVersion: v1
56+
fieldPath: spec.nodeName
57+
volumeMounts:
58+
- mountPath: /csi
59+
name: socket-dir
60+
- mountPath: /registration
61+
name: registration-dir
62+
- mountPath: /csi-data-dir
63+
name: csi-data-dir
64+
65+
- name: hostpath
66+
image: quay.io/k8scsi/hostpathplugin:v1.2.0-rc8
67+
args:
68+
- "--drivername=hostpath.csi.k8s.io"
69+
- "--v=5"
70+
- "--endpoint=$(CSI_ENDPOINT)"
71+
- "--nodeid=$(KUBE_NODE_NAME)"
72+
env:
73+
- name: CSI_ENDPOINT
74+
value: unix:///csi/csi.sock
75+
- name: KUBE_NODE_NAME
76+
valueFrom:
77+
fieldRef:
78+
apiVersion: v1
79+
fieldPath: spec.nodeName
80+
securityContext:
81+
privileged: true
82+
ports:
83+
- containerPort: 9898
84+
name: healthz
85+
protocol: TCP
86+
livenessProbe:
87+
failureThreshold: 5
88+
httpGet:
89+
path: /healthz
90+
port: healthz
91+
initialDelaySeconds: 10
92+
timeoutSeconds: 3
93+
periodSeconds: 2
94+
volumeMounts:
95+
- mountPath: /csi
96+
name: socket-dir
97+
- mountPath: /var/lib/kubelet/pods
98+
mountPropagation: Bidirectional
99+
name: mountpoint-dir
100+
- mountPath: /var/lib/kubelet/plugins
101+
mountPropagation: Bidirectional
102+
name: plugins-dir
103+
- mountPath: /csi-data-dir
104+
name: csi-data-dir
105+
106+
- name: liveness-probe
107+
volumeMounts:
108+
- mountPath: /csi
109+
name: socket-dir
110+
image: quay.io/k8scsi/livenessprobe:v1.1.0
111+
args:
112+
- --csi-address=/csi/csi.sock
113+
- --connection-timeout=3s
114+
- --health-port=9898
115+
116+
volumes:
117+
- hostPath:
118+
path: /var/lib/kubelet/plugins/csi-hostpath
119+
type: DirectoryOrCreate
120+
name: socket-dir
121+
- hostPath:
122+
path: /var/lib/kubelet/pods
123+
type: DirectoryOrCreate
124+
name: mountpoint-dir
125+
- hostPath:
126+
path: /var/lib/kubelet/plugins_registry
127+
type: Directory
128+
name: registration-dir
129+
- hostPath:
130+
path: /var/lib/kubelet/plugins
131+
type: Directory
132+
name: plugins-dir
133+
- hostPath:
134+
# 'path' is where PV data is persisted on host.
135+
# using /tmp is also possible while the PVs will not available after plugin container recreation or host reboot
136+
path: /var/lib/csi-hostpath-data/
137+
type: DirectoryOrCreate
138+
name: csi-data-dir
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: csi-hostpath-provisioner
5+
labels:
6+
app: csi-hostpath-provisioner
7+
spec:
8+
selector:
9+
app: csi-hostpath-provisioner
10+
ports:
11+
- name: dummy
12+
port: 12345
13+
14+
---
15+
kind: StatefulSet
16+
apiVersion: apps/v1
17+
metadata:
18+
name: csi-hostpath-provisioner
19+
spec:
20+
serviceName: "csi-hostpath-provisioner"
21+
replicas: 1
22+
selector:
23+
matchLabels:
24+
app: csi-hostpath-provisioner
25+
template:
26+
metadata:
27+
labels:
28+
app: csi-hostpath-provisioner
29+
spec:
30+
affinity:
31+
podAffinity:
32+
requiredDuringSchedulingIgnoredDuringExecution:
33+
- labelSelector:
34+
matchExpressions:
35+
- key: app
36+
operator: In
37+
values:
38+
- csi-hostpathplugin
39+
topologyKey: kubernetes.io/hostname
40+
serviceAccountName: csi-provisioner
41+
containers:
42+
- name: csi-provisioner
43+
image: quay.io/k8scsi/csi-provisioner:v1.3.0
44+
args:
45+
- -v=5
46+
- --csi-address=/csi/csi.sock
47+
- --connection-timeout=15s
48+
- --feature-gates=Topology=true
49+
volumeMounts:
50+
- mountPath: /csi
51+
name: socket-dir
52+
volumes:
53+
- hostPath:
54+
path: /var/lib/kubelet/plugins/csi-hostpath
55+
type: DirectoryOrCreate
56+
name: socket-dir

0 commit comments

Comments
 (0)