diff --git a/pkg/api/register.go b/pkg/api/register.go index e7172d13615..5e7bb8cc42e 100644 --- a/pkg/api/register.go +++ b/pkg/api/register.go @@ -35,11 +35,31 @@ func init() { &Status{}, &ServerOpList{}, &ServerOp{}, - &ContainerManifestList{}, &Endpoints{}, &EndpointsList{}, &Binding{}, &Event{}, &EventList{}, + &ContainerManifestList{}, + &BoundPods{}, ) } + +func (*Pod) IsAnAPIObject() {} +func (*PodList) IsAnAPIObject() {} +func (*ReplicationController) IsAnAPIObject() {} +func (*ReplicationControllerList) IsAnAPIObject() {} +func (*Service) IsAnAPIObject() {} +func (*ServiceList) IsAnAPIObject() {} +func (*Endpoints) IsAnAPIObject() {} +func (*EndpointsList) IsAnAPIObject() {} +func (*Minion) IsAnAPIObject() {} +func (*MinionList) IsAnAPIObject() {} +func (*Binding) IsAnAPIObject() {} +func (*Status) IsAnAPIObject() {} +func (*ServerOp) IsAnAPIObject() {} +func (*ServerOpList) IsAnAPIObject() {} +func (*Event) IsAnAPIObject() {} +func (*EventList) IsAnAPIObject() {} +func (*ContainerManifestList) IsAnAPIObject() {} +func (*BoundPods) IsAnAPIObject() {} diff --git a/pkg/api/types.go b/pkg/api/types.go index 3952ad3acf3..ad47551e85d 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -45,32 +45,6 @@ import ( // or more simply: // DNS_LABEL(\.DNS_LABEL)* -// ContainerManifest corresponds to the Container Manifest format, documented at: -// https://developers.google.com/compute/docs/containers/container_vms#container_manifest -// This is used as the representation of Kubernetes workloads. -type ContainerManifest struct { - // Required: This must be a supported version string, such as "v1beta1". - Version string `yaml:"version" json:"version"` - // Required: This must be a DNS_SUBDOMAIN. - // TODO: ID on Manifest is deprecated and will be removed in the future. - ID string `yaml:"id" json:"id"` - // TODO: UUID on Manifest is deprecated in the future once we are done - // with the API refactoring. It is required for now to determine the instance - // of a Pod. - UUID string `yaml:"uuid,omitempty" json:"uuid,omitempty"` - Volumes []Volume `yaml:"volumes" json:"volumes"` - Containers []Container `yaml:"containers" json:"containers"` - RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" yaml:"restartPolicy,omitempty"` -} - -// ContainerManifestList is used to communicate container manifests to kubelet. -type ContainerManifestList struct { - TypeMeta `json:",inline" yaml:",inline"` - Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"` -} - -func (*ContainerManifestList) IsAnAPIObject() {} - // Volume represents a named volume in a pod that may be accessed by any containers in the pod. type Volume struct { // Required: This must be a DNS_LABEL. Each volume in a pod must have @@ -387,8 +361,6 @@ type PodList struct { Items []Pod `json:"items" yaml:"items,omitempty"` } -func (*PodList) IsAnAPIObject() {} - // Pod is a collection of containers, used as either input (create, update) or as output (list, get). type Pod struct { TypeMeta `json:",inline" yaml:",inline"` @@ -397,8 +369,6 @@ type Pod struct { CurrentState PodState `json:"currentState,omitempty" yaml:"currentState,omitempty"` } -func (*Pod) IsAnAPIObject() {} - // ReplicationControllerState is the state of a replication controller, either input (create, update) or as output (list, get). type ReplicationControllerState struct { Replicas int `json:"replicas" yaml:"replicas"` @@ -412,8 +382,6 @@ type ReplicationControllerList struct { Items []ReplicationController `json:"items,omitempty" yaml:"items,omitempty"` } -func (*ReplicationControllerList) IsAnAPIObject() {} - // ReplicationController represents the configuration of a replication controller. type ReplicationController struct { TypeMeta `json:",inline" yaml:",inline"` @@ -422,8 +390,6 @@ type ReplicationController struct { Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` } -func (*ReplicationController) IsAnAPIObject() {} - // PodTemplate holds the information used for creating pods. type PodTemplate struct { DesiredState PodState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"` @@ -436,8 +402,6 @@ type ServiceList struct { Items []Service `json:"items" yaml:"items"` } -func (*ServiceList) IsAnAPIObject() {} - // Service is a named abstraction of software service (for example, mysql) consisting of local port // (for example 3306) that the proxy listens on, and the selector that determines which pods // will answer requests sent through the proxy. @@ -461,8 +425,6 @@ type Service struct { ContainerPort util.IntOrString `json:"containerPort,omitempty" yaml:"containerPort,omitempty"` } -func (*Service) IsAnAPIObject() {} - // Endpoints is a collection of endpoints that implement the actual service, for example: // Name: "mysql", Endpoints: ["10.10.1.1:1909", "10.10.2.2:8834"] type Endpoints struct { @@ -470,16 +432,12 @@ type Endpoints struct { Endpoints []string `json:"endpoints,omitempty" yaml:"endpoints,omitempty"` } -func (*Endpoints) IsAnAPIObject() {} - // EndpointsList is a list of endpoints. type EndpointsList struct { TypeMeta `json:",inline" yaml:",inline"` Items []Endpoints `json:"items,omitempty" yaml:"items,omitempty"` } -func (*EndpointsList) IsAnAPIObject() {} - // NodeResources represents resources on a Kubernetes system node // see https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/resources.md for more details. type NodeResources struct { @@ -502,16 +460,12 @@ type Minion struct { NodeResources NodeResources `json:"resources,omitempty" yaml:"resources,omitempty"` } -func (*Minion) IsAnAPIObject() {} - // MinionList is a list of minions. type MinionList struct { TypeMeta `json:",inline" yaml:",inline"` Items []Minion `json:"items,omitempty" yaml:"items,omitempty"` } -func (*MinionList) IsAnAPIObject() {} - // Binding is written by a scheduler to cause a pod to be bound to a host. type Binding struct { TypeMeta `json:",inline" yaml:",inline"` @@ -519,8 +473,6 @@ type Binding struct { Host string `json:"host" yaml:"host"` } -func (*Binding) IsAnAPIObject() {} - // Status is a return value for calls that don't return other objects. // TODO: this could go in apiserver, but I'm including it here so clients needn't // import both. @@ -544,8 +496,6 @@ type Status struct { Code int `json:"code,omitempty" yaml:"code,omitempty"` } -func (*Status) IsAnAPIObject() {} - // StatusDetails is a set of additional properties that MAY be set by the // server to provide additional information about a response. The Reason // field of a Status object defines what attributes will be set. Clients @@ -682,16 +632,12 @@ type ServerOp struct { TypeMeta `yaml:",inline" json:",inline"` } -func (*ServerOp) IsAnAPIObject() {} - // ServerOpList is a list of operations, as delivered to API clients. type ServerOpList struct { TypeMeta `yaml:",inline" json:",inline"` Items []ServerOp `yaml:"items,omitempty" json:"items,omitempty"` } -func (*ServerOpList) IsAnAPIObject() {} - // ObjectReference contains enough information to let you inspect or modify the referred object. type ObjectReference struct { Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` @@ -743,12 +689,65 @@ type Event struct { Source string `json:"source,omitempty" yaml:"source,omitempty"` } -func (*Event) IsAnAPIObject() {} - // EventList is a list of events. type EventList struct { TypeMeta `yaml:",inline" json:",inline"` Items []Event `yaml:"items,omitempty" json:"items,omitempty"` } -func (*EventList) IsAnAPIObject() {} +// ContainerManifest corresponds to the Container Manifest format, documented at: +// https://developers.google.com/compute/docs/containers/container_vms#container_manifest +// This is used as the representation of Kubernetes workloads. +// DEPRECATED: Replaced with BoundPod +type ContainerManifest struct { + // Required: This must be a supported version string, such as "v1beta1". + Version string `yaml:"version" json:"version"` + // Required: This must be a DNS_SUBDOMAIN. + // TODO: ID on Manifest is deprecated and will be removed in the future. + ID string `yaml:"id" json:"id"` + // TODO: UUID on Manifest is deprecated in the future once we are done + // with the API refactoring. It is required for now to determine the instance + // of a Pod. + UUID string `yaml:"uuid,omitempty" json:"uuid,omitempty"` + Volumes []Volume `yaml:"volumes" json:"volumes"` + Containers []Container `yaml:"containers" json:"containers"` + RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" yaml:"restartPolicy,omitempty"` +} + +// ContainerManifestList is used to communicate container manifests to kubelet. +// DEPRECATED: Replaced with BoundPods +type ContainerManifestList struct { + TypeMeta `json:",inline" yaml:",inline"` + Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"` +} + +// Included in partial form from v1beta3 to replace ContainerManifest + +// PodSpec is a description of a pod +type PodSpec struct { + Volumes []Volume `json:"volumes" yaml:"volumes"` + Containers []Container `json:"containers" yaml:"containers"` + RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" yaml:"restartPolicy,omitempty"` +} + +// BoundPod is a collection of containers that should be run on a host. A BoundPod +// defines how a Pod may change after a Binding is created. A Pod is a request to +// execute a pod, whereas a BoundPod is the specification that would be run on a server. +type BoundPod struct { + TypeMeta `json:",inline" yaml:",inline"` + + // Spec defines the behavior of a pod. + Spec PodSpec `json:"spec,omitempty" yaml:"spec,omitempty"` +} + +// BoundPods is a list of Pods bound to a common server. The resource version of +// the pod list is guaranteed to only change when the list of bound pods changes. +type BoundPods struct { + TypeMeta `json:",inline" yaml:",inline"` + + // Host is the name of a node that these pods were bound to. + Host string `json:"host" yaml:"host"` + + // Items is the list of all pods bound to a given host. + Items []BoundPod `json:"items" yaml:"items"` +} diff --git a/pkg/api/v1beta1/register.go b/pkg/api/v1beta1/register.go index acfeec50131..7a125b8a92d 100644 --- a/pkg/api/v1beta1/register.go +++ b/pkg/api/v1beta1/register.go @@ -43,6 +43,7 @@ func init() { &Event{}, &EventList{}, &ContainerManifestList{}, + &BoundPods{}, ) } @@ -63,3 +64,4 @@ func (*ServerOpList) IsAnAPIObject() {} func (*Event) IsAnAPIObject() {} func (*EventList) IsAnAPIObject() {} func (*ContainerManifestList) IsAnAPIObject() {} +func (*BoundPods) IsAnAPIObject() {} diff --git a/pkg/api/v1beta1/types.go b/pkg/api/v1beta1/types.go index c26a92bc236..f8c136e29ce 100644 --- a/pkg/api/v1beta1/types.go +++ b/pkg/api/v1beta1/types.go @@ -711,3 +711,34 @@ type EventList struct { TypeMeta `yaml:",inline" json:",inline"` Items []Event `yaml:"items,omitempty" json:"items,omitempty"` } + +// Backported from v1beta3 to replace ContainerManifest + +// PodSpec is a description of a pod +type PodSpec struct { + Volumes []Volume `json:"volumes" yaml:"volumes"` + Containers []Container `json:"containers" yaml:"containers"` + RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" yaml:"restartPolicy,omitempty"` +} + +// BoundPod is a collection of containers that should be run on a host. A BoundPod +// defines how a Pod may change after a Binding is created. A Pod is a request to +// execute a pod, whereas a BoundPod is the specification that would be run on a server. +type BoundPod struct { + TypeMeta `json:",inline" yaml:",inline"` + + // Spec defines the behavior of a pod. + Spec PodSpec `json:"spec,omitempty" yaml:"spec,omitempty"` +} + +// BoundPods is a list of Pods bound to a common server. The resource version of +// the pod list is guaranteed to only change when the list of bound pods changes. +type BoundPods struct { + TypeMeta `json:",inline" yaml:",inline"` + + // Host is the name of a node that these pods were bound to. + Host string `json:"host" yaml:"host"` + + // Items is the list of all pods bound to a given host. + Items []BoundPod `json:"items" yaml:"items"` +} diff --git a/pkg/api/v1beta2/register.go b/pkg/api/v1beta2/register.go index 514c5d0b3a1..2a5439b87c5 100644 --- a/pkg/api/v1beta2/register.go +++ b/pkg/api/v1beta2/register.go @@ -43,6 +43,7 @@ func init() { &Event{}, &EventList{}, &ContainerManifestList{}, + &BoundPods{}, ) } @@ -63,3 +64,4 @@ func (*ServerOpList) IsAnAPIObject() {} func (*Event) IsAnAPIObject() {} func (*EventList) IsAnAPIObject() {} func (*ContainerManifestList) IsAnAPIObject() {} +func (*BoundPods) IsAnAPIObject() {} diff --git a/pkg/api/v1beta2/types.go b/pkg/api/v1beta2/types.go index d66983a6916..93f2710bd1b 100644 --- a/pkg/api/v1beta2/types.go +++ b/pkg/api/v1beta2/types.go @@ -45,30 +45,6 @@ import ( // or more simply: // DNS_LABEL(\.DNS_LABEL)* -// ContainerManifest corresponds to the Container Manifest format, documented at: -// https://developers.google.com/compute/docs/containers/container_vms#container_manifest -// This is used as the representation of Kubernetes workloads. -type ContainerManifest struct { - // Required: This must be a supported version string, such as "v1beta1". - Version string `yaml:"version" json:"version"` - // Required: This must be a DNS_SUBDOMAIN. - // TODO: ID on Manifest is deprecated and will be removed in the future. - ID string `yaml:"id" json:"id"` - // TODO: UUID on Manifest is deprecated in the future once we are done - // with the API refactoring. It is required for now to determine the instance - // of a Pod. - UUID string `yaml:"uuid,omitempty" json:"uuid,omitempty"` - Volumes []Volume `yaml:"volumes" json:"volumes"` - Containers []Container `yaml:"containers" json:"containers"` - RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" yaml:"restartPolicy,omitempty"` -} - -// ContainerManifestList is used to communicate container manifests to kubelet. -type ContainerManifestList struct { - TypeMeta `json:",inline" yaml:",inline"` - Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"` -} - // Volume represents a named volume in a pod that may be accessed by any containers in the pod. type Volume struct { // Required: This must be a DNS_LABEL. Each volume in a pod must have @@ -710,3 +686,60 @@ type EventList struct { TypeMeta `yaml:",inline" json:",inline"` Items []Event `yaml:"items,omitempty" json:"items,omitempty"` } + +// ContainerManifest corresponds to the Container Manifest format, documented at: +// https://developers.google.com/compute/docs/containers/container_vms#container_manifest +// This is used as the representation of Kubernetes workloads. +// DEPRECATED: Replaced with BoundPod +type ContainerManifest struct { + // Required: This must be a supported version string, such as "v1beta1". + Version string `yaml:"version" json:"version"` + // Required: This must be a DNS_SUBDOMAIN. + // TODO: ID on Manifest is deprecated and will be removed in the future. + ID string `yaml:"id" json:"id"` + // TODO: UUID on Manifest is deprecated in the future once we are done + // with the API refactoring. It is required for now to determine the instance + // of a Pod. + UUID string `yaml:"uuid,omitempty" json:"uuid,omitempty"` + Volumes []Volume `yaml:"volumes" json:"volumes"` + Containers []Container `yaml:"containers" json:"containers"` + RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" yaml:"restartPolicy,omitempty"` +} + +// ContainerManifestList is used to communicate container manifests to kubelet. +// DEPRECATED: Replaced with BoundPods +type ContainerManifestList struct { + TypeMeta `json:",inline" yaml:",inline"` + Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"` +} + +// Backported from v1beta3 to replace ContainerManifest + +// PodSpec is a description of a pod +type PodSpec struct { + Volumes []Volume `json:"volumes" yaml:"volumes"` + Containers []Container `json:"containers" yaml:"containers"` + RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" yaml:"restartPolicy,omitempty"` +} + +// BoundPod is a collection of containers that should be run on a host. A BoundPod +// defines how a Pod may change after a Binding is created. A Pod is a request to +// execute a pod, whereas a BoundPod is the specification that would be run on a server. +type BoundPod struct { + TypeMeta `json:",inline" yaml:",inline"` + + // Spec defines the behavior of a pod. + Spec PodSpec `json:"spec,omitempty" yaml:"spec,omitempty"` +} + +// BoundPods is a list of Pods bound to a common server. The resource version of +// the pod list is guaranteed to only change when the list of bound pods changes. +type BoundPods struct { + TypeMeta `json:",inline" yaml:",inline"` + + // Host is the name of a node that these pods were bound to. + Host string `json:"host" yaml:"host"` + + // Items is the list of all pods bound to a given host. + Items []BoundPod `json:"items" yaml:"items"` +}