doc-exports/docs/cci/api-ref/cci_02_0011.html
Dong, Qiu Jian 21dca87c32 CCI API initial upload
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>
2024-10-14 11:16:04 +00:00

86 lines
6.3 KiB
HTML

<a name="cci_02_0011"></a><a name="cci_02_0011"></a>
<h1 class="topictitle1">Getting Started</h1>
<div id="body1509018940525"><div class="section" id="cci_02_0011__section142673304107"><h4 class="sectiontitle">Overview</h4><p id="cci_02_0011__p1188213511416">You can call APIs to create a pod. An Nginx image is used as an example to show how you can create a pod.</p>
<p id="cci_02_0011__p299212244251">The Nginx image is from the open-source image center, and the container uses 1 vCPU and 2 GiB of memory.</p>
<p id="cci_02_0011__p17275144331218">For details about how to call APIs, see <a href="cci_02_0009.html">Calling APIs</a>.</p>
</div>
<div class="section" id="cci_02_0011__section114621034191316"><h4 class="sectiontitle">Procedure</h4><ol id="cci_02_0011__ol1847673481313"><li id="cci_02_0011__li19475133411130">Call the API described in <a href="createCciV2Namespace.html">Creating a Namespace</a> to create a namespace.</li><li id="cci_02_0011__li164755345132">Call the API described in <a href="createYangtseV2NamespacedNetwork.html">Creating a Network</a> to create a network, and associate the network with a VPC and subnet.</li><li id="cci_02_0011__li147613491318">Call the API described in <a href="createCciV2NamespacedPod.html">Creating a Pod</a> to create an Nginx pod.</li></ol>
</div>
<div class="section" id="cci_02_0011__section680742610404"><h4 class="sectiontitle">Creating an Nginx Pod</h4><ol id="cci_02_0011__ol2092913277172"><li id="cci_02_0011__li92724315583"><span>Call the API described in <a href="createCciV2Namespace.html">Creating a Namespace</a> to create a namespace.</span><p><pre class="screen" id="cci_02_0011__screen17329324121211">{
"apiVersion": "cci/v2",
"kind": "Namespace",
"metadata": {
"name": "namespace-test"
}
}</pre>
<p id="cci_02_0011__p1030175113357">You must specify the following parameters:</p>
<ul id="cci_02_0011__ul4612528173616"><li id="cci_02_0011__li761212813368"><strong id="cci_02_0011__b13796184222">name</strong>: namespace name.</li></ul>
</p></li><li id="cci_02_0011__li793342619596"><span>Call the API described in <a href="createYangtseV2NamespacedNetwork.html">Creating a Network</a> to create a network, and associate the network with a VPC and subnet.</span><p><pre class="screen" id="cci_02_0011__screen117365151516">{
"apiVersion": "yangtse/v2",
"kind": "Network",
"metadata": {
"annotations": {
"yangtse.io/domain-id": "51ed88507a244b6eb36270c0250fcc96",
"yangtse.io/project-id": "a81f079abca74e83b47af9a586048b24"
},
"name": "test-network",
"namespace": "namespace-test"
},
"spec": {
"networkType": "underlay_neutron",
"securityGroups": [
"470b6a8f-612e-4284-a788-c6900ac32fce"
],
"subnets": [
{
"subnetID": "c6dd31e3-d217-4b31-bb60-eb30322c75b8"
}
]
}
}</pre>
<p id="cci_02_0011__p1991516010460">You must specify the following parameters:</p>
<ul id="cci_02_0011__ul1521851864612"><li id="cci_02_0011__li1421841820464"><strong id="cci_02_0011__b133251752102519">name</strong>: name of a network object.</li><li id="cci_02_0011__li10958181914465"><strong id="cci_02_0011__b181961551804">securityGroups</strong>: security group ID, which can be obtained on the <strong id="cci_02_0011__b3936119917"></strong><strong id="cci_02_0011__b693619191116"></strong><strong id="cci_02_0011__b1268491142219">Security Groups</strong> page.</li><li id="cci_02_0011__li2689143044612"><strong id="cci_02_0011__b638811419286">yangtse.io/domain-id</strong>: account ID, which can be obtained by following the procedure in <a href="cci_02_1002.html">Obtaining an Account ID</a>.</li><li id="cci_02_0011__li14426143814467"><strong id="cci_02_0011__b19305843294">yangtse.io/project-id</strong>: project ID, which can be obtained by following the procedure in <a href="cci_02_1001.html">Obtaining a Project ID</a>.</li><li id="cci_02_0011__li570204120491"><strong id="cci_02_0011__b126331235175219">subnetID</strong>: ID of the subnet in the VPC, which can be obtained on the VPC console or by calling the API for querying subnets.</li></ul>
</p></li><li id="cci_02_0011__li567211611164"><span>Call the API described in <a href="createCciV2NamespacedPod.html">Creating a Pod</a> to create an Nginx pod.</span><p><p id="cci_02_0011__p1785127151612">In this example, a pod whose name is <strong id="cci_02_0011__b1168112371361">nginx</strong> and specifications are set to 1 vCPU and 2 GiB of memory will be created from the open-source image nginx:stable-alpine-perl. After the API is called, CCI creates a container running nginx.</p>
<p id="cci_02_0011__p17651304562"></p>
<p id="cci_02_0011__p12542085615"></p>
<pre class="screen" id="cci_02_0011__screen263102815410">{
"apiVersion": "cci/v2",
"kind": "Pod",
"metadata": {
"name": "nginx"
},
"spec": {
"containers": [
{
"image": "nginx:stable-alpine-perl",
"name": "container-0",
"resources": {
"limits": {
"cpu": "1",
"memory": "2Gi"
},
"requests": {
"cpu": "1",
"memory": "2Gi"
}
}
}
],
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
]
}
}</pre>
<p id="cci_02_0011__p158031145154217">You must specify the following parameters:</p>
<ul id="cci_02_0011__ul28031645154218"><li id="cci_02_0011__li780354515427"><strong id="cci_02_0011__b7817191091018">name</strong>: pod name</li><li id="cci_02_0011__li17803174512426"><strong id="cci_02_0011__b194759232101">containers</strong>: container information<ul id="cci_02_0011__ul1080344515422"><li id="cci_02_0011__li88038459427"><strong id="cci_02_0011__b1968193371015">image</strong>: image used to create containers</li><li id="cci_02_0011__li85149165467">name: container name</li><li id="cci_02_0011__li78031745174212"><strong id="cci_02_0011__b13171115931018">resources.limits</strong>: resource limits for a container. The resources used by a container cannot exceed the limits.</li><li id="cci_02_0011__li67391753465"><strong id="cci_02_0011__b15837143118119">resources.requests</strong>: resources requested by a container</li></ul>
</li></ul>
<p id="cci_02_0011__p1280312455426">After the pod is created, you can view it on the CCI console.</p>
<p id="cci_02_0011__p5803945104215"><span><img id="cci_02_0011__image18777181420403" src="en-us_image_0000001874007888.png"></span></p>
</p></li></ol>
</div>
</div>