Getting Started
Overview
You can call APIs to create a workload. An Nginx image is used as an example to show how you can create a workload.
The Nginx image is from the open-source image center, and the container uses 1 vCPU and 2 GiB of memory.
For details about how to call APIs, see Calling APIs.
Procedure
- Call the API described in Creating a Namespace to create a namespace.
- Call the API described in Creating a Network to create a network, and associate the network with a VPC and subnet.
- Call the API described in Creating a Deployment to create an Nginx workload.
Creating an Nginx Workload
- Call the API described in Creating a Namespace to create a namespace.
{ "apiVersion": "cci/v2", "kind": "Namespace", "metadata": { "name": "namespace-test" } }You must specify the following parameters:
- name: namespace name.
- Call the API described in Creating a Network to create a network, and associate the network with a VPC and subnet.
{ "apiVersion": "yangtse/v2", "kind": "Network", "metadata": { "annotations": { "yangtse.io/domain-id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "yangtse.io/project-id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, "name": "test-network", "namespace": "namespace-test" }, "spec": { "networkType": "underlay_neutron", "securityGroups": [ "xxxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ], "subnets": [ { "subnetID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } ] } }You must specify the following parameters:
- name: name of a network object.
- securityGroups: security group ID, which can be obtained on the Security Groups page.
- yangtse.io/domain-id: account ID, which can be obtained by following the procedure in Obtaining an Account ID.
- yangtse.io/project-id: project ID, which can be obtained by following the procedure in Obtaining a Project ID.
- subnetID: ID of the subnet in the VPC, which can be obtained on the VPC console or by calling the API for querying subnets.
- Call the API described in Creating a Deployment to create an Nginx workload.
In this example, a workload whose name is nginx 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.
{ "kind": "Deployment", "apiVersion": "cci/v2", "metadata": { "name": "nginx", "labels": { "app": "nginx" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "nginx" } }, "template": { "metadata": { "labels": { "app": "nginx" } }, "spec": { "containers": [ { "name": "container-0", "image": "library/nginx:stable-alpine-perl", "resources": { "limits": { "cpu": "1", "memory": "2Gi" }, "requests": { "cpu": "1", "memory": "2Gi" } } } ], "imagePullSecrets": [ { "name": "imagepull-secret" } ] } } } }You must specify the following parameters:
- name: Deployment name.
- replicas: pod quantity, that is, the number of pods under the Deployment.
- selector.matchLabels: labels that are used by the Deployment to select pods. In this example, app is set to nginx under labels. The pod that has such a label will be selected by the Deployment.
- template: pod template, which defines pod configurations and specifications.
- metadata.labels: pod label.
- spec.containers: definition of a container in the pod.
- image: image used to create containers.
- resources.limits: resource limits for a container. The resources used by a container cannot exceed the limits.
- resources.requests: resources requested by a container.
After the Nginx workload is created, you can view it on the CCI console.

Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot