From 4cab280d21a1f31453f3270ff95aa8283931f739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Piotr=20C=C5=82apa?= Date: Thu, 10 Mar 2022 10:47:47 +0100 Subject: [PATCH] fix paths --- k8s-socketcan-daemonset.yaml | 13 ++++++++++--- socketcan.go | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/k8s-socketcan-daemonset.yaml b/k8s-socketcan-daemonset.yaml index 2f61795..7f55339 100644 --- a/k8s-socketcan-daemonset.yaml +++ b/k8s-socketcan-daemonset.yaml @@ -22,9 +22,9 @@ spec: - sh - -c - chroot /root/ modprobe vcan || { chroot /root/ apt-get install -y linux-modules-extra-$(uname -r) && chroot /root/ modprobe vcan; } && echo Succesfully installed and loaded the vcan kernel module; - chroot /root/ mkdir -p /var/run/k8s-socketcan/ && echo Succesfully created the /var/run/k8s-socketcan/ folder; - chroot /root/ mknod /var/run/k8s-socketcan/fakedev b 1 1 && echo Succesfully created the /var/run/k8s-socketcan/fakedev device; - for path in /var/run/containerd/containerd.sock /var/snap/microk8s/common/run/containerd.sock /run/k3s/containerd/containerd.sock; do [ -S /root/$path ] && chroot /root/ ln -sfn $path /var/run/k8s-socketcan/containerd.sock && echo "Found containerd socket in $path" && break; done; + mknod /var/run/k8s-socketcan/fakedev b 1 1 && echo Succesfully created the /var/run/k8s-socketcan/fakedev device; + for path in /root/var/run/containerd/containerd.sock /root/var/snap/microk8s/common/run/containerd.sock /root/run/k3s/containerd/containerd.sock; do [ -S $path ] && ln -sfn $path /var/run/k8s-socketcan/containerd.sock && echo "Found containerd socket in $path" && break; done; + #tail -f /dev/null securityContext: privileged: true capabilities: @@ -32,8 +32,13 @@ spec: volumeMounts: - name: root mountPath: /root + - name: var-run-k8s-socketcan + mountPath: /var/run/k8s-socketcan containers: - name: k8s-socketcan + # image: busybox + # command: [ 'sh' ] + # args: [ '-c', 'exec tail -f /dev/null' ] image: ghcr.io/collabora/k8s-socketcan:latest env: - name: SOCKETCAN_DEVICES @@ -48,6 +53,8 @@ spec: - name: device-plugin mountPath: /var/lib/kubelet/device-plugins volumes: + - name: var-run-k8s-socketcan + emptyDir: {} - name: device-plugin hostPath: path: /var/lib/kubelet/device-plugins diff --git a/socketcan.go b/socketcan.go index ca64ace..6e4d1fc 100644 --- a/socketcan.go +++ b/socketcan.go @@ -56,7 +56,7 @@ func (scl SocketCANLister) NewPlugin(kind string) dpm.PluginInterface { // Device plugin class const ( - fakeDevicePath = "/root/var/run/k8s-socketcan/fakedev" + fakeDevicePath = "/var/run/k8s-socketcan/fakedev" ) type VCANDevicePlugin struct { @@ -156,7 +156,7 @@ func (VCANDevicePlugin) GetPreferredAllocation(ctx context.Context, in *pluginap // and keep checking all containers to look for this sentinel device. After we find one, we // inject the network interface into it's namespace. func (p *VCANDevicePlugin) interfaceCreator() { - client, err := containerd.New("/root/var/run/k8s-socketcan/containerd.sock") + client, err := containerd.New("/var/run/k8s-socketcan/containerd.sock") if err != nil { glog.V(3).Info("Failed to connect to containerd") panic(err)