• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference
  4. PodTemplate (Native Kubernetes APIs)
  5. Creating a PodTemplate

Creating a PodTemplate

Function

This API is used to create a PodTemplate object.

URI

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

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 2.

Example request:

{ 
   "apiVersion": "v1", 
     "kind": "PodTemplate", 
     "metadata": { 
         "name": "nginx", 
         "creationTimestamp": null, 
         "labels": { 
             "app": "nginx" 
         } 
     }, 
     "template": { 
         "spec": { 
             "containers": [ 
                 { 
                     "name": "redis", 
                     "image": "redis", 
                     "ports": [ 
                         { 
                             "containerPort": 80, 
                             "protocol": "TCP" 
                         } 
                     ], 
                     "resources": {}, 
                     "terminationMessagePath": "/dev/termination-log", 
                     "imagePullPolicy": "Always" 
                 } 
             ], 
             "restartPolicy": "Always", 
             "terminationGracePeriodSeconds": 30, 
             "dnsPolicy": "ClusterFirst" 
         } 
     } 
 }

Response

Response parameters:

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

Example response:

{ 
   "kind": "PodTemplate", 
   "apiVersion": "v1", 
   "metadata": { 
     "name": "nginx", 
     "namespace": "default", 
     "selfLink": "/api/v1/namespaces/default/podtemplates/nginx", 
     "uid": "123ffeec-5a11-11e6-b444-286ed488fafe", 
     "resourceVersion": "202244", 
     "creationTimestamp": "2016-08-04T07:00:04Z", 
     "labels": { 
       "app": "nginx" 
     } 
   }, 
   "template": { 
     "metadata": { 
       "creationTimestamp": null 
     }, 
     "spec": { 
       "containers": [ 
         { 
           "name": "redis", 
           "image": "redis", 
           "ports": [ 
             { 
               "containerPort": 80, 
               "protocol": "TCP" 
             } 
           ], 
           "resources": {}, 
           "terminationMessagePath": "/dev/termination-log", 
           "imagePullPolicy": "Always" 
         } 
       ], 
       "restartPolicy": "Always", 
       "terminationGracePeriodSeconds": 30, 
       "dnsPolicy": "ClusterFirst", 
       "securityContext": {} 
     } 
   } 
 }

Status Code

Table 2 describes the status code of this API.

Table 2 Status code

Status Code

Description

201

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

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