<p>I tried to create k8s cluster on aws using kops. </p>

<p>After create the cluster with default definition, I saw a LoadBalance has been created. </p>

<pre><code>apiVersion: kops/v1alpha2
kind: Cluster
metadata:
  name: bungee.staging.k8s.local
spec:
  api:
    loadBalancer:
      type: Public
....
</code></pre>

<p>I just wondering about the reason of creating the LoadBalancer along with cluster.</p>

<p>Appreciate !</p>

<p>In the type of cluster that kops creates the apiserver (referred to as api above, a component of the Kubernetes master, aka control plane) <em>may</em> not have a static IP address. Also, kops can create a HA (replicated) control plane, which means there <strong>will</strong> be multiple IPs where the apiserver is available.</p>

<p>The apiserver functions as a central connection hub for all other Kubernetes components, for example all the nodes connect to it but also the operator humans connect to them via kubectl. For one, these configuration files do not support multiple IP address for the apiserver (as to make use of the HA setup). Plus updating the configuration files every time the apiserver IP address(es) change would be difficult.</p>

<p>So the load balancer functions as a front for the apiserver(s) with a single, static IP address (an anycast IP with AWS/GCP). This load balancer IP is specified in the configuration files of Kubernetes components instead of actual apiserver IP(s).</p>

<p>Actually, it is also possible to solve this program by using a DNS name that resolves to IP(s) of the apiserver(s) coupled with a mechanism that keeps this record updated. This solution can't react to changes of the underlying IP(s) as fast a load balancer can, but it does save you couple of bucks plus it is slightly less likely to fail and creates less dependency on the cloud provider. This can be configured like so:</p>

<pre><code>spec:
  api:
    dns: {}
</code></pre>

<p>See <a href="https://github.com/kubernetes/kops/blob/master/docs/cluster_spec.md#api" rel="noreferrer">specification</a> for more details.</p>
