8.2 Create hostpath Storage Class

The Kubernetes cluster requires a persistent storage class for the databases to store persistent data. You can provide this with your own storage (e.g. SUSE Enterprise Storage), or use the built-in hostpath storage type. hostpath is NOT suitable for a production deployment, but it is an easy option for a minimal test deployment.

WARNING: Using the hostpath storage type on CaaS Platform

CaaS Platform is configured as a multi-node Kubernetes setup with a minimum of one master and two workers. Hostpath provisioning on CaaS Platform uses local storage on each of these nodes, therefore persistent data stored will only be available locally on the Kubernetes nodes. This impacts use cases where SUSE Cloud Foundry containers restart on a different Kubernetes worker, for example in high availability setups or update tests. If a container starts on a different worker than before it will miss its persistent data, leading to various other side effects. In addition, hostpath-provisioner uses the local root filesystem of the Kubernetes node. If it runs out of disk space your Kubernetes node won't work anymore.

Open an SSH session to your Kubernetes master node and add the argument --enable-hostpath-provisioner to /etc/kubernetes/controller-manager:

root # vim /etc/kubernetes/controller-manager 
        --enable-hostpath-provisioner \

Restart the Kubernetes controller-manager:

root # systemctl restart kube-controller-manager

Create a persistent storage class named hostpath:

root # echo '{"kind":"StorageClass","apiVersion":"storage.k8s.io/v1", "metadata":{"name":"hostpath"},"provisioner":"kubernetes.io/host-path"}' | \
kubectl create -f -

storageclass "hostpath" created

Verify that your new storage class has been created:

root # kubectl get storageclass
hostpath   kubernetes.io/host-path

Log into all of your Kubernetes nodes and create the /tmp/hostpath_pv directory, then set its permissions to read/write/execute:

root # mkdir /tmp/hostpath_pv  
root # chmod -R 0777 /tmp/hostpath_pv

See the Kubernetes document Storage Classes for detailed information on storage classes.

HINT: Log in Directly to Kubernetes Nodes

By default, SUSE CaaS Platform allows logging into the Kubernetes nodes only from the admin node. You can set up direct logins to your Kubernetes nodes from your workstation by copying the SSH keys from your admin node to your Kubernetes nodes, and then you will have password-less SSH logins. This is not a best practice for a production deployment, but will make running a test deployment a little easier.