Kubernetes – cloud provider config for OpenStack

Kubernetes – cloud provider config for OpenStack

Time goes by and subscription end date of Kubernetes Fundamentals course by LF is closer. So I decided to dive into k8s. When I was learning about services, I run into problem that my services (type LoadBalancer) and ingress resources are not getting external IP addresses. I dug around it and found out, that these features are expecting to get external IPs from provider (AWS, OpenStack, …).

I didn’t care about external IP for LoadBalancer type of service but when I was about to test ingress I really wanted to test ingress from outside the cluster which was running in OpenStack.

I found quick hack if your k8s cluster is not configured or you can’t configure it with cloud-provider option. When I was creating service for ingress controller, I have added  externalIPs to service specification:

Then deployed ingress resource is accessible from outside of cluster.

 

But! Later on, I decided that I want it to be automatized via cloud-provider. After a few unsuccessful tries I finally figured out how to properly configure it.

Let’s prepare cloud-config creds and settings file for communication with OpenStack API:

Save it wherever you want, best place is probably  /etc/kubernetes/cloud-config.

 

If kubeadm is used to bootstrap the cluster, edit  /etc/systemd/system/kubelet.service.d/10-kubeadm.conf  add following line:

Copy  cloud-config to all workers to same directory and also edit kubelet systemd service file as above.

 

If you init and join cluster with kubeadm use following file to specify cloud-provider for kubeadm (pod network is for Calico):

and init cluster with config file  kubeadm init --config <config-above> . That’s all for kubeadm bootstraping. In other scenarions, it is necessary to add arguments to  kube-controller-manager  and  kube-apiserver :  --cloud-provider=openstack --cloud-config=/etc/kubernetes/cloud-config .

Comments are closed.