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 ?
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-manager
is responsible for loading volume plugins and related in Kubernetes. So we could make cinder available by adjustingkube-controller-manager
configuration.Steps
cloud.conf
file to contain your openstack credsPrepare your openstack creds and saved as a file , for example
/etc/kubernetes/cloud.conf
in kubernetes control panel whichkube-controller-manager
locates. The following is example forcloud.conf
Most could be found from your
stackrc
file. Andca-file
item is optional, depending on if your openstack auth url ishttp
orhttps
kube-controller-manager
start 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.yml
to create and using commandkubectl get sc
to verify if it created correctlydemo-pvc.yml:
Creating PVC by
kubectl create -f demo-pvc.yml
And now checking by command
kubectl get pvc
And in openstack environment, checking by command
cinder list | grep pvc-5dd3d62e-9204-11e7-bc43-fa163e0e0379
So now StorageClass is working well using Cinder in Kubernetes.