deploy the csi driver hostpath to kubernetes n windows docker

Rmag Breaking News

We have been trying to find ways to get volumesnaphot working on a kubernetes deployment on Windows Docker, but it has always failed us as it is Windows underlying kubernetes.

We found that minikube was using https://github.com/kubernetes-csi/csi-driver-host-path so we started to look at how to deploy that into our environment.

It took a little finagling using a wsl2 container as the deployment needed a linux runtime to do the deployment. Anyway here are the steps we took.

deployment

Start a wsl2 container such as ubuntu that has docker integration enabled via Terminal and issue the following commands

git clone https://github.com/kubernetes-csi/csi-driver-host-path.git
cd csi-driver-host-path/
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/release-6.3/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/release-6.3/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/release-6.3/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v6.3.3/deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v6.3.3/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml
deploy/kubernetes-latest/deploy.sh

When all is finished issue the following for sanity checks

kubectl get volumesnapshotclass

returns

NAME DRIVER DELETIONPOLICY AGE
csi-hostpath-snapclass hostpath.csi.k8s.io Delete 24h
kubectl get pods -n kube-system

check for similar

NAME READY STATUS RESTARTS AGE

snapshot-controller-59db5f898f-dj8ct 1/1 Running 0 24h
snapshot-controller-59db5f898f-z2p59 1/1 Running 0 24h
storage-provisioner 1/1 Running 67 (15d ago) 111d

kubectl get pods -n default

check for similar

NAME READY STATUS RESTARTS AGE
csi-hostpath-socat-0 1/1 Running 0 24h
csi-hostpathplugin-0 8/8 Running 0 24h
kubectl get volumesnapshotclass

check for similar

NAME DRIVER DELETIONPOLICY AGE
csi-hostpath-snapclass hostpath.csi.k8s.io Delete 24h

Testing

The following describe shows how to test and validate it is working

cd csi-driver-host-path/
kubens default
kubectl apply -f examples/csi-app.yaml

check it is running

kubectl get pod my-csi-app

returns similar to

NAME READY STATUS RESTARTS AGE
my-csi-app 1/1 Running 0 24h

Test File

Add a file to the file system

kubectl exec -it my-csi-app — touch data/hello-world

Check CSI Host

kubectl exec -it csi-hostpathplugin-0 -c hostpath — find / -name hello-world

should return similar to

/var/lib/kubelet/pods/4afdb0c6-9166-4f32-9e9f-686ad3b3ad31/volumes/kubernetes.io~csi/pvc-9ce19ec7-99ff-484f-acd9-d5158e1efa67/mount/hello-world
/csi-data-dir/7f3fae05-f52c-11ee-9c3e-1a6977443d45/hello-world

We will expand further on how to use this in a later article.

Leave a Reply

Your email address will not be published. Required fields are marked *