Recently when practicing kubernetes , I found there is no doc and example specifically explaining how to use cinder correctly in kubernetes.
So how to setup cinder to be used in kubernetes ?
Recently when practicing kubernetes , I found there is no doc and example specifically explaining how to use cinder correctly in kubernetes.
So how to setup cinder to be used in kubernetes ?
On
Thanks a lot for your great share!
The solution works for me (K8S 1.14.3, OpenStack Queen), and I just added snippets of parameter/volumeMounts/volume like below:
Parameter:
- --cloud-provider=openstack
- --cloud-config=/etc/kubernetes/cloud-config
volumeMounts:
-- mountPath: /etc/kubernetes/cloud-config
name: cloud
readOnly: true
volume:
-- hostPath:
path: /etc/kubernetes/cloud.conf
type: FileOrCreate
name: cloud
I did some experiment and worked out how to setup cinder with kubernetes. Just find a suitable to document and share.
Preparation
Background
From my investigation, component
kube-controller-manageris responsible for loading volume plugins and related in Kubernetes. So we could make cinder available by adjustingkube-controller-managerconfiguration.Steps
cloud.conffile to contain your openstack credsPrepare your openstack creds and saved as a file , for example
/etc/kubernetes/cloud.confin kubernetes control panel whichkube-controller-managerlocates. The following is example forcloud.confMost could be found from your
stackrcfile. Andca-fileitem is optional, depending on if your openstack auth url ishttporhttpskube-controller-managerstart configurationThis link is a full detail options for
kube-controller-manager(https://kubernetes.io/docs/admin/kube-controller-manager/)Actually we should add two extra parameters based on your current one
There are mainly two ways to start
kube-controller-manager: 1) using systemd 2) using static pod .Just one tips, if you are using static pod for
kube-controller-manager, make sure you have mount all files such as cloud.conf or openstack ca file into your container.Verification
We will create a storageclass, and use this storageclass to create persistent volume dynamically.
standard:demo-sc.yml:
Using command
kubectl create -f demo-sc.ymlto create and using commandkubectl get scto verify if it created correctlydemo-pvc.yml:
Creating PVC by
kubectl create -f demo-pvc.ymlAnd now checking by command
kubectl get pvcAnd in openstack environment, checking by command
cinder list | grep pvc-5dd3d62e-9204-11e7-bc43-fa163e0e0379So now StorageClass is working well using Cinder in Kubernetes.