Skip to content

Commit cb8f3ca

Browse files
authored
Merge pull request #282 from pohly/single-pod-deployments
single pod deployments
2 parents 5443144 + 194132f commit cb8f3ca

32 files changed

+1238
-106
lines changed

deploy/kubernetes-1.18-test/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The deployment for Kubernetes 1.18 uses CSIDriver v1 and
2+
thus is incompatible with Kubernetes < 1.18.
3+
4+
It uses separate pods and service accounts for each sidecar. This is
5+
not how they would normally be deployed. It gets done this way to test
6+
that the individual RBAC rules are correct.

deploy/kubernetes-1.18-test/deploy.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../util/deploy-hostpath.sh
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../util/destroy-hostpath.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: storage.k8s.io/v1
2+
kind: CSIDriver
3+
metadata:
4+
name: hostpath.csi.k8s.io
5+
labels:
6+
app.kubernetes.io/instance: hostpath.csi.k8s.io
7+
app.kubernetes.io/part-of: csi-driver-host-path
8+
app.kubernetes.io/name: hostpath.csi.k8s.io
9+
app.kubernetes.io/component: csi-driver
10+
spec:
11+
# Supports persistent and ephemeral inline volumes.
12+
volumeLifecycleModes:
13+
- Persistent
14+
- Ephemeral
15+
# To determine at runtime which mode a volume uses, pod info and its
16+
# "csi.storage.k8s.io/ephemeral" entry are needed.
17+
podInfoOnMount: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
kind: StatefulSet
2+
apiVersion: apps/v1
3+
metadata:
4+
name: csi-hostpathplugin
5+
labels:
6+
app.kubernetes.io/instance: hostpath.csi.k8s.io
7+
app.kubernetes.io/part-of: csi-driver-host-path
8+
app.kubernetes.io/name: csi-hostpathplugin
9+
app.kubernetes.io/component: plugin
10+
spec:
11+
serviceName: "csi-hostpathplugin"
12+
# One replica only:
13+
# Host path driver only works when everything runs
14+
# on a single node. We achieve that by starting it once and then
15+
# co-locate all other pods via inter-pod affinity
16+
replicas: 1
17+
selector:
18+
matchLabels:
19+
app.kubernetes.io/instance: hostpath.csi.k8s.io
20+
app.kubernetes.io/part-of: csi-driver-host-path
21+
app.kubernetes.io/name: csi-hostpathplugin
22+
app.kubernetes.io/component: plugin
23+
template:
24+
metadata:
25+
labels:
26+
app.kubernetes.io/instance: hostpath.csi.k8s.io
27+
app.kubernetes.io/part-of: csi-driver-host-path
28+
app.kubernetes.io/name: csi-hostpathplugin
29+
app.kubernetes.io/component: plugin
30+
spec:
31+
serviceAccountName: csi-external-health-monitor-controller
32+
containers:
33+
- name: hostpath
34+
image: k8s.gcr.io/sig-storage/hostpathplugin:v1.6.2
35+
args:
36+
- "--drivername=hostpath.csi.k8s.io"
37+
- "--v=5"
38+
- "--endpoint=$(CSI_ENDPOINT)"
39+
- "--nodeid=$(KUBE_NODE_NAME)"
40+
env:
41+
- name: CSI_ENDPOINT
42+
value: unix:///csi/csi.sock
43+
- name: KUBE_NODE_NAME
44+
valueFrom:
45+
fieldRef:
46+
apiVersion: v1
47+
fieldPath: spec.nodeName
48+
securityContext:
49+
privileged: true
50+
ports:
51+
- containerPort: 9898
52+
name: healthz
53+
protocol: TCP
54+
livenessProbe:
55+
failureThreshold: 5
56+
httpGet:
57+
path: /healthz
58+
port: healthz
59+
initialDelaySeconds: 10
60+
timeoutSeconds: 3
61+
periodSeconds: 2
62+
volumeMounts:
63+
- mountPath: /csi
64+
name: socket-dir
65+
- mountPath: /var/lib/kubelet/pods
66+
mountPropagation: Bidirectional
67+
name: mountpoint-dir
68+
- mountPath: /var/lib/kubelet/plugins
69+
mountPropagation: Bidirectional
70+
name: plugins-dir
71+
- mountPath: /csi-data-dir
72+
name: csi-data-dir
73+
- mountPath: /dev
74+
name: dev-dir
75+
76+
- name: liveness-probe
77+
volumeMounts:
78+
- mountPath: /csi
79+
name: socket-dir
80+
image: k8s.gcr.io/sig-storage/livenessprobe:v2.2.0
81+
args:
82+
- --csi-address=/csi/csi.sock
83+
- --health-port=9898
84+
85+
- name: csi-external-health-monitor-agent
86+
image: k8s.gcr.io/sig-storage/csi-external-health-monitor-agent:v0.2.0
87+
args:
88+
- "--v=5"
89+
- "--csi-address=$(ADDRESS)"
90+
env:
91+
- name: NODE_NAME
92+
valueFrom:
93+
fieldRef:
94+
fieldPath: spec.nodeName
95+
- name: ADDRESS
96+
value: /csi/csi.sock
97+
imagePullPolicy: "IfNotPresent"
98+
volumeMounts:
99+
- name: socket-dir
100+
mountPath: /csi
101+
102+
- name: csi-external-health-monitor-controller
103+
image: k8s.gcr.io/sig-storage/csi-external-health-monitor-controller:v0.2.0
104+
args:
105+
- "--v=5"
106+
- "--csi-address=$(ADDRESS)"
107+
- "--leader-election"
108+
env:
109+
- name: ADDRESS
110+
value: /csi/csi.sock
111+
imagePullPolicy: "IfNotPresent"
112+
volumeMounts:
113+
- name: socket-dir
114+
mountPath: /csi
115+
116+
- name: node-driver-registrar
117+
image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.0.1
118+
args:
119+
- --v=5
120+
- --csi-address=/csi/csi.sock
121+
- --kubelet-registration-path=/var/lib/kubelet/plugins/csi-hostpath/csi.sock
122+
securityContext:
123+
# This is necessary only for systems with SELinux, where
124+
# non-privileged sidecar containers cannot access unix domain socket
125+
# created by privileged CSI driver container.
126+
privileged: true
127+
env:
128+
- name: KUBE_NODE_NAME
129+
valueFrom:
130+
fieldRef:
131+
apiVersion: v1
132+
fieldPath: spec.nodeName
133+
volumeMounts:
134+
- mountPath: /csi
135+
name: socket-dir
136+
- mountPath: /registration
137+
name: registration-dir
138+
- mountPath: /csi-data-dir
139+
name: csi-data-dir
140+
141+
volumes:
142+
- hostPath:
143+
path: /var/lib/kubelet/plugins/csi-hostpath
144+
type: DirectoryOrCreate
145+
name: socket-dir
146+
- hostPath:
147+
path: /var/lib/kubelet/pods
148+
type: DirectoryOrCreate
149+
name: mountpoint-dir
150+
- hostPath:
151+
path: /var/lib/kubelet/plugins_registry
152+
type: Directory
153+
name: registration-dir
154+
- hostPath:
155+
path: /var/lib/kubelet/plugins
156+
type: Directory
157+
name: plugins-dir
158+
- hostPath:
159+
# 'path' is where PV data is persisted on host.
160+
# using /tmp is also possible while the PVs will not available after plugin container recreation or host reboot
161+
path: /var/lib/csi-hostpath-data/
162+
type: DirectoryOrCreate
163+
name: csi-data-dir
164+
- hostPath:
165+
path: /dev
166+
type: Directory
167+
name: dev-dir
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
labels:
15+
app.kubernetes.io/instance: hostpath.csi.k8s.io
16+
app.kubernetes.io/part-of: csi-driver-host-path
17+
app.kubernetes.io/name: csi-hostpath-socat
18+
app.kubernetes.io/component: socat
19+
spec:
20+
type: NodePort
21+
selector:
22+
app.kubernetes.io/instance: hostpath.csi.k8s.io
23+
app.kubernetes.io/part-of: csi-driver-host-path
24+
app.kubernetes.io/name: csi-hostpath-socat
25+
app.kubernetes.io/component: socat
26+
ports:
27+
- port: 10000 # fixed port inside the pod, dynamically allocated port outside
28+
---
29+
kind: StatefulSet
30+
apiVersion: apps/v1
31+
metadata:
32+
name: csi-hostpath-socat
33+
labels:
34+
app.kubernetes.io/instance: hostpath.csi.k8s.io
35+
app.kubernetes.io/part-of: csi-driver-host-path
36+
app.kubernetes.io/name: csi-hostpath-socat
37+
app.kubernetes.io/component: socat
38+
spec:
39+
serviceName: "csi-hostpath-socat"
40+
replicas: 1
41+
selector:
42+
matchLabels:
43+
app.kubernetes.io/instance: hostpath.csi.k8s.io
44+
app.kubernetes.io/part-of: csi-driver-host-path
45+
app.kubernetes.io/name: csi-hostpath-socat
46+
app.kubernetes.io/component: socat
47+
template:
48+
metadata:
49+
labels:
50+
app.kubernetes.io/instance: hostpath.csi.k8s.io
51+
app.kubernetes.io/part-of: csi-driver-host-path
52+
app.kubernetes.io/name: csi-hostpath-socat
53+
app.kubernetes.io/component: socat
54+
spec:
55+
affinity:
56+
podAffinity:
57+
requiredDuringSchedulingIgnoredDuringExecution:
58+
- labelSelector:
59+
matchExpressions:
60+
- key: app.kubernetes.io/instance
61+
operator: In
62+
values:
63+
- hostpath.csi.k8s.io
64+
topologyKey: kubernetes.io/hostname
65+
containers:
66+
- name: socat
67+
image: alpine/socat:1.0.3
68+
args:
69+
- tcp-listen:10000,fork,reuseaddr
70+
- unix-connect:/csi/csi.sock
71+
securityContext:
72+
# This is necessary only for systems with SELinux, where
73+
# non-privileged sidecar containers cannot access unix domain socket
74+
# created by privileged CSI driver container.
75+
privileged: true
76+
volumeMounts:
77+
- mountPath: /csi
78+
name: socket-dir
79+
volumes:
80+
- hostPath:
81+
path: /var/lib/kubelet/plugins/csi-hostpath
82+
type: DirectoryOrCreate
83+
name: socket-dir
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file describes how to test this deployment of the CSI hostpath driver
2+
# using the Kubernetes 1.17 E2E test suite. For details see:
3+
# https://github.com/kubernetes/kubernetes/tree/v1.17.0/test/e2e/storage/external
4+
5+
StorageClass:
6+
FromName: true
7+
SnapshotClass:
8+
FromName: true
9+
DriverInfo:
10+
Name: hostpath.csi.k8s.io
11+
SupportedSizeRange:
12+
Min: 1Mi
13+
Capabilities:
14+
block: true
15+
controllerExpansion: true
16+
exec: true
17+
multipods: true
18+
nodeExpansion: true
19+
persistence: true
20+
singleNodeVolume: true
21+
snapshotDataSource: true
22+
topology: true
23+
InlineVolumes:
24+
- shared: true

0 commit comments

Comments
 (0)