Skip to content

Commit 500c26e

Browse files
committed
Add deployment without external-attacher and with CSIDriver
1 parent 4b2c735 commit 500c26e

9 files changed

+491
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The deployment for Kubernetes 1.15 uses CSI 1.0 and thus is
2+
incompatible with Kubernetes < 1.13.
3+
4+
The sidecars depend on 1.15 API changes for migration and resizing,
5+
and 1.14 API changes for CSIDriver and CSINode.
6+
7+
This deployment does not use external-attacher sidecar, it creates
8+
CSIDriver instance that tells Kubernetes not to use attach
9+
(ControllerPublishVolume) at all.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../util/deploy-hostpath-no-attacher.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: storage.k8s.io/v1beta1
2+
kind: CSIDriver
3+
metadata:
4+
name: hostpath.csi.k8s.io
5+
spec:
6+
attachRequired: false
7+
podInfoOnMount: false
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.1.0
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
volumeMounts:
49+
- mountPath: /csi
50+
name: socket-dir
51+
volumes:
52+
- hostPath:
53+
path: /var/lib/kubelet/plugins/csi-hostpath
54+
type: DirectoryOrCreate
55+
name: socket-dir
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: csi-hostpath-snapshotter
5+
labels:
6+
app: csi-hostpath-snapshotter
7+
spec:
8+
selector:
9+
app: csi-hostpath-snapshotter
10+
ports:
11+
- name: dummy
12+
port: 12345
13+
14+
---
15+
kind: StatefulSet
16+
apiVersion: apps/v1
17+
metadata:
18+
name: csi-hostpath-snapshotter
19+
spec:
20+
serviceName: "csi-hostpath-snapshotter"
21+
replicas: 1
22+
selector:
23+
matchLabels:
24+
app: csi-hostpath-snapshotter
25+
template:
26+
metadata:
27+
labels:
28+
app: csi-hostpath-snapshotter
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+
serviceAccount: csi-snapshotter
41+
containers:
42+
- name: csi-snapshotter
43+
image: quay.io/k8scsi/csi-snapshotter:v1.2.0
44+
args:
45+
- -v=5
46+
- --csi-address=/csi/csi.sock
47+
- --connection-timeout=15s
48+
volumeMounts:
49+
- mountPath: /csi
50+
name: socket-dir
51+
volumes:
52+
- hostPath:
53+
path: /var/lib/kubelet/plugins/csi-hostpath
54+
type: DirectoryOrCreate
55+
name: socket-dir
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# WARNING: this is only for testing purposes. Do not install in a production
2+
# cluster.
3+
#
4+
# This exposes the hostpath's Unix domain csi.sock as a TCP port to the
5+
# outside world. The mapping from Unix domain socket to TCP is done
6+
# by socat.
7+
#
8+
# This is useful for testing with csi-sanity or csc.
9+
10+
apiVersion: v1
11+
kind: Service
12+
metadata:
13+
name: hostpath-service
14+
spec:
15+
type: NodePort
16+
selector:
17+
app: csi-hostpath-socat
18+
ports:
19+
- port: 10000 # fixed port inside the pod, dynamically allocated port outside
20+
---
21+
kind: StatefulSet
22+
apiVersion: apps/v1
23+
metadata:
24+
name: csi-hostpath-socat
25+
spec:
26+
serviceName: "csi-hostpath-socat"
27+
replicas: 1
28+
selector:
29+
matchLabels:
30+
app: csi-hostpath-socat
31+
template:
32+
metadata:
33+
labels:
34+
app: csi-hostpath-socat
35+
spec:
36+
affinity:
37+
podAffinity:
38+
requiredDuringSchedulingIgnoredDuringExecution:
39+
- labelSelector:
40+
matchExpressions:
41+
- key: app
42+
operator: In
43+
values:
44+
- csi-hostpathplugin
45+
topologyKey: kubernetes.io/hostname
46+
containers:
47+
- name: socat
48+
image: alpine/socat:1.0.3
49+
args:
50+
- tcp-listen:10000,fork,reuseaddr
51+
- unix-connect:/csi/csi.sock
52+
volumeMounts:
53+
- mountPath: /csi
54+
name: socket-dir
55+
volumes:
56+
- hostPath:
57+
path: /var/lib/kubelet/plugins/csi-hostpath
58+
type: DirectoryOrCreate
59+
name: socket-dir
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: snapshot.storage.k8s.io/v1alpha1
2+
kind: VolumeSnapshotClass
3+
metadata:
4+
name: csi-hostpath-snapclass
5+
snapshotter: hostpath.csi.k8s.io

0 commit comments

Comments
 (0)