Creating a Pod
Function
This API is used to create a pod.
Each pod has a short lifecycle. Exercise caution when creating an independent pod. You are advised to use Deployments, StatefulSets, and jobs to create applications to ensure high availability.
Cloud Container Instance (CCI) has limitation on pod specifications. For details, see Pod Specifications in Usage Constraints.
Drivers 410.104 and 418.126 are compatible with NVIDIA GPUs. The CUDA toolkit used in your application must meet the requirements listed in Table 1. For details about the compatibility between CUDA toolkits and drivers, see CUDA Compatibility at https://www.nvidia.com.
|
NVIDIA GPU Driver Version |
CUDA Toolkit Version |
|---|---|
|
410.104 |
CUDA 10.0 (10.0.130) or earlier |
|
418.126 |
CUDA 10.1 (10.1.105) or earlier |
If a GPU-accelerated pod is selected, you need to add the cri.cci.io/gpu-driver field to metadata.annotations of the pod to specify the GPU driver version to be used. The values are as follows:
- gpu-410.104
- gpu-418.126
There are constraints on mounting OBS buckets during pod creation. For details, see Constraints on OBS Bucket Mounting.
URI
POST /api/v1/namespaces/{namespace}/pods
|
Parameter |
Description |
|---|---|
|
namespace |
Object name and auth scope, such as for teams and projects. |
|
Parameter |
Mandatory |
Description |
|---|---|---|
|
pretty |
No |
If 'true', then the output is pretty printed. |
Request
Request parameters
For the description about request parameters, see Table 2.
Example request
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"labels": {
"name": "pod-test"
},
"name": "pod-test"
},
"spec": {
"containers": [
{
"image": "redis",
"imagePullPolicy": "Always",
"name": "test",
"resources": {
"requests": {
"cpu": "0.5",
"memory": "1024Mi"
},
"limits": {
"cpu": "0.5",
"memory": "1024Mi"
}
}
}
],
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
],
"restartPolicy": "Always",
"priority": 0
}
}
An example of creating a GPU-accelerated pod:
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"labels": {
"name": "pod-test"
},
"name": "pod-test",
"annotations": {
"cri.cci.io/gpu-driver": "gpu-410.104"
}
},
"spec": {
"containers": [
{
"image": "redis",
"imagePullPolicy": "Always",
"name": "test",
"resources": {
"requests": {
"cpu": "4",
"memory": "32Gi",
"nvidia.com/gpu-tesla-v100-16GB": "1"
},
"limits": {
"cpu": "4",
"memory": "32Gi",
"nvidia.com/gpu-tesla-v100-16GB": "1"
}
}
}
],
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
],
"restartPolicy": "Always",
"priority": 0
}
}
An example of creating a pod mounted into a local volume:
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"labels": {
"app": "localvolume"
},
"name": "localvolume",
"namespace": "cci-namespace-12192721"
},
"spec": {
"containers": [
{
"command": [
"/bin/sh",
"-c",
"sleep 10000"
],
"image": "100.79.1.215:20202/paas_cci_test/redis:v1",
"imagePullPolicy": "Always",
"lifecycle": {},
"volumeMounts": [
{
"name": "innerevs123",
"mountPath": "/tmp/log"
}
],
"name": "container-0",
"resources": {
"limits": {
"cpu": "500m",
"memory": "1024Mi"
},
"requests": {
"cpu": "500m",
"memory": "1024Mi"
}
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File"
}
],
"dnsPolicy": "Default",
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
],
"restartPolicy": "Always",
"schedulerName": "default-scheduler",
"volumes": [
{
"emptyDir": {
"sizeLimit": "100Gi"
},
"name": "innerevs123"
}
],
"terminationGracePeriodSeconds": 30,
"nodeSelector": {
"node.cci.io/allowed-on-poc-dedicated-node": "sina"
},
"tolerations": [
{
"effect": "NoSchedule",
"key": "node.cci.io/allowed-on-poc-dedicated-node",
"operator": "Equal",
"value": "sina"
}
]
}
}
Response
Response parameters
For the description about response parameters, see Table 2.
Example response
{
"kind": "Pod",
"apiVersion": "v1",
"metadata": {
"name": "pod-test",
"namespace": "namespace-test",
"selfLink": "/api/v1/namespaces/namespace-test/pods/pod-test",
"uid": "8b985a27-af74-11e8-9d5d-c88d83be759f",
"resourceVersion": "5030599",
"creationTimestamp": "2018-09-03T12:26:12Z",
"labels": {
"name": "pod-test"
},
"annotations": {
"cri.cci.io/container-type": "secure-container"
},
"enable": true
},
"spec": {
"containers": [
{
"name": "test",
"image": "redis",
"resources": {
"limits": {
"cpu": "500m",
"memory": "1Gi"
},
"requests": {
"cpu": "500m",
"memory": "1Gi"
}
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "Always"
}
],
"restartPolicy": "Always",
"priority": 0,
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
],
"schedulerName": "default-scheduler",
"tolerations": [
{
"key": "node.kubernetes.io/not-ready",
"operator": "Exists",
"effect": "NoExecute",
"tolerationSeconds": 300
},
{
"key": "node.kubernetes.io/unreachable",
"operator": "Exists",
"effect": "NoExecute",
"tolerationSeconds": 300
}
]
},
"status": {
"phase": "Pending",
"qosClass": "Guaranteed"
}
}
Status Code
Table 4 describes the status code of this API.
|
Status Code |
Description |
|---|---|
|
201 |
This operation succeeds, and a Pod resource object is returned. |
For more status codes, see Status Codes.
Last Article: Pod
Next Article: Reading a Pod
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.