api reference · 2020. 12. 30. · 1 overview introduction to cce cloud container engine (cce) is a...

521
Cloud Container Engine API Reference Date 2018-09-19

Upload: others

Post on 10-Feb-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

  • Cloud Container Engine

    API Reference

    Date 2018-09-19

  • Contents

    1 Overview....................................................................................................................................1

    2 APIs............................................................................................................................................. 32.1 API Calling..................................................................................................................................................................................32.2 Uploading an AK/SK File.......................................................................................................................................................42.3 Creating a VPC......................................................................................................................................................................... 52.4 Creating a Key Pair................................................................................................................................................................. 52.5 Authenticating Requests....................................................................................................................................................... 62.5.1 Token Authentication......................................................................................................................................................... 62.5.2 AK/SK Authentication......................................................................................................................................................... 72.5.2.1 AK and SK Generation.................................................................................................................................................... 72.5.2.2 Request Signing Procedure............................................................................................................................................72.5.2.3 Sample Code...................................................................................................................................................................... 82.6 Obtaining Cluster UUID...................................................................................................................................................... 152.7 Constructing Requests.........................................................................................................................................................162.8 Initiating Requests................................................................................................................................................................ 182.9 Parsing Responses.................................................................................................................................................................192.10 Status Codes......................................................................................................................................................................... 20

    3 Common Parameters............................................................................................................ 243.1 Common Request Parameters.......................................................................................................................................... 243.2 Common Response Parameters....................................................................................................................................... 79

    4 Cluster and Host Management (Proprietary APIs).....................................................1184.1 Creating a Container Cluster.......................................................................................................................................... 1184.2 Adding a Node to a Container Cluster........................................................................................................................1214.3 Updating Container Cluster Information................................................................................................................... 1274.4 Deleting Nodes from a Container Cluster................................................................................................................. 1294.5 Deleting a Container Cluster.......................................................................................................................................... 1304.6 Obtaining Information About All Clusters................................................................................................................. 1314.7 Obtaining Information About a Specified Cluster...................................................................................................1444.8 Obtaining Information About All Hosts in a Specified Cluster...........................................................................1514.9 Obtaining Information About a Specified Host in a Specified Cluster............................................................ 1624.10 Obtaining Certificates for Accessing a Container Cluster.................................................................................. 170

    5 Metrics and Logs (Proprietary APIs).............................................................................. 172

    Cloud Container EngineAPI Reference Contents

    2018-09-19 ii

  • 5.1 Obtaining Cluster Monitoring Metrics........................................................................................................................ 1725.2 Obtaining Monitoring Metrics of All Nodes in a Cluster......................................................................................1785.3 Obtaining Monitoring Metrics of a Specified Cluster Node................................................................................ 1825.4 Obtaining Monitoring Metrics of All Application Instances in a Specified Namespace in a Cluster.... 1855.5 Obtaining Monitoring Metrics of a Specified Application Instance in a Specified Namespace in aCluster............................................................................................................................................................................................1905.6 Application Logs................................................................................................................................................................. 193

    6 Secret (Native Kubernetes APIs)..................................................................................... 1966.1 Creating a Secret................................................................................................................................................................ 1966.2 Deleting a Secret................................................................................................................................................................ 2066.3 Reading a Specified Secret.............................................................................................................................................. 2116.4 Replacing a Specified Secret........................................................................................................................................... 2186.5 Listing or Watching objects of kind Secret in a Specified Namespace............................................................ 2206.6 Listing or Watching objects of kind Secret................................................................................................................ 223

    7 ReplicationController (Native Kubernetes APIs).........................................................2297.1 Creating a ReplicationController................................................................................................................................... 2297.2 Deleting a ReplicationController................................................................................................................................... 2327.3 Reading a Specified ReplicationController.................................................................................................................2367.4 Replacing a Specified ReplicationController............................................................................................................. 2387.5 Replacing the Status of a Specified ReplicationController...................................................................................2417.6 Listing or Watching Objects of ReplicationController in a Specified Namespace....................................... 2437.7 Listing or Watching Objects of ReplicationController........................................................................................... 2467.8 Partially Updating a Specified ReplicationController............................................................................................. 248

    8 Service (Native Kubernetes APIs)................................................................................... 2528.1 Creating a Service...............................................................................................................................................................2528.2 Deleting a Service...............................................................................................................................................................2688.3 Reading a Specified Service............................................................................................................................................ 2698.4 Replacing a Specified Service......................................................................................................................................... 2818.5 Listing or Watching Objects of Kind Service in a Specified Namespace......................................................... 2838.6 Listing or Watching Objects of Kind Service............................................................................................................. 2868.7 Partially Updating a Specified Service.........................................................................................................................2898.8 Proxying GET Requests to a Service with Path.........................................................................................................2918.9 Proxying GET Requests to a Service............................................................................................................................. 2928.10 Proxying DELETE Requests to a Service with Path............................................................................................... 2938.11 Proxying DELETE Requests to a Service................................................................................................................... 2948.12 Proxying PUT Requests to a Service with Path...................................................................................................... 2958.13 Proxying PUT Requests to a Service.......................................................................................................................... 2968.14 Proxying POST Requests to a Service with Path................................................................................................... 2978.15 Proxying POST Requests to a Service........................................................................................................................2988.16 Proxying HEAD Requests to a Service with Path.................................................................................................. 2998.17 Proxying HEAD Requests to a Service.......................................................................................................................3008.18 Proxying OPTIONS Requests to a Service with Path........................................................................................... 301

    Cloud Container EngineAPI Reference Contents

    2018-09-19 iii

  • 8.19 Proxying OPTIONS Requests to a Service................................................................................................................3028.20 Replacing the Status of a Specified Service............................................................................................................ 303

    9 Pod (Native Kubernetes APIs)......................................................................................... 3079.1 Creating a Pod..................................................................................................................................................................... 3079.2 Deleting a Pod..................................................................................................................................................................... 3099.3 Reading a Specified Pod...................................................................................................................................................3139.4 Reading Logs of a Specified Pod................................................................................................................................... 3159.5 Replacing a Specified Pod............................................................................................................................................... 3189.6 Replacing the Status of a Specified Pod.....................................................................................................................3229.7 Listing or Watching Objects of Kind Pod in a Specified Namespace............................................................... 3259.8 Listing or Watching Objects of Kind Pod................................................................................................................... 3289.9 Partially Updating a Specified Pod............................................................................................................................... 3319.10 Proxying GET Requests to a Pod with Path............................................................................................................ 3359.11 Proxying GET Requests to a Pod.................................................................................................................................3369.12 Proxying DELETE Requests to a Pod with Path..................................................................................................... 3379.13 Proxying DELETE Requests to a Pod..........................................................................................................................3389.14 Proxying PUT Requests to a Pod with Path............................................................................................................ 3399.15 Proxying PUT Requests to a Pod.................................................................................................................................3409.16 Proxying POST Requests to a Pod with Path..........................................................................................................3419.17 Proxying POST Requests to a Pod.............................................................................................................................. 3429.18 Proxying HEAD Requests to a Pod with Path.........................................................................................................3439.19 Proxying HEAD Requests to a Pod............................................................................................................................. 3449.20 Proxying OPTIONS Requests to a Pod with Path..................................................................................................3459.21 Proxying OPTIONS Requests to a Pod...................................................................................................................... 3469.22 Connecting GET Requests to the Proxy of a Pod.................................................................................................. 3479.23 Connecting GET Requests to the Proxy of a Pod with Path.............................................................................. 3489.24 Connecting DELETE Requests to the Proxy of a Pod........................................................................................... 3499.25 Connecting DELETE Requests to the Proxy of a Pod with Path.......................................................................3509.26 Connecting PUT Requests to the Proxy of a Pod.................................................................................................. 3519.27 Connecting PUT Requests to the Proxy of a Pod with Path..............................................................................3529.28 Connecting POST Requests to the Proxy of a Pod............................................................................................... 3539.29 Connecting POST Requests to the Proxy of a Pod with Path........................................................................... 3549.30 Connecting HEAD Requests to the Proxy of a Pod.............................................................................................. 3559.31 Connecting HEAD Requests to the Proxy of a Pod with Path.......................................................................... 3569.32 Connecting OPTIONS Requests to the Proxy of a Pod....................................................................................... 3579.33 Connecting OPTIONS Requests to the Proxy of a Pod with Path................................................................... 358

    10 PodTemplate (Native Kubernetes APIs)......................................................................36010.1 Creating a PodTemplate................................................................................................................................................ 36010.2 Deleting a PodTemplate................................................................................................................................................ 36210.3 Reading a Specified PodTemplate.............................................................................................................................. 36610.4 Replacing a Specified PodTemplate........................................................................................................................... 36810.5 Listing or Watching Objects of Kind PodTemplate in a Specified Namespace...........................................371

    Cloud Container EngineAPI Reference Contents

    2018-09-19 iv

  • 10.6 Listing or Watching Objects of kind PodTemplate............................................................................................... 37310.7 Partially Updating a Specified PodTemplate.......................................................................................................... 376

    11 Namespace (Native Kubernetes APIs).........................................................................37911.1 Creating a Namespace................................................................................................................................................... 37911.2 Deleting a Namespace................................................................................................................................................... 38211.3 Reading a Specified Namespace.................................................................................................................................38511.4 Replacing a Specified Namespace..............................................................................................................................38711.5 Replacing the Status of a Specified Namespace................................................................................................... 38911.6 Replacing the Finalize Value of a Specified Namespace....................................................................................39111.7 Listing or Watching Objects of Kind Namespace................................................................................................. 39311.8 Partially Updating a Specified Namespace............................................................................................................. 395

    12 Endpoints (Native Kubernetes APIs)............................................................................39812.1 Creating an Endpoints.................................................................................................................................................... 39812.2 Deleting an Endpoints.................................................................................................................................................... 40312.3 Reading a Specified Endpoints.................................................................................................................................... 40712.4 Replacing a Specified Endpoints................................................................................................................................. 40812.5 Listing or Watching Objects of Kind Endpoints..................................................................................................... 41112.6 Listing or Watching Objects of Kind Endpoints in a Specified Namespace.................................................41512.7 Partially Updating a Specified Endpoints................................................................................................................ 417

    13 StatefulSet (Native Kubernetes APIs)......................................................................... 42013.1 Creating a StatefulSet.................................................................................................................................................... 42013.2 Deleting a StatefulSet.................................................................................................................................................... 42913.3 Reading a Specified StatefulSet.................................................................................................................................. 43013.4 Reading the Status of a Specified StatefulSet....................................................................................................... 43313.5 Replacing a Specified StatefulSet............................................................................................................................... 43513.6 Replacing the Status of a Specified StatefulSet.................................................................................................... 43813.7 Listing or Watching Objects of Kind StatefulSet in a Specified Namespace...............................................44113.8 Listing or Watching Objects of Kind StatefulSet...................................................................................................44413.9 Partially Updating a Specified StatefulSet.............................................................................................................. 44713.10 Partially Updating the Status of a Specified StatefulSet................................................................................. 450

    14 PersistentVolumeClaim (Native Kubernetes APIs)...................................................45314.1 Creating a PersistentVolumeClaim.............................................................................................................................45314.2 Deleting a PersistentVolumeClaim.............................................................................................................................45814.3 Reading a Specified PersistentVolumeClaim.......................................................................................................... 46014.4 Replacing a Specified PersistentVolumeClaim....................................................................................................... 46414.5 Replacing the Status of a Specified PersistentVolumeClaim............................................................................ 46614.6 Listing or Watching Objects of Kind PersistentVolumeClaim in a Specified Namespace.......................46814.7 Listing or Watching Objects of Kind PersistentVolumeClaim........................................................................... 47214.8 Partially Updating a Specified PersistentVolumeClaim.......................................................................................474

    15 PersistentVolume (Native Kubernetes APIs)..............................................................477

    Cloud Container EngineAPI Reference Contents

    2018-09-19 v

  • 15.1 Creating a PersistentVolume........................................................................................................................................ 47715.2 Deleting a PersistentVolume........................................................................................................................................ 48415.3 Reading a Specified PersistentVolume......................................................................................................................48615.4 Replacing a Specified PersistentVolume.................................................................................................................. 48715.5 Replacing the Status of a Specified PersistentVolume........................................................................................48915.6 Listing or Watching Objects of Kind PersistentVolume...................................................................................... 49115.7 Partially Updating a Specified PersistentVolume..................................................................................................495

    16 Appendix............................................................................................................................. 49716.1 Patch Request Method Operation Description...................................................................................................... 49716.2 Patch Request Method Operation Example............................................................................................................49816.3 Using ELB with a Cluster............................................................................................................................................... 50216.4 Using kubectl to Access a Container Cluster.......................................................................................................... 50416.5 Using an External Private Container Image............................................................................................................50616.6 Using kubectl to Interconnecting PV with EVS...................................................................................................... 508

    A Change History....................................................................................................................512

    Cloud Container EngineAPI Reference Contents

    2018-09-19 vi

  • 1 OverviewIntroduction to CCE

    Cloud Container Engine (CCE) is a platform for developers and partners todevelop, deploy, manage, and perform operation and maintenance (O&M) forcontainerized applications. With CCE, new containerized applications can be rolledout cost-efficiently anytime, anywhere.

    Classification of APIsThe APIs provided by CCE fall into two categories: open APIs and proprietary APIs.

    Open APIs are inherited from Kubernetes. Currently, the Kubernetes version hasbeen upgraded to 1.7.

    The Kubernetes APIs used in this version do not support Hypertext TransferProtocol (HTTP) persistent connections.

    Type Subtype Description

    ProprietaryAPIs

    Cluster andnodemanagement

    API used for cluster and node management,such as creating and deleting clusters andnodes.Using this API, you can create clusters, addnodes to clusters, and obtain informationabout created clusters and nodes.

    Data and logmonitoring

    ● API used for obtaining monitoring data ofnodes and application instances, forexample, obtaining CPU and memoryusage.

    ● API for exporting application logs. Usingthis API, you can export application logsbased on the specified keywords and timeranges.

    Cloud Container EngineAPI Reference 1 Overview

    2018-09-19 1

  • Type Subtype Description

    NativeKubernetesAPIs

    Secret API used for managing secrets, such ascreating, querying, modifying, and deletingsecrets.

    ReplicationController

    API used for managing ReplicationControllers,such as creating, querying, modifying, anddeleting ReplicationControllers.

    Service API used for managing services, such ascreating, querying, modifying, and deletingservices.

    Pod API used for managing pods, such as creating,querying, modifying, and deleting pods.

    PodTemplate API used for managing PodTemplates, such ascreating, querying, modifying, and deletingPodTemplates.

    Namespace API used for managing namespaces, such ascreating, querying, modifying, and deletingnamespaces.

    Endpoint API used for managing endpoints, such ascreating, querying, modifying, and deletingendpoints.

    Statefulset API used for managing StatefulSets, such ascreating, querying, modifying, and deletingStatefulSets.

    PersistentVolumeClaim

    API used for managing PersistentVolume-Claims (PVCs), such as creating, querying,modifying, and deleting PVCs.

    PersistentVolume

    API used for managing PersistentVolumes(PVs), such as creating, querying, modifying,and deleting PVs.

    Cloud Container EngineAPI Reference 1 Overview

    2018-09-19 2

  • 2 APIsPublic cloud services provide RESTful APIs.

    Representational State Transfer (REST) allocates Uniform Resource Identifiers(URIs) to dispersed resources so that the resources can be located. Applications onclients use Unified Resource Locators (URLs) to obtain the resources.

    Public cloud APIs use HTTPS as the transmission protocol. Requests/Responses aretransmitted by using JSON messages.

    The URL is in the following format: https://Endpoint/uri

    Table 2-1 describes the parameters in a URL.

    Table 2-1 Parameter description

    Parameter Description

    Endpoint Specifies the URL that is the entry point for a web service.Obtain this value from section Regions and Endpoints.

    uri Specifies the API access path for performing a specifiedoperation. Obtain this value from the URI of the API, forexample, v3/auth/tokens.

    2.1 API CallingThe process for calling an API is as follows:

    1. (Optional) Perform preparations before calling an API.

    If the following operations have been performed, skip this step.

    a. 2.2 Uploading an AK/SK Fileb. 2.3 Creating a VPCc. 2.4 Creating a Key Pair

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 3

    https://docs.prod-cloud-ocb.orange-business.com/en-us/endpoint/index.html

  • 2. Create a container cluster.Before you call an API, create a container cluster and add cluster nodes on theCCE console.

    3. Obtain request authentication information.Before you call an API, obtain request authentication information and add itto the message header. For details, see 2.5 Authenticating Requests.

    4. Obtain the cluster UUID.Before you call an API, obtain the UUID of a container cluster (see 4.6Obtaining Information About All Clusters) and add it to the messageheader.

    5. Construct a request.Different methods are created by using different request parameters. Fordetails, see 2.7 Constructing Requests.

    6. Initiate the request.For details, see 2.8 Initiating Requests.

    7. Parse the response message.For details, see 2.9 Parsing Responses.

    2.2 Uploading an AK/SK FileBefore you create a container cluster on the CCE console, upload a valid AccessKey ID/Secret Access Key (AK/SK) file. If no AK/SK file is uploaded or the uploadedAK/SK file has expired, the container cluster cannot be authorized to use privatecontainer images and the ELB. To ensure account security and optimal userexperience with CCE services, upload your AK/SK file and complete userauthentication.

    ProcedureStep 1 Download your AK/SK file from the authentication center.

    1. Log in to the management console, click the account name at the upper rightcorner, and choose My Credential.

    2. Choose Access Keys > Add Access Key. In the Add Access Key dialog box,enter the email or short message service (SMS) verification code and click OK.

    3. Click OK to confirm that you want to proceed with the download.The AK/SK file is named credentials.csv.

    After you click OK, different browsers will respond differently. For some browsers, thebrowser downloads the AK/SK file to the local default directory automatically. Forother browsers, you are prompted to confirm whether to open or save thedownloaded AK/SK file.

    Step 2 Upload your AK/SK file to CCE.● If you log in to the CCE console for the first time, the Upload Certificate File

    window is displayed upon successful login. Click Upload.● In other situations, choose Dashboard in the navigation pane and then

    Update Certificate File in the Authentication area.

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 4

  • Figure 2-1 Updating a certificate file

    Step 3 Select the path to your AK/SK file in the .csv format. Click Upload and then Close.

    ----End

    2.3 Creating a VPCCreate a VPC before you create a container cluster. VPCs provide a secure andisolated network environment for CCE services.

    If you have already created a VPC, you will never need to create it again.

    For more information about how to create a VPC, choose Help Center > Virtual PrivateCloud > User Guide > VPC and Subnet > Creating a VPC on the management console.

    Step 1 On the management console, click Service List, and choose Network > VirtualPrivate Cloud to launch the VPC console.

    Step 2 On the Dashboard page, click Create VPC to create a VPC.

    ----End

    2.4 Creating a Key PairCreate a key pair before you create a container cluster. Key pairs are used foridentity authentication at the time of node login.

    If you have already created a key pair, you will never need to create it again.

    For more information about how to create a key pair, choose Help Center > Elastic CloudServer > User Guide > Configurations > Creating a Key Pair on the management console.

    Step 1 On the management console, click Service List, and choose Computing > ElasticCloud Server to launch the ECS console.

    Step 2 In the navigation pane, choose Key Pair.

    Step 3 Click Create Key Pair.

    Step 4 In the Create Key Pair dialog box, specify the key pair name. For example,KeyPair-cce.

    The key pair name must be 1 to 64 characters long. Only letters, digits, hyphens(-), and underscores (_) are allowed.

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 5

  • Step 5 In the Create Key Pair dialog box, click OK.

    Step 6 In the Information dialog box, click OK.

    A key file in the .pem format is generated and saved to the default directory onyour local computer.

    ----End

    2.5 Authenticating RequestsThere are two methods for authenticating API requests. You can use either of themethods as needed.

    ● Token AuthenticationCommon requests are authenticated using Tokens. Open APIs typically useToken authentication.

    ● AK/SK AuthenticationRequests are encrypted using the Access Key ID (AK) and Secret Access Key(SK). This authentication mode is more secure than token authentication andis recommended for proprietary APIs.

    2.5.1 Token Authentication

    ScenariosIf you use a token for authentication, you must obtain the user's token and add X-Auth-Token to the request message header of the service API when making anAPI call.

    This section describes how to make an API call for token authentication.

    Make an API Call1. Send POST https://IAM endpoint/v3/auth/tokens to obtain the IAM

    endpoint and the region name in the message body. For details, see Regionsand Endpoints.An example request message is as follows:

    Replace the items in italic in the following example with actual ones. For details, seeand Access Management API Reference.

    { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "******", "password": "******", "domain": { "name": "domainname" }

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 6

    https://docs.prod-cloud-ocb.orange-business.com/en-us/endpoint/index.htmlhttps://docs.prod-cloud-ocb.orange-business.com/en-us/endpoint/index.html

  • } } }, "scope": { "project": { "name": "aaa" //The project name "aaa" is used as an example. } } }}

    2. Obtain the token. For details, see section "Obtaining User Token" in theIdentity and Access Management API Reference. After the request isprocessed, the value of X-Subject-Token in the message header is the tokenvalue.

    3. Make a call to a service API, add X-Auth-Token to the message header, andset the value of X-Auth-Token to the token obtained in step 2.

    2.5.2 AK/SK AuthenticationWhen you use an API gateway to send requests to underlying services, therequests are signed using the AK and SK.

    AK: indicates the unique ID of the secret access key. AK is used together with SK to obtainan encrypted signature for a request.SK: indicates the secret access key used together with the access key ID to sign requests. AKand SK can be used together to identify a request sender to prevent the request from beingmodified.

    2.5.2.1 AK and SK Generation1. Log in to the management console.2. Click the username and choose My Credential from the drop-down list.

    3. Click Access Credentials.4. Click Add Access Key to switch to the Add Access Key page.5. Enter the password used for the current login.6. Enter the authentication code received in the email or mobile phone.

    7. Click OK to download the access key.

    To prevent the access key from being leaked, keep it secure.

    2.5.2.2 Request Signing Procedure

    Preparations1. Download the API gateway signing tool from the following website:

    https://oss.prod-cloud-ocb.orange-business.com/download/develop/api/java/java-sdk-core.zip

    2. Extract the package.3. Create a Java project, and reference the extracted JAR to the dependency

    path.

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 7

    https://oss.prod-cloud-ocb.orange-business.com/download/develop/api/java/java-sdk-core.ziphttps://oss.prod-cloud-ocb.orange-business.com/download/develop/api/java/java-sdk-core.zip

  • Sign a Request1. Create a request com.cloud.sdk.DefaultRequest (JAVA) used for signing.2. Set the target API URL, HTTPS method, and content of request

    com.cloud.sdk.DefaultRequest (JAVA).3. Sign request com.cloud.sdk.DefaultRequest (JAVA).

    a. Call SignerFactory.getSigner(String serviceName, String regionName)to obtain a signing tool.

    b. Call Signer.sign(Request request, Credentials credentials) to signthe request created in step 1.The following code shows the details://Select an algorithm for request signing.Signer signer = SignerFactory.getSigner(serviceName, region);//Sign the request. The request will change after the signing.signer.sign(request, new BasicCredentials(this.ak, this.sk));

    4. Convert the request signed in the previous step to a new request that can beused to make an API call and copy the header of the signed request to thenew request.For example, if Apache HttpClient is used, convert DefaultRequest toHttpRequestBase and copy the header of the signed DefaultRequest toHttpRequestBase.For details, see descriptions of AccessServiceImpl.java in section 2.5.2.3Sample Code.

    2.5.2.3 Sample CodeThe following code shows how to sign a request and how to use an HTTP client tosend an HTTPS request:

    Code is classified into three classes for demonstrating request signing and HTTPrequest sending.

    AccessService: indicates the abstract class that converts the GET, POST, PUT, andDELETE methods into the access method.

    Demo: indicates the execution entry used to simulate GET, POST, PUT, and DELETErequest sending.

    AccessServiceImpl: indicates the implementation of the access method. Coderequired for API gateway communication is in the access method.

    For details about region and serviceName in the following codes, see Regionsand Endpoints.

    AccessService.java:

    package com.cloud.apigateway.sdk.demo;

    import java.io.InputStream;import java.net.URL;import java.util.Map;

    import org.apache.http.HttpResponse;

    import com.cloud.sdk.http.HttpMethodName;

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 8

    https://docs.prod-cloud-ocb.orange-business.com/en-us/endpoint/index.htmlhttps://docs.prod-cloud-ocb.orange-business.com/en-us/endpoint/index.html

  • public abstract class AccessService { protected String serviceName = null; protected String region = null; protected String ak = null; protected String sk = null; public AccessService(String serviceName, String region, String ak, String sk) { this.region = region; this.serviceName = serviceName; this.ak = ak; this.sk = sk; } public abstract HttpResponse access(URL url, Map header, InputStream content, Long contentLength, HttpMethodName httpMethod) throws Exception; public HttpResponse access(URL url, Map header, HttpMethodName httpMethod) throws Exception { return this.access(url, header, null, 0l, httpMethod); } public HttpResponse access(URL url, InputStream content, Long contentLength, HttpMethodName httpMethod) throws Exception { return this.access(url, null, content, contentLength, httpMethod); } public HttpResponse access(URL url, HttpMethodName httpMethod) throws Exception { return this.access(url, null, null, 0l, httpMethod); } public abstract void close(); public String getServiceName() { return serviceName; } public void setServiceName(String serviceName) { this.serviceName = serviceName; } public String getRegion() { return region; } public void setRegion(String region) { this.region = region; } public String getAk() { return ak; } public void setAk(String ak) { this.ak = ak; } public String getSk() { return sk; } public void setSk(String sk) { this.sk = sk; }

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 9

  • }

    AccessServiceImpl.java:

    package com.cloud.apigateway.sdk.demo;

    import java.io.IOException;import java.io.InputStream;import java.net.URISyntaxException;import java.net.URL;import java.util.HashMap;import java.util.Map;

    import javax.net.ssl.SSLContext;

    import org.apache.http.Header;import org.apache.http.HttpHeaders;import org.apache.http.HttpResponse;import org.apache.http.client.methods.HttpDelete;import org.apache.http.client.methods.HttpGet;import org.apache.http.client.methods.HttpHead;import org.apache.http.client.methods.HttpPatch;import org.apache.http.client.methods.HttpPost;import org.apache.http.client.methods.HttpPut;import org.apache.http.client.methods.HttpRequestBase;import org.apache.http.conn.ssl.AllowAllHostnameVerifier;import org.apache.http.conn.ssl.SSLConnectionSocketFactory;import org.apache.http.conn.ssl.SSLContexts;import org.apache.http.conn.ssl.TrustSelfSignedStrategy;import org.apache.http.entity.InputStreamEntity;import org.apache.http.impl.client.CloseableHttpClient;import org.apache.http.impl.client.HttpClients;

    import com.cloud.sdk.DefaultRequest;import com.cloud.sdk.Request;import com.cloud.sdk.auth.credentials.BasicCredentials;import com.cloud.sdk.auth.signer.Signer;import com.cloud.sdk.auth.signer.SignerFactory;import com.cloud.sdk.http.HttpMethodName;

    public class AccessServiceImpl extends AccessService {

    private CloseableHttpClient client = null;

    public AccessServiceImpl(String serviceName, String region, String ak, String sk) { super(serviceName, region, ak, sk); }

    /** {@inheritDoc} */

    public HttpResponse access(URL url, Map headers, InputStream content, Long contentLength, HttpMethodName httpMethod) throws Exception {

    // Make a request for signing. Request request = new DefaultRequest(this.serviceName); try { // Set the request address. request.setEndpoint(url.toURI());

    String urlString = url.toString();

    String parameters = null;

    if (urlString.contains("?")) { parameters = urlString.substring(urlString.indexOf("?") + 1);

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 10

  • Map parametersmap = new HashMap(); if (null != parameters && !"".equals(parameters)) { String[] parameterarray = parameters.split("&"); for (String p : parameterarray) { String key = p.split("=")[0]; String value = p.split("=")[1]; parametersmap.put(key, value); } request.setParameters(parametersmap); } }

    } catch (URISyntaxException e) { // It is recommended to add logs in this place. e.printStackTrace(); } // Set the request method. request.setHttpMethod(httpMethod); if (headers != null) { // Add request header information if required. request.setHeaders(headers); } // Configure the request content. request.setContent(content);

    // Select an algorithm for request signing. Signer signer = SignerFactory.getSigner(serviceName, region); // Sign the request, and the request will change after the signing. signer.sign(request, new BasicCredentials(this.ak, this.sk));

    // Make a request that can be sent by the HTTP client. HttpRequestBase httpRequestBase = createRequest(url, null, request.getContent(), contentLength, httpMethod); Map requestHeaders = request.getHeaders(); // Put the header of the signed request to the new request. for (String key : requestHeaders.keySet()) { if (key.equalsIgnoreCase(HttpHeaders.CONTENT_LENGTH.toString())) { continue; } httpRequestBase.addHeader(key, requestHeaders.get(key)); }

    HttpResponse response = null; SSLContext sslContext = SSLContexts.custom() .loadTrustMaterial(null, new TrustSelfSignedStrategy()) .useTLS().build(); SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory( sslContext, new AllowAllHostnameVerifier());

    client = HttpClients.custom().setSSLSocketFactory(sslSocketFactory) .build(); // Send the request, and a response will be returned. response = client.execute(httpRequestBase); return response; }

    /** * Make a request that can be sent by the HTTP client. * * @param url * specifies the API access path. * @param header * specifies the header information to be added. * @param content * specifies the body content to be sent in the API call. * @param contentLength * specifies the length of the content. This parameter is optional.

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 11

  • * @param httpMethod * specifies the HTTP method to be used. * @return specifies the request that can be sent by an HTTP client. */ private static HttpRequestBase createRequest(URL url, Header header, InputStream content, Long contentLength, HttpMethodName httpMethod) {

    HttpRequestBase httpRequest; if (httpMethod == HttpMethodName.POST) { HttpPost postMethod = new HttpPost(url.toString());

    if (content != null) { InputStreamEntity entity = new InputStreamEntity(content, contentLength); postMethod.setEntity(entity); } httpRequest = postMethod; } else if (httpMethod == HttpMethodName.PUT) { HttpPut putMethod = new HttpPut(url.toString()); httpRequest = putMethod;

    if (content != null) { InputStreamEntity entity = new InputStreamEntity(content, contentLength); putMethod.setEntity(entity); } } else if (httpMethod == HttpMethodName.PATCH) { HttpPatch patchMethod = new HttpPatch(url.toString()); httpRequest = patchMethod;

    if (content != null) { InputStreamEntity entity = new InputStreamEntity(content, contentLength); patchMethod.setEntity(entity); } } else if (httpMethod == HttpMethodName.GET) { httpRequest = new HttpGet(url.toString()); } else if (httpMethod == HttpMethodName.DELETE) { httpRequest = new HttpDelete(url.toString()); } else if (httpMethod == HttpMethodName.HEAD) { httpRequest = new HttpHead(url.toString()); } else { throw new RuntimeException("Unknown HTTP method name: " + httpMethod); }

    httpRequest.addHeader(header); return httpRequest; }

    @Override public void close() { try { if (client != null) { client.close(); } } catch (IOException e) { // It is recommended to add logs in this place. e.printStackTrace(); } }

    }

    Demo.java:

    package com.cloud.apigateway.sdk.demo;

    import java.io.BufferedReader;

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 12

  • import java.io.ByteArrayInputStream;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.net.MalformedURLException;import java.net.URL;

    import org.apache.http.HttpResponse;

    import com.cloud.sdk.http.HttpMethodName;

    public class Demo {

    //replace real region private static final String region = "regionName";

    //replace real service name private static final String serviceName = "serviceName";

    public static void main(String[] args) {

    //replace real AK String ak = "akString"; //replace real SK String sk = "skString";

    // get method //replace real url String url = "urlString"; get(ak, sk, url);

    // post method //replace real url String postUrl = "urlString"; //replace real body String postbody = "bodyString"; post(ak, sk, postUrl, postbody);

    // put method //replace real body String putbody = "bodyString"; //replace real url String putUrl = "urlString"; put(ak, sk, putUrl, putbody);

    // delete method //replace real url String deleteUrl = "urlString"; delete(ak, sk, deleteUrl); }

    public static void put(String ak, String sk, String requestUrl, String putBody) {

    AccessService accessService = null; try { accessService = new AccessServiceImpl(serviceName, region, ak, sk); URL url = new URL(requestUrl); HttpMethodName httpMethod = HttpMethodName.PUT; InputStream content = new ByteArrayInputStream(putBody.getBytes()); HttpResponse response = accessService.access(url, content, (long) putBody.getBytes().length, httpMethod); System.out.println(response.getStatusLine().getStatusCode()); } catch (Exception e) {

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 13

  • e.printStackTrace(); } finally { accessService.close(); }

    } public static void patch(String ak, String sk, String requestUrl, String putBody) {

    AccessService accessService = null; try { accessService = new AccessServiceImpl(serviceName, region, ak, sk); URL url = new URL(requestUrl); HttpMethodName httpMethod = HttpMethodName.PATCH; InputStream content = new ByteArrayInputStream(putBody.getBytes()); HttpResponse response = accessService.access(url, content, (long) putBody.getBytes().length, httpMethod); System.out.println(convertStreamToString(response.getEntity() .getContent())); } catch (Exception e) { e.printStackTrace(); } finally { accessService.close(); }

    }

    public static void delete(String ak, String sk, String requestUrl) {

    AccessService accessService = null;

    try { accessService = new AccessServiceImpl(serviceName, region, ak, sk); URL url = new URL(requestUrl); HttpMethodName httpMethod = HttpMethodName.DELETE;

    HttpResponse response = accessService.access(url, httpMethod); System.out.println(convertStreamToString(response.getEntity() .getContent())); } catch (Exception e) { e.printStackTrace(); } finally { accessService.close(); }

    }

    public static void get(String ak, String sk, String requestUrl) {

    AccessService accessService = null;

    try { accessService = new AccessServiceImpl(serviceName, region, ak, sk); URL url = new URL(requestUrl); HttpMethodName httpMethod = HttpMethodName.GET; HttpResponse response; response = accessService.access(url, httpMethod); System.out.println(convertStreamToString(response.getEntity() .getContent())); } catch (Exception e) { e.printStackTrace(); } finally { accessService.close(); }

    }

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 14

  • public static void post(String ak, String sk, String requestUrl, String postbody) {

    AccessService accessService = new AccessServiceImpl(serviceName, region, ak, sk); URL url = null; try { url = new URL(requestUrl); } catch (MalformedURLException e) { e.printStackTrace(); } InputStream content = new ByteArrayInputStream(postbody.getBytes()); HttpMethodName httpMethod = HttpMethodName.POST; HttpResponse response;

    try { response = accessService.access(url, content, (long) postbody.getBytes().length, httpMethod); System.out.println(convertStreamToString(response.getEntity() .getContent())); } catch (Exception e) { e.printStackTrace(); } finally { accessService.close(); } }

    private static String convertStreamToString(InputStream is) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder();

    String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } } catch (IOException e) { e.printStackTrace(); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); } }

    return sb.toString(); }

    }

    1. Parameters URI, AK, SK, and HTTP METHOD are mandatory.2. You can use the request.addHeader() method to add header information.

    2.6 Obtaining Cluster UUIDEach user can create a maximum of two container clusters. Clusters aredifferentiated by their UUID. Except the API used for 4.6 Obtaining InformationAbout All Clusters, other APIs must have their request message headers convey acluster UUID.

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 15

  • Prerequisites● A cluster and cluster nodes have been created on the CCE console.● Authentication credentials of the public cloud have been obtained.

    For details, see 2.5 Authenticating Requests.

    Procedure

    Step 1 Construct a request method using information about all clusters and initiate arequest.

    For details, see 4.6 Obtaining Information About All Clusters.

    Step 2 From the response message body corresponding to the request method, obtain theUUID of the cluster with the specified name.

    For details about a response message body, see Response.

    In the example below, the UUID of the cluster named NewCluster is31e39cf1-0792-4504-bb71-16c56bdd59c5.

    { "clusters": [ { "kind": "cluster", "apiVersion": "v1", "metadata": { "name": "NewCluster", "uuid": "31e39cf1-0792-4504-bb71-16c56bdd59c5", "spaceuuid": "ac7fbe69-d7ae-7e3c-897d-41d23386ef9b", "createAt": "2016-08-01 10:11:02.139235173 +0000 UTC", "updateAt": "2016-08-03 08:02:54.710201743 +0000 UTC" }, ...]}

    ----End

    2.7 Constructing RequestsA request consists of three parts: a request line, a request header, and a requestbody (optional).

    Request LineA request line starts with a method token, which is followed by a request uniformresource identifier (URI) and protocol version. The three parts are separated byspaces. The format of the request line is as follows:

    Method Request-URI HTTP-Version CRLF

    ● Method: request method. All methods are capitalized. Their meanings are asfollows:– GET: obtains resources identified by a Request-URI.– POST: adds new data to a resource identified by a Request-URI.– PUT: requests a server to save a resource and uses a Request-URI to

    identify the resource.

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 16

  • – DELETE: requests the server to delete the resource identified by aRequest-URI.

    – PATCH: requests a server to update a resource or create a new resource ifthe target resource does not exist.

    – HEAD: requests only the page header.

    – OPTION: allows the client to view server performance.

    ● Request-URI: unified resource identifier.

    Request-URI is in the format [path][?query], where:

    ● If there are multiple paths, separate them by a forward slash (/).

    ● If there are multiple queries, separate them by ampersand (&).

    ● path and query are separated by a question mark (?).

    ● HTTP-Version: version of the HTTP protocol used by a request.

    ● CRLF: carriage return and new-line characters. CRLF is placed only at the endof a line, and a separate CR or LF is not allowed.

    Request Header

    A request header consists of several header fields. Each header field is in theformat: field name:field value.

    Table 2-2 shows the common request headers. Except Cotent-Type, other headerfields are CCE-specific.

    Table 2-2 Common request headers fields

    Parameter Description Mandatory

    Example Value

    Content-Type Nature of the data inthe body of an entity.

    Yes application/json

    X-Auth-Token Token authenticationinformation acquiredduring 2.5.1 TokenAuthentication.NOTE

    This header field ismandatory if Tokenauthentication is inuse.

    No -

    X-Sdk-Date Time at which therequest was sent.NOTE

    This header field ismandatory if AK/SKauthentication is inuse.

    No 20151222T034042Z

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 17

  • Parameter Description Mandatory

    Example Value

    Authorization Authenticationinformation, whichcan be obtained fromthe request signingresult.NOTE

    This header field ismandatory if AK/SKauthentication is inuse.

    No -

    X-Cluster-UUID

    UUID of the targetcluster.The UUID is obtainedduring the procedureof 4.6 ObtainingInformation AboutAll Clusters.NOTE

    This header field ismandatory for APIsother than those usedfor 4 Cluster and HostManagement(Proprietary APIs) and5 Metrics and Logs(Proprietary APIs).

    No 72a483fd-bd8e-4dae-98b9-afe3ae942765

    Request Body

    A request body is a JSON-style nested key:value pair. The mandatory fields andoptional fields in an HTTP request vary depending on the URI object.

    2.8 Initiating RequestsThere are three methods to initiate requests to the server end:

    ● cURL

    cURL is a command line tool used to perform URL operations and transmitinformation. It can serve as an HTTP client to send HTTP requests to theserver end and receive response messages. cURL is suitable for use in APItuning scenarios. For more information about cURL, visit https://curl.haxx.se/.

    ● Code

    You can call an API through code to assemble, send, and process requests.

    ● REST clients

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 18

    https://curl.haxx.se/https://curl.haxx.se/

  • Mozilla Firefox and Google provide a graphical browser plug-in for RESTclients to send and process requests. For details, see Firefox REST Client andPostman.

    2.9 Parsing ResponsesAfter receiving a request, the server will return an HTTP response.

    A response consists of three parts: status line, response header, and response body.

    Status Line

    The format of a status line is as follows:

    HTTP-Version Status-Code Reason-Phrase CRLF

    ● HTTP-Version: version of the HTTP protocol used by the server.

    ● Status-Code: status code in the response returned by the server.

    A status code consists of three digits. The first digit defines the category of aresponse. There are five categories:

    – 1xx: informational response, indicating that the request has been receivedand the recipient is continuing to process the request.

    – 2xx: success response, indicating that the request has been received,understood, and accepted.

    – 3xx: redirection response, indicating that further action needs to be takenby the requester in order to complete the request.

    – 4xx: client error response, indicating that the request contains a syntaxerror or cannot be fulfilled.

    – 5xx: server error response, indicating that the server fails to fulfill a validrequest.

    ● Reason-Phrase: text description of the status code.

    Response Header

    In most cases, a response header carries the following header fields:

    Table 2-3 Standard HTTP response headers

    Name Description Example

    Date Date and time when theresponse was sent.The format of the dateand time is defined inRFC 822.

    Mon, 12 Nov 200715:55:01 GMT

    Server Software informationthat the server uses toprocess requests.

    Apache

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 19

    https://addons.mozilla.org/en-US/firefox/addon/restclient/https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop

  • Name Description Example

    Content-Length Length of the responsebody in octets.

    xxx

    Content-Type Media type of theresponse body sent tothe recipient.

    application/json

    Response BodyA response body is JSON text. The content of a response body is UTF-8 coded.

    2.10 Status CodesTable 2-4 describes status codes.

    Table 2-4 Status codes

    StatusCode

    Name Description

    100 Continue The server has received the initial part of therequest and the client should continue to sendthe remaining part.

    101 SwitchingProtocols

    The requester has asked the server to switchprotocols and the server has agreed to do so.The target protocol must be more advancedthan the source protocol.For example, the current HTTP protocol isswitched to a later version of HTTP.

    200 OK The server successfully processed the request.

    201 Created The request has been fulfilled, resulting in thecreation of a new resource.

    202 Accepted The request has been accepted for processing,but the processing has not been completed.

    203 Non-AuthoritativeInformation

    The request has been fulfilled.

    204 NoContent The server has successfully processed therequest, but is not returning any content.The status code is returned in response to anHTTP OPTIONS request.

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 20

  • StatusCode

    Name Description

    205 Reset Content The server has successfully processed therequest, but is not returning any content.Unlike a 204 response, this response requiresthat the requester reset the content.

    206 Partial Content The server has successfully processed a part ofthe GET request.

    300 Multiple Choices There are multiple options for the requestedresource. For example, this code could be usedto present a list of resource characteristics andaddresses from which the client such as abrowser may choose.

    301 MovedPermanently

    This and all future requests should bepermanently directed to the given URIindicated in this response.

    302 Found The requested resource was temporarilymoved.

    303 See Other The response to the request can be foundunder another URI using a GET or POSTmethod.

    304 Not Modified The requested resource has not been modified.In such case, there is no need to retransmit theresource since the client still has a previously-downloaded copy.

    305 Use Proxy The requested resource is available onlythrough a proxy.

    306 Unused This HTTP status code is no longer used.

    400 BadRequest The request is invalid.The client should modify the request instead ofre-initiating it.

    401 Unauthorized The authentication information provided bythe client is incorrect or invalid.

    402 PaymentRequired

    Reserved for future use.

    403 Forbidden The server has received the request andunderstood it, but the server is refusing torespond to it.The client should modify the request instead ofre-initiating it.

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 21

  • StatusCode

    Name Description

    404 NotFound The requested resource could not be found.The client should modify the request instead ofre-initiating it.

    405 MethodNotAllowed

    A request method is not supported for therequested resource.The client should modify the request instead ofre-initiating it.

    406 Not Acceptable The server could not fulfill the requestaccording to the content characteristics of therequest.

    407 ProxyAuthenticationRequired

    This code is similar to 401, but indicates thatthe client must first authenticate itself with theproxy.

    408 Request Time-out

    The server timed out waiting for the request.The client may re-initiate the request withoutmodifications at any later time.

    409 Conflict The request could not be processed due to aconflict in the request, such as an edit conflictbetween multiple simultaneous updates or theresource that the client attempts to createalready exits.

    410 Gone The requested resource has been deletedpermanently and will not be available again.

    411 Length Required The server refused to process the requestbecause the request does not specify thelength of its content.

    412 PreconditionFailed

    The server does not meet one of thepreconditions that the requester puts on therequest.

    413 Request EntityToo Large

    The request is larger than the server is willingor able to process.The server may close the connection toprevent the client from continuing the request.If the server temporarily cannot process therequest, the response will contain a Retry-Afterheader field.

    414 Request-URI TooLarge

    The URI provided was too long for the serverto process.

    415 UnsupportedMedia Type

    The server does not support the media type inthe request.

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 22

  • StatusCode

    Name Description

    416 Requestedrange notsatisfiable

    The requested range is invalid.

    417 ExpectationFailed

    The server fails to meet the requirements ofthe Expect request-header field.

    422 UnprocessableEntity

    The request was well-formed but was unableto be followed due to semantic errors.

    429 TooManyRequests

    The client has sent more requests than its ratelimit is allowed within a given amount of time,or the server has received more requests thanit is able to process within a given amount oftime. In this case, it is advisable for the clientto re-initiate requests after the time specifiedin the Retry-After header of the responseexpires.

    500 InternalServerError

    The server is able to receive the request but itcould not understand the request.

    501 NotImplemented

    The server does not support the requestedfunction.

    502 Bad Gateway The server was acting as a gateway or proxyand received an invalid request from a remoteserver.

    503 ServiceUnavaila-ble

    The requested service is invalid.It is advisable for the client to modify therequest instead of re-initiating the request.

    504 ServerTimeout The server could not return a timely response.The response will reach the client only if therequest carries a timeout parameter.

    505 HTTP Versionnot supported

    The server does not support the HTTP protocolversion used in the request.

    Cloud Container EngineAPI Reference 2 APIs

    2018-09-19 23

  • 3 Common ParametersThis chapter describes common request parameters, and common responseparameters of every API.

    3.1 Common Request Parameters

    Table 3-1 Request parameters of v1.ReplicationController

    Name Mandatory Type Description

    kind Yes String A string value representingthe REST resource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isReplicationController.

    apiVersion Yes String Versioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

    metadata Yes Table 3-11 -

    spec Yes Table 3-19 -

    status No Table 3-20 -

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 24

  • Table 3-2 Request parameters of v1.PodTemplate

    Name Mandatory Type Description

    kind Yes String A string value representingthe REST resource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isPodTemplate.

    apiVersion Yes String Versioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

    metadata Yes Table 3-11 -

    template Yes Table 3-21 -

    Table 3-3 Request parameters of v1.Pod

    Name Mandatory Type Description

    kind Yes String A string value representingthe REST resource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isPod.

    apiVersion Yes String Versioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

    metadata Yes Table 3-11 -

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 25

  • Name Mandatory Type Description

    spec Yes Table 3-23 -

    status No Table 3-4 -

    Table 3-4 Data structure of the status field

    Name Mandatory Type Description

    phase No String Current condition of the pod.

    conditions No Table 3-5 Current service state of thepod.

    message No String A human readable messageindicating details about whythe pod is in this condition.

    reason No String A brief CamelCase messageindicating details about whythe pod is in this state. Forexample, 'OutOfDisk'.

    hostIP No String IP address of the host towhich the pod is assigned.Empty if not yet scheduled.

    podIP No String IP address allocated to thepod. Routable at least withinthe cluster. Empty if not yetallocated.

    startTime No String RFC 3339 date and time atwhich the object wasacknowledged by the Kubelet.This is before the Kubeletpulled the container image(s)for the pod.

    containerStatuses

    No Table 3-6 The list has one entry percontainer in the manifest.Each entry is currently theoutput of docker inspect.

    Table 3-5 Data structure of the conditions field

    Name Mandatory Type Description

    type No String Type of the condition.Currently only Ready.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 26

  • Name Mandatory Type Description

    status No String Status of the condition. Canbe True, False, or Unknown.

    lastProbeTime No String Last time we probed thecondition.

    lastTransitionTime

    No String Last time the conditiontransitioned from one statusto another.

    reason No String Unique, one-word, CamelCasereason for the condition's lasttransition.

    message No String Human-readable messageindicating details about lasttransition.

    Table 3-6 Data structure of the containerStatuses field

    Name Mandatory Type Description

    name Yes String This must be a DNS_LABEL.Each container in a pod musthave a unique name. Cannotbe updated.

    state No Table 3-7 -

    lastState No Table 3-7 -

    ready No Boolean Specifies whether thecontainer has passed itsreadiness probe.

    No No Integer The number of times thecontainer has been restarted,currently based on thenumber of dead containersthat have not yet beenremoved. Note that this iscalculated from deadcontainers. However, thosecontainers are subject togarbage collection. This valuewill get capped at 5 by GC.

    image No String The image the container isrunning.

    imageID No String ID of the container's image.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 27

  • Name Mandatory Type Description

    containerID No String Container's ID in the format'docker://'.

    Table 3-7 Data structure of the state/lastState field

    Name Mandatory Type Description

    waiting No Table 3-8 -

    running No Table 3-9 -

    terminated No Table 3-10 -

    Table 3-8 Data structure of the waiting field

    Name Mandatory Type Description

    reason No String (Brief) Reason the containeris not yet running.

    message No String Message regarding why thecontainer is not yet running.

    Table 3-9 Data structure of the running field

    Name Mandatory Type Description

    startedAt No String Time at which the containerwas last (re-)started.

    Table 3-10 Data structure of the terminated field

    Name Mandatory Type Description

    startedAt No Integer Exit status from the lasttermination of the container.

    signal No Integer Signal from the lasttermination of the container.

    reason No String (Brief) reason from the lasttermination of the container.

    message No String Message regarding the lasttermination of the container.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 28

  • Name Mandatory Type Description

    startedAt No String Time at which previousexecution of the containerstarted.

    finishedAt No String Time at which the containerlast terminated.

    containerID No String Container's ID in the format'docker://'

    Table 3-11 Data structure of the metadata field

    Name Mandatory Type Description

    name Yes String Name must be unique withina namespace. Is requiredwhen creating resources,although some resources mayallow a client to request thegeneration of an appropriatename automatically. Name isprimarily intended forcreation idempotence andconfiguration definition.Cannot be updated.0 characters < name length ≤253 characters.The name must be a regularexpression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

    clusterName No String The name of the clusterwhich the object belongs to.This is used to distinguishresources with same nameand namespace in differentclusters. This field is not setanywhere right now andapiserver is going to ignore itif set in create or updaterequest.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 29

  • Name Mandatory Type Description

    initializers No Table 3-12 (A newly added parameter inKubernetes 1.7)An initializer is a controllerwhich enforces some systeminvariant at object creationtime. This field is a list ofinitializers that have not yetacted on this object. If nil orempty, this object has beencompletely initialized.Otherwise, the object isconsidered uninitialized and ishidden (in list/watch and getcalls) from clients thathaven't explicitly asked toobserve uninitialized objects.When an object is created,the system will populate thislist with the current set ofinitializers. Only privilegedusers may set or modify thislist. Once it is empty, it maynot be modified further byany user.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 30

  • Name Mandatory Type Description

    generateName No String An optional prefix used bythe server to generate aunique name ONLY IF theName field has not beenprovided. If this field is used,the name returned to theclient will be different thanthe name passed. This valuewill also be combined with aunique suffix. The providedvalue has the same validationrules as the Name field, andmay be truncated by thelength of the suffix requiredto make the value unique onthe server.If this field is specified andthe generated name exists,the server will NOT return a409. Instead, it will eitherreturn 201 Created or 500with Reason ServerTimeoutindicating a unique namecould not be found in thetime allotted, and the clientshould retry (optionally afterthe time indicated in theRetry-After header).Applied only if Name is notspecified.0 characters < generatedname length ≤ 253characters.The generated name must bea regular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 31

  • Name Mandatory Type Description

    namespace No String Namespace defines the spacewithin each name must beunique. An empty namespaceis equivalent to the "default"namespace, but "default" isthe canonical representation.Not all objects are required tobe scoped to a namespace -the value of this field forthose objects will be empty.Must be a DNS_LABEL.Cannot be updated.0 characters < namespacelength ≤ 63 characters.The namespace must be aregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

    selfLink No String A URL representing thisobject. Populated by thesystem. Read-only.NOTE

    This field is automaticallygenerated. Do not assign anyvalue to this field. Otherwise,API calls would fail.

    uid No String UID is the unique in time andspace value for this object. Itis typically generated by theserver on successful creationof a resource and is notallowed to change on PUToperations. Populated by thesystem. Read-only.NOTE

    This field is automaticallygenerated. Do not assign anyvalue to this field. Otherwise,API calls would fail.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 32

  • Name Mandatory Type Description

    resourceVersion

    No String An opaque value thatrepresents the internalversion of this object that canbe used by clients todetermine when objects havechanged. May be used foroptimistic concurrency,change detection, and thewatch operation on aresource or set of resources.Clients must treat thesevalues as opaque and passedunmodified back to theserver. They may only be validfor a particular resource orset of resources. Populated bythe system. Read-only. Valuemust be treated as opaque byclients.NOTE

    This field is automaticallygenerated. Do not assign anyvalue to this field. Otherwise,API calls would fail.

    generation No Integer A sequence numberrepresenting a specificgeneration of the desiredstate. Currently onlyimplemented by replicationcontrollers. Populated by thesystem. Read-only.

    creationTimestamp

    No String A timestamp representing theserver time when this objectwas created. It is notguaranteed to be set inhappens-before order acrossseparate operations. Clientsmay not set this value. It isrepresented in RFC3339 formand is in UTC. Populated bythe system. Read-only. Nullfor lists.NOTE

    This field is automaticallygenerated. Do not assign anyvalue to this field. Otherwise,API calls would fail.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 33

  • Name Mandatory Type Description

    deletionTimestamp

    No String RFC 3339 date and time atwhich this resource will bedeleted. This field is set bythe server when a gracefuldeletion is requested by theuser, and is not directlysettable by a client. Theresource will be deleted (nolonger visible from resourcelists, and not reachable byname) after the time in thisfield. Once set, this value maynot be unset or be set furtherinto the future, although itmay be shortened or theresource may be deleted priorto this time. For example, auser may request that a podis deleted in 30 seconds. TheKubelet will react by sendinga graceful termination signalto the containers in the pod.Once the resource is deletedin the API, the Kubelet willsend a hard terminationsignal to the container. If notset, graceful deletion of theobject has not beenrequested. Populated by thesystem when a gracefuldeletion is requested. Read-only.

    deletionGracePeriodSeconds

    No Integer Number of seconds allowedfor this object to gracefullyterminate before it will beremoved from the system.Only set whendeletionTimestamp is alsoset. May only be shortened.Read-only.

    labels Yes Map[string]string

    Map of string keys and valuesthat can be used to organizeand categorize (scope andselect) objects. May matchselectors of replicationcontrollers and services.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 34

  • Name Mandatory Type Description

    Annotations No Map[string]string

    An unstructured key valuemap stored with a resourcethat may be set by externaltools to store and retrievearbitrary metadata. They arenot queryable and should bepreserved when modifyingobjects.

    ownerReferences

    No Table 3-18 (A newly added parameter inKubernetes 1.3)List of objects depended bythis object. If ALL objects inthe list have been deleted,this object will be garbagecollected. If this object ismanaged by a controller, thenan entry in this list will pointto this controller, with thecontroller field set to true.There cannot be more thanone managing controller.

    finalizers No String array (A newly added parameter inKubernetes 1.3)Must be empty before theobject is deleted from theregistry. Each entry is anidentifier for the responsiblecomponent that will removethe entry from the list. If thedeletionTimestamp of theobject is non-nil, entries inthis list can only be removed.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 35

  • Table 3-12 Data structure of the initializers field

    Parameter Mandatory Type Description

    pending No Table 3-13 (A newly added parameter inKubernetes 1.7)Pending is a list of initializersthat must execute in orderbefore this object is visible.When the last pendinginitializer is removed, and nofailing result is set, theinitializers struct will be set tonil and the object isconsidered as initialized andvisible to all clients.

    result No Table 3-14 (A newly added parameter inKubernetes 1.7)If result is set with the Failurefield, the object will bepersisted to storage and thendeleted, ensuring that otherclients can observe thedeletion.

    Table 3-13 Data structure of the pending field

    Parameter Mandatory Type Description

    name No String (A newly added parameter inKubernetes 1.7)name of the process that isresponsible for initializing thisobject.

    Table 3-14 Data structure of the result field

    Parameter Mandatory Type Description

    apiVersion No String (A newly added parameter inKubernetes 1.7)APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 36

  • Parameter Mandatory Type Description

    code No Integer (A newly added parameter inKubernetes 1.7)Suggested HTTP return codefor this status, 0 if not set.

    details No Table 3-15 (A newly added parameter inKubernetes 1.7)Extended data associated withthe reason. Each reason maydefine its own extendeddetails. This field is optionaland the data returned is notguaranteed to conform to anyschema except that defined bythe reason type.

    kind No String (A newly added parameter inKubernetes 1.7)Kind is a string valuerepresenting the RESTresource this object represents.Servers may infer this fromthe endpoint the clientsubmits requests to. Cannotbe updated.

    message No String (A newly added parameter inKubernetes 1.7)A human-readable descriptionof the status of this operation.

    metadata Yes Table 3-16 (A newly added parameter inKubernetes 1.7)Standard list metadata.

    reason No String (A newly added parameter inKubernetes 1.7)A machine-readabledescription of why thisoperation is in the "Failure"status. If this value is emptythere is no informationavailable. A Reason clarifiesan HTTP status code but doesnot override it.

    status No String (A newly added parameter inKubernetes 1.7)Status of the operation. Oneof: "Success" or "Failure".

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 37

  • Table 3-15 Data structure of the details field

    Parameter Mandatory Type Description

    causes No Table 3-17 (A newly added parameter inKubernetes 1.7)The Causes array includesmore details associated withthe StatusReason failure. Notall StatusReasons may providedetailed causes.

    group No String (A newly added parameter inKubernetes 1.7)The group attribute of theresource associated with thestatus StatusReason.

    kind No String (A newly added parameter inKubernetes 1.7)The kind attribute of theresource associated with thestatus StatusReason. On someoperations may differ fromthe requested resource Kind.

    name No String (A newly added parameter inKubernetes 1.7)The name attribute of theresource associated with thestatus StatusReason (whenthere is a single name whichcan be described).

    retryAfterSeconds

    No Integer (A newly added parameter inKubernetes 1.7)If specified, the time inseconds before the operationshould be retried.

    uid No String (A newly added parameter inKubernetes 1.7)UID of the resource. (whenthere is a single resourcewhich can be described).

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 38

  • Table 3-16 Data structure of the metadata field

    Parameter Mandatory Type Description

    resourceVersion No String (A newly added parameter inKubernetes 1.7)String that identifies theserver's internal version of thisobject that can be used byclients to determine whenobjects have changed. Valuemust be treated as opaque byclients and passed unmodifiedback to the server. Populatedby the system. Read-only.

    selfLink No String (A newly added parameter inKubernetes 1.7)SelfLink is a URL representingthis object. Populated by thesystem. Read-only.

    Table 3-17 Data structure of the causes field

    Parameter Mandatory Type Description

    field No String (A newly added parameter inKubernetes 1.7)The field of the resource thathas caused this error, asnamed by its JSONserialization. May include dotand postfix notation fornested attributes. Arrays arezero-indexed. Fields mayappear more than once in anarray of causes due to fieldshaving multiple errors.Optional. Examples: "name" -the field "name" on thecurrent resource"items[0].name" - the field"name" on the first arrayentry in "items"

    message No String (A newly added parameter inKubernetes 1.7)A human-readable descriptionof the cause of the error. Thisfield may be presented as-isto a reader.

    Cloud Container EngineAPI Reference 3 Common Parameters

    2018-09-19 39

  • Parameter Mandatory Type Description

    reason No String (A newly added parameter inKubernetes 1.7)A machine-readabledescription of the cause of theerror. If this value is emptythere is no informationavailable.

    Table 3-18 Data structure of the ownerReferences field

    Name Mandatory Type Description

    apiVersion No String (A newly added parameter inKubernetes 1.3)API version of the referent.

    kind No String (A newly added parameter inKubernetes 1.3)Kind of the referent.

    name Yes String (A newly added parameter inKubernetes 1.3)Name of the referent.

    uid No String (A newly added parameter inKubernetes 1.3)UID of the referent.

    controller No Boolean (A newly added parameter inKubernetes 1.3)If true, this reference points tothe managing controller.

    Table 3-19 Data structure of the spec field

    Name Mandatory Type Description

    replicas No Integer The number of desiredreplicas. This is a pointer todistinguish between explicitzero and unspecified.Value range: ≥ 0.Default: 1