How does "type: LoadBalancer" creates external Load Balancer in Kubernetes?

7/29/2018

How does Kubernetes knows what external cloud provider on it is running?

Is there any specific service running in Master which finds out if the Kubernetes Cluster running in AWS or Google Cloud?

Even if it is able to find out it is AWS or Google, from where does it take the credentials to create the external AWS/Google Load Balancers? Do we have to configure the credentials somewhere so that it picks it from there and creates the external load balancer?

-- karthikeayan
amazon-web-services
aws-load-balancer
elastic-load-balancer
google-kubernetes-engine
kubernetes

1 Answer

7/29/2018

When installing Kubernetes cloud provider flag, you must specify the --cloud-provider=aws flag on a variety of components.

kube-controller-manager - this is the component which interacts with the cloud API when cloud specific requests are made. It runs "loops" which ensure that any cloud provider request is completed. So when you request an Service of Type=LoadBalancer, the controller-manager is the thing that checks and ensures this was provisioned

kube-apiserver - this simply ensure the cloud APIs are exposed, like for persistent volumes

kubelet - ensures thats when workloads are provisioned on nodes. This is especially the case for things like persistent storage EBS volumes.

Do we have to configure the credentials somewhere so that it picks it from there and creates the external load balancer?

All the above components should be able to query the required cloud provider APIs. Generally this is done using IAM roles which ensure the actual node itself has the permissions. If you take a look at the kops documentation, you'll see examples of the IAM roles assigned to masters and workers to give those nodes permissions to query and make API calls.

It should be noted that this model is changing shortly, to move all cloud provider logic into a dedicated cloud-controller-manager which will have to be pre-configured when installing the cluster.

-- jaxxstorm
Source: StackOverflow