8.1 KiB
		
	
	
	
	
	
			
		
		
	
	 
 
 
 

PLEASE NOTE: This document applies to the HEAD of the source tree
If you are using a released version of Kubernetes, you should refer to the docs that go with that version.
The latest 1.0.x release of this document can be found [here](http://releases.k8s.io/release-1.0/docs/api.md).Documentation for other releases can be found at releases.k8s.io.
The Kubernetes API
Primary system and API concepts are documented in the User guide.
Overall API conventions are described in the API conventions doc.
Complete API details are documented via Swagger. The Kubernetes apiserver (aka "master") exports an API that can be used to retrieve the Swagger spec for the Kubernetes API, by default at /swaggerapi, and a UI you can use to browse the API documentation at /swagger-ui. We also periodically update a statically generated UI.
Remote access to the API is discussed in the access doc.
The Kubernetes API also serves as the foundation for the declarative configuration schema for the system. The Kubectl command-line tool can be used to create, update, delete, and get API objects.
Kubernetes also stores its serialized state (currently in etcd) in terms of the API resources.
Kubernetes itself is decomposed into multiple components, which interact through its API.
API changes
In our experience, any system that is successful needs to grow and change as new use cases emerge or existing ones change. Therefore, we expect the Kubernetes API to continuously change and grow. However, we intend to not break compatibility with existing clients, for an extended period of time. In general, new API resources and new resource fields can be expected to be added frequently. Elimination of resources or fields will require following a deprecation process. The precise deprecation policy for eliminating features is TBD, but once we reach our 1.0 milestone, there will be a specific policy.
What constitutes a compatible change and how to change the API are detailed by the API change document.
API versioning
To make it easier to eliminate fields or restructure resource representations, Kubernetes supports multiple API versions, each at a different API path prefix, such as /api/v1beta3. These are simply different interfaces to read and/or modify the same underlying resources. In general, all API resources are accessible via all API versions, though there may be some cases in the future where that is not true.
We chose to version at the API level rather than at the resource or field level to ensure that the API presents a clear, consistent view of system resources and behavior, and to enable controlling access to end-of-lifed and/or experimental APIs.
The API and release versioning proposal describes the current thinking on the API version evolution process.
v1beta1, v1beta2, and v1beta3 are deprecated; please move to v1 ASAP
As of June 4, 2015, the Kubernetes v1 API has been enabled by default. The v1beta1 and v1beta2 APIs were deleted on June 1, 2015. v1beta3 is planned to be deleted on July 6, 2015.
v1 conversion tips (from v1beta3)
We're working to convert all documentation and examples to v1. A simple API conversion tool has been written to simplify the translation process. Use kubectl create --validate in order to validate your json or yaml against our Swagger spec.
Changes to services are the most significant difference between v1beta3 and v1.
- The service.spec.portalIPproperty is renamed toservice.spec.clusterIP.
- The service.spec.createExternalLoadBalancerproperty is removed. Specifyservice.spec.type: "LoadBalancer"to create an external load balancer instead.
- The service.spec.publicIPsproperty is deprecated and now calledservice.spec.deprecatedPublicIPs. This property will be removed entirely when v1beta3 is removed. The vast majority of users of this field were using it to expose services on ports on the node. Those users should specifyservice.spec.type: "NodePort"instead. Read External Services for more info. If this is not sufficient for your use case, please file an issue or contact @thockin.
Some other difference between v1beta3 and v1:
- The pod.spec.containers[*].privilegedandpod.spec.containers[*].capabilitiesproperties are now nested under thepod.spec.containers[*].securityContextproperty. See Security Contexts.
- The pod.spec.hostproperty is renamed topod.spec.nodeName.
- The endpoints.subsets[*].addresses.IPproperty is renamed toendpoints.subsets[*].addresses.ip.
- The pod.status.containerStatuses[*].state.terminationandpod.status.containerStatuses[*].lastState.terminationproperties are renamed topod.status.containerStatuses[*].state.terminatedandpod.status.containerStatuses[*].lastState.terminatedrespectively.
- The pod.status.Conditionproperty is renamed topod.status.conditions.
- The status.details.idproperty is renamed tostatus.details.name.
v1beta3 conversion tips (from v1beta1/2)
Some important differences between v1beta1/2 and v1beta3:
- The resource idis now calledname.
- name,- labels,- annotations, and other metadata are now nested in a map called- metadata
- desiredStateis now called- spec, and- currentStateis now called- status
- /minionshas been moved to- /nodes, and the resource has kind- Node
- The namespace is required (for all namespaced resources) and has moved from a URL parameter to the path: /api/v1beta3/namespaces/{namespace}/{resource_collection}/{resource_name}. If you were not using a namespace before, usedefaulthere.
- The names of all resource collections are now lower cased - instead of replicationControllers, usereplicationcontrollers.
- To watch for changes to a resource, open an HTTP or Websocket connection to the collection query and provide the ?watch=truequery parameter along with the desiredresourceVersionparameter to watch from.
- The labelsquery parameter has been renamed tolabelSelector.
- The fieldsquery parameter has been renamed tofieldSelector.
- The container entrypointhas been renamed tocommand, andcommandhas been renamed toargs.
- Container, volume, and node resources are expressed as nested maps (e.g., resources{cpu:1}) rather than as individual fields, and resource values support scaling suffixes rather than fixed scales (e.g., milli-cores).
- Restart policy is represented simply as a string (e.g., "Always") rather than as a nested map (always{}).
- Pull policies changed from PullAlways,PullNever, andPullIfNotPresenttoAlways,Never, andIfNotPresent.
- The volume sourceis inlined intovolumerather than nested.
- Host volumes have been changed from hostDirtohostPathto better reflect that they can be files or directories.