What's the purpose of the default kubernetes service?

后端 未结 2 1793
醉酒成梦
醉酒成梦 2021-02-07 18:58

When you run: kubectl get svc -n default, you will have a kubernetes service with Type as ClusterIP already there.

What is the purpose of this service? Any

2条回答
  •  攒了一身酷
    2021-02-07 19:24

    It is so that every Pod within your cluster can make API requests of the Kubernetes master without having to hard-code the API URL therein. Your ~/.kube/config may very well have the "external" address of your Kubernetes master, but it makes very little sense for API traffic to leave the cluster and then re-enter the cluster for a Pod that could be co-located on the same Node. Pods are able to use the Service Account credentials injected by kubernetes, unless that Service Account feature is disabled per-Pod.

    Your application is free to make use of that functionality, too, if it wishes -- for example -- to discover any annotations on its Pod, or how many other replicas there are in its Deployment, and so forth.

    I guess the tl;dr is that for 90% of the Pods it doesn't matter, and for the remaining 10% it is super convenient.

提交回复
热议问题