Kubernetes Daily Task Aug 10 Turn on CSI!


Userlevel 7
Badge +10

 

As you might have guessed we eventually will be playing around with Kasten. So we need to turn on the CSI hostpath driver and snapshotting in Minikube. 

 

We will first take a look at all of the addons available:

 

minikube addons list

Now we will enable the two ones that we need;

 

 

minikube addons enable csi-hostpath-driver 

and then

minikube addons enable volumesnapshots

and

 

 

The CSI local hostpath dirver will allow us to dynamically allocate storage. We need to change the default storage class to the hostpath driver.

 

First we can check if it is installed:

 

kubectl get sc

 

 

First lets take off the default storage class status for standard, make sure that you are in bash (type bash)

kubectl patch storageclass standard -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'

and now make the csi-hostpath-sc the default

 

kubectl patch storageclass csi-hostpath-sc -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

 

Now lets test this out to make sure we can grab storage with a small nginx setup:

Create the namespace

kubectl create ns nginx

Now copy and paste the following:

cat <<EOF | kubectl apply -f -

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nginxpvcclaim
namespace: nginx
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
---
kind: Pod
apiVersion: v1
metadata:
name: nginxwebsite
namespace: nginx
labels:
run: nginx
spec:
volumes:
- name: storage
persistentVolumeClaim:
claimName: nginxpvcclaim
containers:
- name: nginxwebsite
image: nginx
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: storage
EOF

Wait until the pod is running:

 

kubectl get pods -n nginx

 

If it is running then it probably got the storage that it needed :)

We can check that with a 

kubectl get pvc -n nginx

The pvc is in a bound state which means that it is good

 

 

 

That is it for today. We have storage that we can automatically allocate and we also have the snapshotter ready for some Kasten fun in the future!


12 comments

Userlevel 7
Badge +7

😎 great.

Have to do the steps from the last days to catch up….

The step-by-step guidiance is great. 👍🏼

Userlevel 7
Badge +8

Yes! Another lab.  Time to get this one done and ready for the next one. 👍🏼

Userlevel 7
Badge +8

Just an FYI for these commands the enable has to go before the addon name -

minikube addons csi-hostpath-driver enable and then minikube addons volumesnapshots enable

should be:

minikube addons enable csi-hostpath-driver and minikube addons enable volumesnapshots

Userlevel 7
Badge +8

Cannot seem to get the CSI driver to enable.  Snapshot is fine. ☹️

Get this -

 Exiting due to MK_ADDON_ENABLE: run callbacks: running callbacks: [waiting for kubernetes.io/minikube-addons=csi-hostpath-driver pods: timed out waiting for the condition]

Userlevel 7
Badge +8

Weird!  Started the Ingress addon and then the CSI one enabled.  Well at least I can continue now. 🤣

Userlevel 1

Hello everyone.

I’m ok with te configurations.

I’m using Rancher Desktop and I’ve installed external snapshotter and hostpath CSI driver, then I patched the default sc, then I’ve created the app following the instructions and everything is ok.

Thanks.

 

Userlevel 7
Badge +10

Cannot seem to get the CSI driver to enable.  Snapshot is fine. ☹️

Get this -

 Exiting due to MK_ADDON_ENABLE: run callbacks: running callbacks: [waiting for kubernetes.io/minikube-addons=csi-hostpath-driver pods: timed out waiting for the condition]

I think that might be a minikube bug, I have seen that before, investigated, done nothing then it just worked :)

Userlevel 7
Badge +10

Just an FYI for these commands the enable has to go before the addon name -

minikube addons csi-hostpath-driver enable and then minikube addons volumesnapshots enable

should be:

minikube addons enable csi-hostpath-driver and minikube addons enable volumesnapshots

speed typing or…. this could be part of the fun? :)  Hint always look at the screenshots too. This time though it was me rushing things :)

Userlevel 7
Badge +10

One more thing folks, I have changed the original instructions as well to downgrade the kubernetes version otherwise it will use the latest that might not yet be supported with Kasten when we get to it later on.

So this command can be used to redo your cluster (practice makes perfect) 

minikube delete



minikube start --kubernetes-version=1.22.4

You will then need to redo the tasks.

 

Also if you want more power you can change the cup and mem as well, for example:

 

 minikube stop
minikube config set memory 8192
minikube config set cpus 4
minikube start

 

Userlevel 4
Badge

@Geoff Burke I had some time today to go over all these Kube Tasks. Great job! I’m all caught up now. Thanks!

Userlevel 7
Badge +8

@Geoff BurkeI had some time today to go over all these Kube Tasks. Great job! I’m all caught up now. Thanks!

Nice to see you finally caught up. 😜

Userlevel 7
Badge +5

+1 @Geoff Burke! thank you for sharing your knowledge with us...

Comment