更新时间:2022-04-18 GMT+08:00
分享

创建Pod

功能介绍

该API用于在指定Namespace下创建一个Pod对象。

URI

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

表1 描述该API的参数。

表1 参数描述

参数

是否必选

描述

pretty

No

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

namespace

Yes

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

请求消息

请求参数:

请求参数的详细描述请参见表3

请求示例:

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

响应消息

响应参数:

响应参数的详细描述请参见请求消息

响应示例:

{
    "kind": "Pod",
    "apiVersion": "v1",
    "metadata": {
        "name": "pod-test",
        "namespace": "development",
        "selfLink": "/api/v1/namespaces/development/pods/pod-test",
        "uid": "6f4ed218-b737-4466-981e-be231a631718",
        "resourceVersion": "10203",
        "creationTimestamp": "2021-10-14T01:47:36Z",
        "labels": {
            "name": "pod-test"
        },
        "annotations": {
            "kubernetes.io/psp": "psp-global"
        }
    },
    "spec": {
        "volumes": [
            {
                "name": "default-token-ddq7k",
                "secret": {
                    "secretName": "default-token-ddq7k",
                    "defaultMode": 420
                }
            }
        ],
        "containers": [
            {
                "name": "test",
                "image": "nginx:alpine",
                "resources": {
                    "requests": {
                        "cpu": "100m"
                    }
                },
                "volumeMounts": [
                    {
                        "name": "default-token-ddq7k",
                        "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",
        "tolerations": [
            {
                "key": "node.kubernetes.io/not-ready",
                "operator": "Exists",
                "effect": "NoExecute",
                "tolerationSeconds": 300
            },
            {
                "key": "node.kubernetes.io/unreachable",
                "operator": "Exists",
                "effect": "NoExecute",
                "tolerationSeconds": 300
            }
        ],
        "priority": 0,
        "dnsConfig": {
            "options": [
                {
                    "name": "single-request-reopen",
                    "value": ""
                },
                {
                    "name": "timeout",
                    "value": "2"
                }
            ]
        },
        "enableServiceLinks": true,
        "preemptionPolicy": "PreemptLowerPriority"
    },
    "status": {
        "phase": "Pending",
        "qosClass": "Burstable"
    }
}

状态码

表2描述API的状态码。

表2 状态码

状态码

描述

201

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

异常状态码请参见状态码

分享:

    相关文档

    相关产品

close