<p>From <a href="https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/" rel="noreferrer">assess cluster api</a>, i know that the pod in the cluster can using the clusterIp service kubernetes.default.svc to access the api server, but i am curious about how it works. </p>

<p>The pod in the cluster would only try to access the clusterip defined in the kubernetes.default.svc, the clusterip is nothing different with the other cluster ip except the svc's name.</p>

<p>So how can a http request to the specific clusterip be routed to the api server, does it configured by the api server proxy when create the kubernetes.default.svc?</p>

user2992389
<blockquote>
  <p>The pod in the cluster would only try to access the clusterip defined in the kubernetes.default.svc, the clusterip is nothing different with the other cluster ip except the svc's name.</p>
</blockquote>

<p>Absolutely correct</p>

<blockquote>
  <p>So how can a http request to the specific clusterip be routed to the api server, does it configured by the api server proxy when create the kubernetes.default.svc?</p>
</blockquote>

<p>This magic happens via <code>kube-proxy</code>, which <em>usually</em> delegates down to <code>iptables</code>, although I think it more recent kubernetes installs they are using ipvs to give a lot more control over ... well, almost everything. The <code>kube-proxy</code> receives its instructions from the API informing it of any changes, which it applies to the individual Nodes to keep the world in sync.</p>

<p>If you have access to the Nodes, you can run <code>sudo iptables -t nat -L -n</code> and see all the <code>KUBE-SERVICE-*</code> rules that are defined -- usually with helpful comments, even -- and see how they are mapped from the <code>ClusterIP</code> down to the Pod's IP of the Pods which match the selector on the <code>Service</code></p>
