<p>How does Kubernetes knows what external cloud provider on it is running?</p>

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

<p>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?</p>

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

<p><strong><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/#options" rel="nofollow noreferrer">kube-controller-manager</a></strong> - 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</p>

<p><strong><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/#options" rel="nofollow noreferrer">kube-apiserver</a></strong> - this simply ensure the cloud APIs are exposed, like for persistent volumes</p>

<p><strong><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/#options" rel="nofollow noreferrer">kubelet</a></strong> - ensures thats when workloads are provisioned on nodes. This is especially the case for things like persistent storage EBS volumes.</p>

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

<p>All the above components should be able to query the required cloud provider APIs. Generally this is done using <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html" rel="nofollow noreferrer">IAM roles</a> which ensure the actual node itself has the permissions. If you take a look at the <a href="https://github.com/kubernetes/kops/blob/master/docs/iam_roles.md" rel="nofollow noreferrer">kops</a> 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.</p>

<p>It should be noted that this model is changing shortly, to move all cloud provider logic into a dedicated <a href="https://kubernetes.io/docs/tasks/administer-cluster/running-cloud-controller/" rel="nofollow noreferrer">cloud-controller-manager</a> which will have to be pre-configured when installing the cluster.</p>
