doc-exports/docs/cce/api-ref/cce_02_0087.html
Dong, Qiu Jian 3336ba8df7 CCE API for v1.23
Reviewed-by: gtema <artem.goncharov@gmail.com>
Co-authored-by: Dong, Qiu Jian <qiujiandong1@huawei.com>
Co-committed-by: Dong, Qiu Jian <qiujiandong1@huawei.com>
2022-11-10 12:48:59 +00:00

207 lines
16 KiB
HTML

<a name="cce_02_0087"></a><a name="cce_02_0087"></a>
<h1 class="topictitle1">How to Use ELB in a Cluster</h1>
<div id="body1498621882386"><p id="cce_02_0087__p5575330319390">This section describes how to use the Elastic Load Balancer (ELB) in a cluster created by CCE.</p>
<div class="section" id="cce_02_0087__section50156865193415"><h4 class="sectiontitle">Procedure</h4><div class="p" id="cce_02_0087__p184231648766">Create a Service. <div class="note" id="cce_02_0087__note11622519165956"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="cce_02_0087__p37493813165956">Before enabling sticky session, ensure that the following conditions are met:</p>
<ul id="cce_02_0087__ul1138349517031"><li id="cce_02_0087__li5546555417031">The workload protocol is TCP.</li><li id="cce_02_0087__li732857617050">Anti-affinity has been configured between pods of the workload. That is, all pods of the workload are deployed on different nodes.</li></ul>
</div></div>
</div>
<div class="p" id="cce_02_0087__p317482512919">Automatically creating an ELB:<pre class="screen" id="cce_02_0087__screen1399824616596">apiVersion: v1
kind: Service
metadata:
annotations:
kubernetes.io/elb.class: union
kubernetes.io/session-affinity-mode: SOURCE_IP
kubernetes.io/elb.subnet-id: 5083f225-9bf8-48fa-9c8b-67bd9693c4c0
kubernetes.io/elb.autocreate: "{\"type\":\"public\",\"bandwidth_name\":\"cce-bandwidth-1551163379627\",\"bandwidth_chargemode\":\"traffic\",\"bandwidth_size\":5,\"bandwidth_sharetype\":\"PER\",\"eip_type\":\"5_bgp\",\"name\":\"james\"}"
labels:
app: nginx
name: nginx
spec:
externalTrafficPolicy: Local
ports:
- name: service0
port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancer</pre>
</div>
<div class="p" id="cce_02_0087__p123613281796">Using an existing ELB:<pre class="screen" id="cce_02_0087__screen12340173319524">apiVersion: v1
kind: Service
metadata:
annotations:
kubernetes.io/elb.class: union
kubernetes.io/session-affinity-mode: SOURCE_IP
kubernetes.io/elb.id: 3c7caa5a-a641-4bff-801a-feace27424b6
kubernetes.io/elb.subnet-id: 5083f225-9bf8-48fa-9c8b-67bd9693c4c0
labels:
app: nginx
name: nginx
spec:
loadBalancerIP: 10.78.42.242
externalTrafficPolicy: Local
ports:
- name: service0
port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancer</pre>
</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="cce_02_0087__table1819001615355" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Key parameters</caption><thead align="left"><tr id="cce_02_0087__row1519121663519"><th align="left" class="cellrowborder" valign="top" width="34.28657134286571%" id="mcps1.3.2.5.2.4.1.1"><p id="cce_02_0087__p18191161619356">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="14.118588141185882%" id="mcps1.3.2.5.2.4.1.2"><p id="cce_02_0087__p1191141613357">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="51.594840515948405%" id="mcps1.3.2.5.2.4.1.3"><p id="cce_02_0087__p1919116161353">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="cce_02_0087__row7430236123515"><td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.2.5.2.4.1.1 "><p id="cce_02_0087__p2430336153520">kubernetes.io/elb.class</p>
</td>
<td class="cellrowborder" valign="top" width="14.118588141185882%" headers="mcps1.3.2.5.2.4.1.2 "><p id="cce_02_0087__p19430103693512">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.5.2.4.1.3 "><p id="cce_02_0087__p1380805311426">Mandatory and must be set to <span class="uicontrol" id="cce_02_0087__uicontrol16781216134315"><b>union</b></span> if an enhanced load balancer is in use.</p>
</td>
</tr>
<tr id="cce_02_0087__row15191171618357"><td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.2.5.2.4.1.1 "><p id="cce_02_0087__p204451615124716">kubernetes.io/session-affinity-mode</p>
</td>
<td class="cellrowborder" valign="top" width="14.118588141185882%" headers="mcps1.3.2.5.2.4.1.2 "><p id="cce_02_0087__p1090683224719">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.5.2.4.1.3 "><p id="cce_02_0087__p12830929125713">Optional. If sticky session is enabled, add this parameter.</p>
<p id="cce_02_0087__p16904132104710">The value <strong id="cce_02_0087__b10851032194318">SOURCE_IP</strong> indicates that listeners ensure sticky session based on source IP addresses.</p>
</td>
</tr>
<tr id="cce_02_0087__row81941516153513"><td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.2.5.2.4.1.1 "><p id="cce_02_0087__p4764162894719">kubernetes.io/elb.id</p>
</td>
<td class="cellrowborder" valign="top" width="14.118588141185882%" headers="mcps1.3.2.5.2.4.1.2 "><p id="cce_02_0087__p77621528184710">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.5.2.4.1.3 "><p id="cce_02_0087__p59344376579">Optional. This parameter is mandatory if an existing ELB is used.</p>
<p id="cce_02_0087__p416573016509">It indicates the ID of an enhanced load balancer.</p>
</td>
</tr>
<tr id="cce_02_0087__row201957167350"><td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.2.5.2.4.1.1 "><p id="cce_02_0087__p18758202864719">kubernetes.io/elb.subnet-id</p>
</td>
<td class="cellrowborder" valign="top" width="14.118588141185882%" headers="mcps1.3.2.5.2.4.1.2 "><p id="cce_02_0087__p336744055219">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.5.2.4.1.3 "><p id="cce_02_0087__p2075662814474">Optional. This parameter is mandatory only if a load balancer will be automatically created. For clusters of v1.11.7-r0 or later, this parameter can be left unspecified.</p>
</td>
</tr>
<tr id="cce_02_0087__row1719518169356"><td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.2.5.2.4.1.1 "><p id="cce_02_0087__p9754162844712">kubernetes.io/elb.autocreate</p>
</td>
<td class="cellrowborder" valign="top" width="14.118588141185882%" headers="mcps1.3.2.5.2.4.1.2 "><p id="cce_02_0087__en-us_topic_0079615000_p32706975"><a href="#cce_02_0087__table19417184671919">elb.autocreate</a> object</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.5.2.4.1.3 "><p id="cce_02_0087__p127521028194718">Optional. This parameter is mandatory if a public network load balancer will be automatically created. The system will create an enhanced load balancer and an EIP. This parameter is also mandatory if a private network load balancer will be automatically created. The system will create an enhanced load balancer.</p>
<p id="cce_02_0087__p115519391615"><strong id="cce_02_0087__b1574518310446">Example:</strong></p>
<ul id="cce_02_0087__ul286913611614"><li id="cce_02_0087__li188691936963">Value for a public network load balancer that is automatically created: "{\"type\":\"public\",\"bandwidth_name\":\"cce-bandwidth-1551163379627\",\"bandwidth_chargemode\":\"traffic\",\"bandwidth_size\":5,\"bandwidth_sharetype\":\"PER\",\"eip_type\":\"5_bgp\",\"name\":\"james\"}"</li><li id="cce_02_0087__li1686910361463">Value for a private network load balancer that is automatically created: "{\"type\":\"inner\"}"</li></ul>
</td>
</tr>
<tr id="cce_02_0087__row121515334113"><td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.2.5.2.4.1.1 "><p id="cce_02_0087__p92162033131111">loadBalancerIP</p>
</td>
<td class="cellrowborder" valign="top" width="14.118588141185882%" headers="mcps1.3.2.5.2.4.1.2 "><p id="cce_02_0087__en-us_topic_0079615000_p47822814">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.5.2.4.1.3 "><p id="cce_02_0087__p7217113331120">Private IP address of a private network load balancer or public IP address of a public network load balancer.</p>
</td>
</tr>
<tr id="cce_02_0087__row14980162901115"><td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.2.5.2.4.1.1 "><p id="cce_02_0087__p398162913117">externalTrafficPolicy</p>
</td>
<td class="cellrowborder" valign="top" width="14.118588141185882%" headers="mcps1.3.2.5.2.4.1.2 "><p id="cce_02_0087__p142173231413">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.5.2.4.1.3 "><p id="cce_02_0087__p119811329111112">Optional. If sticky session is enabled, add this parameter so requests are transferred to a fixed node. If a LoadBalancer Service with this parameter set to <strong id="cce_02_0087__b134197138450">Local</strong> is created for a workload, the workload can be accessed only when the client is installed on the same node as the server.</p>
</td>
</tr>
<tr id="cce_02_0087__row17120113981313"><td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.2.5.2.4.1.1 "><p id="cce_02_0087__p17120639161311">port</p>
</td>
<td class="cellrowborder" valign="top" width="14.118588141185882%" headers="mcps1.3.2.5.2.4.1.2 "><p id="cce_02_0087__p1120939161311">Integer</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.5.2.4.1.3 "><p id="cce_02_0087__p1120163961310">Access port that is registered on the load balancer and mapped to the cluster-internal IP address.</p>
</td>
</tr>
<tr id="cce_02_0087__row02694357138"><td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.2.5.2.4.1.1 "><p id="cce_02_0087__p627233515132">targetPort</p>
</td>
<td class="cellrowborder" valign="top" width="14.118588141185882%" headers="mcps1.3.2.5.2.4.1.2 "><p id="cce_02_0087__p19272143531318">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.5.2.4.1.3 "><p id="cce_02_0087__p8272035161316">Container port on the CCE console.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablenoborder"><a name="cce_02_0087__table19417184671919"></a><a name="table19417184671919"></a><table cellpadding="4" cellspacing="0" summary="" id="cce_02_0087__table19417184671919" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Data structure of the <strong id="cce_02_0087__b636315611450">elb.autocreate</strong> field</caption><thead align="left"><tr id="cce_02_0087__row14418174611912"><th align="left" class="cellrowborder" valign="top" width="29.727027297270276%" id="mcps1.3.2.6.2.4.1.1"><p id="cce_02_0087__p1141924611199">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="18.678132186781323%" id="mcps1.3.2.6.2.4.1.2"><p id="cce_02_0087__p1641911466191">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="51.594840515948405%" id="mcps1.3.2.6.2.4.1.3"><p id="cce_02_0087__p1941920463197">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="cce_02_0087__row194191846181915"><td class="cellrowborder" valign="top" width="29.727027297270276%" headers="mcps1.3.2.6.2.4.1.1 "><p id="cce_02_0087__p152321411112318">name</p>
</td>
<td class="cellrowborder" valign="top" width="18.678132186781323%" headers="mcps1.3.2.6.2.4.1.2 "><p id="cce_02_0087__p7419646171920">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.6.2.4.1.3 "><p id="cce_02_0087__p87791494919">Name of the load balancer that is automatically created.</p>
<p id="cce_02_0087__p9912132016296">The value is a string of 1 to 64 characters that consist of letters, digits, underscores (_), and hyphens (-).</p>
</td>
</tr>
<tr id="cce_02_0087__row142064681919"><td class="cellrowborder" valign="top" width="29.727027297270276%" headers="mcps1.3.2.6.2.4.1.1 "><p id="cce_02_0087__p20862285225">type</p>
</td>
<td class="cellrowborder" valign="top" width="18.678132186781323%" headers="mcps1.3.2.6.2.4.1.2 "><p id="cce_02_0087__p8420746101918">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.6.2.4.1.3 "><p id="cce_02_0087__p4703183013491">Network type of the load balancer.</p>
<ul id="cce_02_0087__ul152311045124913"><li id="cce_02_0087__li1523219452491"><strong id="cce_02_0087__b569141515463">public</strong>: public network load balancer.</li><li id="cce_02_0087__li19232114524918"><strong id="cce_02_0087__b1443315167463">inner</strong>: private network load balancer.</li></ul>
</td>
</tr>
<tr id="cce_02_0087__row194201046151910"><td class="cellrowborder" valign="top" width="29.727027297270276%" headers="mcps1.3.2.6.2.4.1.1 "><p id="cce_02_0087__p128042817221">bandwidth_name</p>
</td>
<td class="cellrowborder" valign="top" width="18.678132186781323%" headers="mcps1.3.2.6.2.4.1.2 "><p id="cce_02_0087__p1142084619195">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.6.2.4.1.3 "><p id="cce_02_0087__p6964103318220">Bandwidth name. The default value is <strong id="cce_02_0087__b13335121924617">cce-bandwidth-******</strong>.</p>
<p id="cce_02_0087__p1236952875020">The value is a string of 1 to 64 characters that consist of letters, digits, underscores (_), hyphens (-), and periods (.).</p>
</td>
</tr>
<tr id="cce_02_0087__row942194619199"><td class="cellrowborder" valign="top" width="29.727027297270276%" headers="mcps1.3.2.6.2.4.1.1 "><p id="cce_02_0087__p77502811221">bandwidth_chargemode</p>
</td>
<td class="cellrowborder" valign="top" width="18.678132186781323%" headers="mcps1.3.2.6.2.4.1.2 "><p id="cce_02_0087__p11421446191914">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.6.2.4.1.3 "><p id="cce_02_0087__p3178181495216">Bandwidth billing mode.</p>
<p id="cce_02_0087__p17993157195913">The value is <strong id="cce_02_0087__b267410514014">traffic</strong>, indicating that the billing is based on traffic.</p>
</td>
</tr>
<tr id="cce_02_0087__row124211046101910"><td class="cellrowborder" valign="top" width="29.727027297270276%" headers="mcps1.3.2.6.2.4.1.1 "><p id="cce_02_0087__p187492819229">bandwidth_size</p>
</td>
<td class="cellrowborder" valign="top" width="18.678132186781323%" headers="mcps1.3.2.6.2.4.1.2 "><p id="cce_02_0087__p114229463196">Integer</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.6.2.4.1.3 "><p id="cce_02_0087__p12958233152218">Bandwidth size.</p>
</td>
</tr>
<tr id="cce_02_0087__row1942224601917"><td class="cellrowborder" valign="top" width="29.727027297270276%" headers="mcps1.3.2.6.2.4.1.1 "><p id="cce_02_0087__p16731228202214">bandwidth_sharetype</p>
</td>
<td class="cellrowborder" valign="top" width="18.678132186781323%" headers="mcps1.3.2.6.2.4.1.2 "><p id="cce_02_0087__p84221246111913">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.6.2.4.1.3 "><p id="cce_02_0087__p188864421731">Bandwidth sharing mode.</p>
<ul id="cce_02_0087__ul51872412"><li id="cce_02_0087__li1118714414"><strong id="cce_02_0087__b165472015185110">PER</strong>: dedicated bandwidth.</li><li id="cce_02_0087__li2011971349"><strong id="cce_02_0087__b820421695110">WHOLE</strong>: shared bandwidth.</li></ul>
</td>
</tr>
<tr id="cce_02_0087__row1242219461193"><td class="cellrowborder" valign="top" width="29.727027297270276%" headers="mcps1.3.2.6.2.4.1.1 "><p id="cce_02_0087__p1972102872220">eip_type</p>
</td>
<td class="cellrowborder" valign="top" width="18.678132186781323%" headers="mcps1.3.2.6.2.4.1.2 "><p id="cce_02_0087__p132201811174611">String</p>
</td>
<td class="cellrowborder" valign="top" width="51.594840515948405%" headers="mcps1.3.2.6.2.4.1.3 "><p id="cce_02_0087__p11956103372218">EIP type.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="cce_02_0083.html">Appendix</a></div>
</div>
</div>