forked from docs/doc-exports
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com> Co-authored-by: Dong, Qiu Jian <qiujiandong1@huawei.com> Co-committed-by: Dong, Qiu Jian <qiujiandong1@huawei.com>
21 lines
3.0 KiB
HTML
21 lines
3.0 KiB
HTML
<a name="cce_faq_00289"></a><a name="cce_faq_00289"></a>
|
|
|
|
<h1 class="topictitle1">What Is a Headless Service When I Create a StatefulSet?</h1>
|
|
<div id="body1595851963498"><p id="cce_faq_00289__p182891694130">The inter-pod discovery service of CCE corresponds to the headless Service of Kubernetes. Headless Services specify <strong id="cce_faq_00289__b185135415287">None</strong> for the cluster IP (spec:clusterIP) in YAML, which means no cluster IP is allocated.</p>
|
|
<div class="section" id="cce_faq_00289__section1890233754916"><h4 class="sectiontitle">Differences Between Headless Services and Common Services</h4><ul id="cce_faq_00289__ul94853375810"><li id="cce_faq_00289__li248516316589">Common Services:<p id="cce_faq_00289__p417981811313"><a name="cce_faq_00289__li248516316589"></a><a name="li248516316589"></a>One Service may be backed by multiple endpoints (pods). A client accesses the cluster IP address and the request is forwarded to the real server based on the iptables or IPVS rules to implement load balancing. For example, a Service has two endpoints, but only the Service address is returned during DNS query. The iptables or IPVS rules determine the real server that the client accesses. The client cannot access the specified endpoint.</p>
|
|
</li></ul>
|
|
<ul id="cce_faq_00289__ul3825204195813"><li id="cce_faq_00289__li9253909410">Headless Services:<p id="cce_faq_00289__p4811101844"><a name="cce_faq_00289__li9253909410"></a><a name="li9253909410"></a>When a headless Service is accessed, the actual endpoint (pod IP addresses) is returned. The headless Service points directly to each endpoint, that is, each pod has a DNS domain name. In this way, pods can access each other, achieving inter-pod discovery and access.</p>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="cce_faq_00289__section762915384541"><h4 class="sectiontitle">Headless Service Application Scenarios</h4><p id="cce_faq_00289__p8582195511214">If there is no difference between multiple pods of a workload, you can use a common Service and use the cluster kube-proxy to implement load balancing, for example, an Nginx Deployment.</p>
|
|
<p id="cce_faq_00289__p7320848181518">However, in some application scenarios, pods of a workload have different roles. For example, in a Redis cluster, each Redis pod is different. They have a master/slave relationship and need to communicate with each other. In this case, a common Service cannot access a specified pod through the cluster IP address. Therefore, you need to allow the headless Service to directly access the real IP address of the pod to implement mutual access among pods.</p>
|
|
<p id="cce_faq_00289__p209941457205">Headless Services work with <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id" target="_blank" rel="noopener noreferrer">StatefulSet</a> to deploy stateful applications, such as Redis and MySQL.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="cce_faq_00186.html">Others</a></div>
|
|
</div>
|
|
</div>
|
|
|