-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# This exposes the hostpath's Unix domain csi.sock as a TCP port to the | ||
# outside world. The mapping from Unix domain socket to TCP is done | ||
# by socat. | ||
# | ||
# This is useful for testing with csi-sanity or csc. | ||
|
||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: hostpath-service | ||
spec: | ||
type: NodePort | ||
selector: | ||
app: csi-hostpath-socat | ||
ports: | ||
- port: 10000 # fixed port inside the pod, dynamically allocated port outside | ||
--- | ||
kind: StatefulSet | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: csi-hostpath-socat | ||
spec: | ||
serviceName: "csi-hostpath-socat" | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: csi-hostpath-socat | ||
template: | ||
metadata: | ||
labels: | ||
app: csi-hostpath-socat | ||
spec: | ||
affinity: | ||
podAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: app | ||
operator: In | ||
values: | ||
- csi-hostpathplugin | ||
topologyKey: kubernetes.io/hostname | ||
containers: | ||
- name: socat | ||
image: alpine/socat:1.0.3 | ||
args: | ||
- tcp-listen:10000,fork,reuseaddr | ||
- unix-connect:/csi/csi.sock | ||
volumeMounts: | ||
- mountPath: /csi | ||
name: socket-dir | ||
volumes: | ||
- hostPath: | ||
path: /var/lib/kubelet/plugins/csi-hostpath | ||
type: DirectoryOrCreate | ||
name: socket-dir |