Skip to content

Commit 0d63b05

Browse files
committed
deploy: expose csi.sock outside of the cluster
Tools like csi-sanity and csc have to connect to the CSI driver. This can be achieved by exposing the csi.sock as a TCP service with forwarding handled by socat.
1 parent 0c78385 commit 0d63b05

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

deploy/kubernetes-1.13/deploy-hostpath.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ done
122122
# Wait until all pods are running. We have to make some assumptions
123123
# about the deployment here, otherwise we wouldn't know what to wait
124124
# for: the expectation is that we run attacher, provisioner,
125-
# snapshotter and hostpath plugin in the default namespace.
125+
# snapshotter, socat and hostpath plugin in the default namespace.
126126
cnt=0
127-
while [ $(kubectl get pods 2>/dev/null | grep '^csi-hostpath.* Running ' | wc -l) -lt 4 ]; do
127+
while [ $(kubectl get pods 2>/dev/null | grep '^csi-hostpath.* Running ' | wc -l) -lt 5 ]; do
128128
if [ $cnt -gt 30 ]; then
129129
echo "Running pods:"
130130
kubectl describe pods
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This exposes the hostpath's Unix domain csi.sock as a TCP port to the
2+
# outside world. The mapping from Unix domain socket to TCP is done
3+
# by socat.
4+
#
5+
# This is useful for testing with csi-sanity or csc.
6+
7+
apiVersion: v1
8+
kind: Service
9+
metadata:
10+
name: hostpath-service
11+
spec:
12+
type: NodePort
13+
selector:
14+
app: csi-hostpath-socat
15+
ports:
16+
- port: 10000 # fixed port inside the pod, dynamically allocated port outside
17+
---
18+
kind: StatefulSet
19+
apiVersion: apps/v1
20+
metadata:
21+
name: csi-hostpath-socat
22+
spec:
23+
serviceName: "csi-hostpath-socat"
24+
replicas: 1
25+
selector:
26+
matchLabels:
27+
app: csi-hostpath-socat
28+
template:
29+
metadata:
30+
labels:
31+
app: csi-hostpath-socat
32+
spec:
33+
affinity:
34+
podAffinity:
35+
requiredDuringSchedulingIgnoredDuringExecution:
36+
- labelSelector:
37+
matchExpressions:
38+
- key: app
39+
operator: In
40+
values:
41+
- csi-hostpathplugin
42+
topologyKey: kubernetes.io/hostname
43+
containers:
44+
- name: socat
45+
image: alpine/socat:1.0.3
46+
args:
47+
- tcp-listen:10000,fork,reuseaddr
48+
- unix-connect:/csi/csi.sock
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)