• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference 2.0
  4. Kubernetes API
  5. Pod
  6. Creating a Pod

Creating a Pod

Function

This API is used to create a Pod object under a specified Namespace.

URI

POST /api/v1/namespaces/{namespace}/pods

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Mandatory

Description

pretty

No

If 'true', then the output is pretty printed.

namespace

Yes

Object name and auth scope, such as for teams and projects.

Request

Request parameters:

For the description about request parameters, see Table 3.

Example request:

{
    "apiVersion": "v1",
    "kind": "Pod",
    "metadata": {
        "labels": {
            "name": "pod-test"
        },
        "name": "pod-test"
    },
    "spec": {
        "containers": [
            {
                "image": "172.16.5.235:20202/test/nginx",
                "imagePullPolicy": "Always",
                "name": "test",
                "resources": {
                    "requests": {
                        "cpu": "100m"
                    }
                }
            }
        ],
        "imagePullSecrets": [
            {
                "name": "default-secret"
            }
        ],
        "restartPolicy": "Always"
    }
}

Response

Response parameters:

For the description about response parameters, see the parameter description in Request.

Example response:

{
    "kind": "Pod",
    "apiVersion": "v1",
    "metadata": {
        "name": "pod-test",
        "namespace": "default",
        "selfLink": "/api/v1/namespaces/default/pods/pod-test",
        "uid": "8917ec2a-fc20-11e7-9c3c-fa163eb8ad1a",
        "resourceVersion": "486125",
        "creationTimestamp": "2018-01-18T07:23:52Z",
        "labels": {
            "name": "pod-test"
        },
        "enable": true
    },
    "spec": {
        "volumes": [
            {
                "name": "default-token-512lg",
                "secret": {
                    "secretName": "default-token-512lg",
                    "defaultMode": 384
                }
            }
        ],
        "containers": [
            {
                "name": "test",
                "image": "172.16.5.235:20202/test/nginx",
                "resources": {
                    "requests": {
                        "cpu": "100m"
                    }
                },
                "volumeMounts": [
                    {
                        "name": "default-token-512lg",
                        "readOnly": true,
                        "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
                    }
                ],
                "terminationMessagePath": "/dev/termination-log",
                "terminationMessagePolicy": "File",
                "imagePullPolicy": "Always"
            }
        ],
        "restartPolicy": "Always",
        "terminationGracePeriodSeconds": 30,
        "dnsPolicy": "ClusterFirst",
        "serviceAccountName": "default",
        "serviceAccount": "default",
        "securityContext": {},
        "imagePullSecrets": [
            {
                "name": "default-secret"
            }
        ],
        "schedulerName": "default-scheduler"
    },
    "status": {
        "phase": "Pending",
        "qosClass": "Burstable"
    }
}

Status Code

Table 2 describes the status code of this API.

Table 2 Status code

Status Code

Description

201

This operation succeeds, and a Pod resource object is returned.

For the description about status codes, see section Status Codes.