From 2fc8ca55a5a01d2be49ffaae8446f06c909d30bd Mon Sep 17 00:00:00 2001 From: Robert Bailey Date: Mon, 19 Mar 2018 13:45:18 -0700 Subject: [PATCH 1/3] Add a machine class resource. --- .../apis/cluster/v1alpha1/machine_types.go | 19 +++++- .../cluster/v1alpha1/machineclass_types.go | 64 +++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 cluster-api/pkg/apis/cluster/v1alpha1/machineclass_types.go diff --git a/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go b/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go index 8716bb97e..198feddad 100644 --- a/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go +++ b/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go @@ -107,7 +107,24 @@ type ProviderConfig struct { // ProviderConfigSource represents a source for the provider-specific // node configuration. type ProviderConfigSource struct { - // TODO(roberthbailey): Fill these in later + + // No more than one of the following may be specified. + + // The machine class from which the provider config should be sourced. + // +optional + MachineClass *MachineClassRef `json:machineClass,omitempty` +} + +type MachineClassRef struct { + // The name of the MachineClass. + Name string `json:name` + + // Parameters allow basic substitution to be applied to + // a MachineClass (where supported). + // Keys must not be empty. The maximum number of + // parameters is 512, with a cumulative max size of 256K. + // +optional + Parameters map[string]string `json:parameters,omitempty` } // MachineStatus defines the observed state of Machine diff --git a/cluster-api/pkg/apis/cluster/v1alpha1/machineclass_types.go b/cluster-api/pkg/apis/cluster/v1alpha1/machineclass_types.go new file mode 100644 index 000000000..971046fd2 --- /dev/null +++ b/cluster-api/pkg/apis/cluster/v1alpha1/machineclass_types.go @@ -0,0 +1,64 @@ + +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + + +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// MachineClass can be used to templatize and re-use provider configuration +// across multiple Machines / MachineSets / MachineDeployments. +// +k8s:openapi-gen=true +// +resource:path=machineclasses +type MachineClass struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // The total capacity available on this machine type (cpu/memory/disk). + // + // WARNING: It is up to the creator of the MachineClass to ensure that + // this field is consistent with the underlying machine that will + // be provisioned when this class is used, to inform higher level + // automation (e.g. the cluster autoscaler). + Capacity corev1.ResourceList `json:"capacity"` + + // How much capacity is actually allocatable on this machine. + // Must be equal to or less than the capacity, and when less + // indicates the resources reserved for system overhead. + // + // WARNING: It is up to the creator of the MachineClass to ensure that + // this field is consistent with the underlying machine that will + // be provisioned when this class is used, to inform higher level + // automation (e.g. the cluster autoscaler). + Allocatable corev1.ResourceList `json:"allocatable"` + + // Provider-specific configuration to use during node creation. + ProviderConfig runtime.RawExtension `json:"providerConfig"` + + // TODO: should this use an api.ObjectReference to a 'MachineTemplate' instead? + // A link to the MachineTemplate that will be used to create provider + // specific configuration for Machines of this class. + // MachineTemplate corev1.ObjectReference `json:machineTemplate` +} From ecdb9c67e22f72adefb743148bac65c21f4dca94 Mon Sep 17 00:00:00 2001 From: Robert Bailey Date: Fri, 23 Mar 2018 10:19:15 -0700 Subject: [PATCH 2/3] Generated code for MachineClass. Created by running: ``` apiserver-boot build generated --generator client --generator deepcopy --generator conversion --generator apiregister --generator openapi ``` using the v0.1-alpha.27 release of apiserver-boot and then manually deleting the generated code for the unversioned client and shared informer. Also had to manually delete the generated code for api registration that assumes every resource will have a spec and status. --- .../v1alpha1/zz_generated.api.register.go | 40 +++ .../v1alpha1/zz_generated.conversion.go | 122 +++++++++ .../cluster/v1alpha1/zz_generated.deepcopy.go | 122 ++++++++- .../apis/cluster/zz_generated.api.register.go | 130 ++++++++++ .../pkg/apis/cluster/zz_generated.deepcopy.go | 122 ++++++++- .../typed/cluster/v1alpha1/cluster_client.go | 5 + .../v1alpha1/fake/fake_cluster_client.go | 4 + .../v1alpha1/fake/fake_machineclass.go | 125 ++++++++++ .../cluster/v1alpha1/generated_expansion.go | 2 + .../typed/cluster/v1alpha1/machineclass.go | 154 ++++++++++++ .../cluster/v1alpha1/interface.go | 7 + .../cluster/v1alpha1/machineclass.go | 73 ++++++ .../externalversions/generic.go | 2 + .../internalversion/expansion_generated.go | 8 + .../cluster/internalversion/machineclass.go | 94 +++++++ .../cluster/v1alpha1/expansion_generated.go | 8 + .../cluster/v1alpha1/machineclass.go | 94 +++++++ cluster-api/pkg/openapi/openapi_generated.go | 232 +++++++++++++++++- 18 files changed, 1338 insertions(+), 6 deletions(-) create mode 100644 cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake/fake_machineclass.go create mode 100644 cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/machineclass.go create mode 100644 cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1/machineclass.go create mode 100644 cluster-api/pkg/client/listers_generated/cluster/internalversion/machineclass.go create mode 100644 cluster-api/pkg/client/listers_generated/cluster/v1alpha1/machineclass.go diff --git a/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.api.register.go b/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.api.register.go index 97f144e0f..02b31e696 100644 --- a/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.api.register.go +++ b/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.api.register.go @@ -41,6 +41,13 @@ var ( func() runtime.Object { return &MachineList{} }, // Register versioned resource list &MachineStrategy{builders.StorageStrategySingleton}, ) + clusterMachineClassStorage = builders.NewApiResource( // Resource status endpoint + cluster.InternalMachineClass, + MachineClassSchemeFns{}, + func() runtime.Object { return &MachineClass{} }, // Register versioned resource + func() runtime.Object { return &MachineClassList{} }, // Register versioned resource list + &cluster.MachineClassStrategy{builders.StorageStrategySingleton}, + ) clusterMachineSetStorage = builders.NewApiResource( // Resource status endpoint cluster.InternalMachineSet, MachineSetSchemeFns{}, @@ -63,6 +70,13 @@ var ( func() runtime.Object { return &Machine{} }, // Register versioned resource func() runtime.Object { return &MachineList{} }, // Register versioned resource list &MachineStatusStrategy{builders.StatusStorageStrategySingleton}, + ), clusterMachineClassStorage, + builders.NewApiResource( // Resource status endpoint + cluster.InternalMachineClassStatus, + MachineClassSchemeFns{}, + func() runtime.Object { return &MachineClass{} }, // Register versioned resource + func() runtime.Object { return &MachineClassList{} }, // Register versioned resource list + &cluster.MachineClassStatusStrategy{builders.StatusStorageStrategySingleton}, ), clusterMachineSetStorage, builders.NewApiResource( // Resource status endpoint cluster.InternalMachineSetStatus, @@ -143,6 +157,32 @@ type MachineList struct { Items []Machine `json:"items"` } +// +// MachineClass Functions and Structs +// +// +k8s:deepcopy-gen=false +type MachineClassSchemeFns struct { + builders.DefaultSchemeFns +} + +// +k8s:deepcopy-gen=false +type MachineClassStrategy struct { + builders.DefaultStorageStrategy +} + +// +k8s:deepcopy-gen=false +type MachineClassStatusStrategy struct { + builders.DefaultStatusStorageStrategy +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type MachineClassList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []MachineClass `json:"items"` +} + // // MachineSet Functions and Structs // diff --git a/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go b/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go index 96b0760f0..93c0f4b8f 100644 --- a/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go +++ b/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.conversion.go @@ -57,6 +57,16 @@ func RegisterConversions(scheme *runtime.Scheme) error { Convert_cluster_ContainerRuntimeInfo_To_v1alpha1_ContainerRuntimeInfo, Convert_v1alpha1_Machine_To_cluster_Machine, Convert_cluster_Machine_To_v1alpha1_Machine, + Convert_v1alpha1_MachineClass_To_cluster_MachineClass, + Convert_cluster_MachineClass_To_v1alpha1_MachineClass, + Convert_v1alpha1_MachineClassList_To_cluster_MachineClassList, + Convert_cluster_MachineClassList_To_v1alpha1_MachineClassList, + Convert_v1alpha1_MachineClassRef_To_cluster_MachineClassRef, + Convert_cluster_MachineClassRef_To_v1alpha1_MachineClassRef, + Convert_v1alpha1_MachineClassStatusStrategy_To_cluster_MachineClassStatusStrategy, + Convert_cluster_MachineClassStatusStrategy_To_v1alpha1_MachineClassStatusStrategy, + Convert_v1alpha1_MachineClassStrategy_To_cluster_MachineClassStrategy, + Convert_cluster_MachineClassStrategy_To_v1alpha1_MachineClassStrategy, Convert_v1alpha1_MachineList_To_cluster_MachineList, Convert_cluster_MachineList_To_v1alpha1_MachineList, Convert_v1alpha1_MachineSet_To_cluster_MachineSet, @@ -346,6 +356,116 @@ func Convert_cluster_Machine_To_v1alpha1_Machine(in *cluster.Machine, out *Machi return autoConvert_cluster_Machine_To_v1alpha1_Machine(in, out, s) } +func autoConvert_v1alpha1_MachineClass_To_cluster_MachineClass(in *MachineClass, out *cluster.MachineClass, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Capacity = *(*v1.ResourceList)(unsafe.Pointer(&in.Capacity)) + out.Allocatable = *(*v1.ResourceList)(unsafe.Pointer(&in.Allocatable)) + out.ProviderConfig = in.ProviderConfig + return nil +} + +// Convert_v1alpha1_MachineClass_To_cluster_MachineClass is an autogenerated conversion function. +func Convert_v1alpha1_MachineClass_To_cluster_MachineClass(in *MachineClass, out *cluster.MachineClass, s conversion.Scope) error { + return autoConvert_v1alpha1_MachineClass_To_cluster_MachineClass(in, out, s) +} + +func autoConvert_cluster_MachineClass_To_v1alpha1_MachineClass(in *cluster.MachineClass, out *MachineClass, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.Capacity = *(*v1.ResourceList)(unsafe.Pointer(&in.Capacity)) + out.Allocatable = *(*v1.ResourceList)(unsafe.Pointer(&in.Allocatable)) + out.ProviderConfig = in.ProviderConfig + return nil +} + +// Convert_cluster_MachineClass_To_v1alpha1_MachineClass is an autogenerated conversion function. +func Convert_cluster_MachineClass_To_v1alpha1_MachineClass(in *cluster.MachineClass, out *MachineClass, s conversion.Scope) error { + return autoConvert_cluster_MachineClass_To_v1alpha1_MachineClass(in, out, s) +} + +func autoConvert_v1alpha1_MachineClassList_To_cluster_MachineClassList(in *MachineClassList, out *cluster.MachineClassList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]cluster.MachineClass)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_MachineClassList_To_cluster_MachineClassList is an autogenerated conversion function. +func Convert_v1alpha1_MachineClassList_To_cluster_MachineClassList(in *MachineClassList, out *cluster.MachineClassList, s conversion.Scope) error { + return autoConvert_v1alpha1_MachineClassList_To_cluster_MachineClassList(in, out, s) +} + +func autoConvert_cluster_MachineClassList_To_v1alpha1_MachineClassList(in *cluster.MachineClassList, out *MachineClassList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]MachineClass)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_cluster_MachineClassList_To_v1alpha1_MachineClassList is an autogenerated conversion function. +func Convert_cluster_MachineClassList_To_v1alpha1_MachineClassList(in *cluster.MachineClassList, out *MachineClassList, s conversion.Scope) error { + return autoConvert_cluster_MachineClassList_To_v1alpha1_MachineClassList(in, out, s) +} + +func autoConvert_v1alpha1_MachineClassRef_To_cluster_MachineClassRef(in *MachineClassRef, out *cluster.MachineClassRef, s conversion.Scope) error { + out.Name = in.Name + out.Parameters = *(*map[string]string)(unsafe.Pointer(&in.Parameters)) + return nil +} + +// Convert_v1alpha1_MachineClassRef_To_cluster_MachineClassRef is an autogenerated conversion function. +func Convert_v1alpha1_MachineClassRef_To_cluster_MachineClassRef(in *MachineClassRef, out *cluster.MachineClassRef, s conversion.Scope) error { + return autoConvert_v1alpha1_MachineClassRef_To_cluster_MachineClassRef(in, out, s) +} + +func autoConvert_cluster_MachineClassRef_To_v1alpha1_MachineClassRef(in *cluster.MachineClassRef, out *MachineClassRef, s conversion.Scope) error { + out.Name = in.Name + out.Parameters = *(*map[string]string)(unsafe.Pointer(&in.Parameters)) + return nil +} + +// Convert_cluster_MachineClassRef_To_v1alpha1_MachineClassRef is an autogenerated conversion function. +func Convert_cluster_MachineClassRef_To_v1alpha1_MachineClassRef(in *cluster.MachineClassRef, out *MachineClassRef, s conversion.Scope) error { + return autoConvert_cluster_MachineClassRef_To_v1alpha1_MachineClassRef(in, out, s) +} + +func autoConvert_v1alpha1_MachineClassStatusStrategy_To_cluster_MachineClassStatusStrategy(in *MachineClassStatusStrategy, out *cluster.MachineClassStatusStrategy, s conversion.Scope) error { + out.DefaultStatusStorageStrategy = in.DefaultStatusStorageStrategy + return nil +} + +// Convert_v1alpha1_MachineClassStatusStrategy_To_cluster_MachineClassStatusStrategy is an autogenerated conversion function. +func Convert_v1alpha1_MachineClassStatusStrategy_To_cluster_MachineClassStatusStrategy(in *MachineClassStatusStrategy, out *cluster.MachineClassStatusStrategy, s conversion.Scope) error { + return autoConvert_v1alpha1_MachineClassStatusStrategy_To_cluster_MachineClassStatusStrategy(in, out, s) +} + +func autoConvert_cluster_MachineClassStatusStrategy_To_v1alpha1_MachineClassStatusStrategy(in *cluster.MachineClassStatusStrategy, out *MachineClassStatusStrategy, s conversion.Scope) error { + out.DefaultStatusStorageStrategy = in.DefaultStatusStorageStrategy + return nil +} + +// Convert_cluster_MachineClassStatusStrategy_To_v1alpha1_MachineClassStatusStrategy is an autogenerated conversion function. +func Convert_cluster_MachineClassStatusStrategy_To_v1alpha1_MachineClassStatusStrategy(in *cluster.MachineClassStatusStrategy, out *MachineClassStatusStrategy, s conversion.Scope) error { + return autoConvert_cluster_MachineClassStatusStrategy_To_v1alpha1_MachineClassStatusStrategy(in, out, s) +} + +func autoConvert_v1alpha1_MachineClassStrategy_To_cluster_MachineClassStrategy(in *MachineClassStrategy, out *cluster.MachineClassStrategy, s conversion.Scope) error { + out.DefaultStorageStrategy = in.DefaultStorageStrategy + return nil +} + +// Convert_v1alpha1_MachineClassStrategy_To_cluster_MachineClassStrategy is an autogenerated conversion function. +func Convert_v1alpha1_MachineClassStrategy_To_cluster_MachineClassStrategy(in *MachineClassStrategy, out *cluster.MachineClassStrategy, s conversion.Scope) error { + return autoConvert_v1alpha1_MachineClassStrategy_To_cluster_MachineClassStrategy(in, out, s) +} + +func autoConvert_cluster_MachineClassStrategy_To_v1alpha1_MachineClassStrategy(in *cluster.MachineClassStrategy, out *MachineClassStrategy, s conversion.Scope) error { + out.DefaultStorageStrategy = in.DefaultStorageStrategy + return nil +} + +// Convert_cluster_MachineClassStrategy_To_v1alpha1_MachineClassStrategy is an autogenerated conversion function. +func Convert_cluster_MachineClassStrategy_To_v1alpha1_MachineClassStrategy(in *cluster.MachineClassStrategy, out *MachineClassStrategy, s conversion.Scope) error { + return autoConvert_cluster_MachineClassStrategy_To_v1alpha1_MachineClassStrategy(in, out, s) +} + func autoConvert_v1alpha1_MachineList_To_cluster_MachineList(in *MachineList, out *cluster.MachineList, s conversion.Scope) error { out.ListMeta = in.ListMeta out.Items = *(*[]cluster.Machine)(unsafe.Pointer(&in.Items)) @@ -727,6 +847,7 @@ func Convert_cluster_ProviderConfig_To_v1alpha1_ProviderConfig(in *cluster.Provi } func autoConvert_v1alpha1_ProviderConfigSource_To_cluster_ProviderConfigSource(in *ProviderConfigSource, out *cluster.ProviderConfigSource, s conversion.Scope) error { + out.MachineClass = (*cluster.MachineClassRef)(unsafe.Pointer(in.MachineClass)) return nil } @@ -736,6 +857,7 @@ func Convert_v1alpha1_ProviderConfigSource_To_cluster_ProviderConfigSource(in *P } func autoConvert_cluster_ProviderConfigSource_To_v1alpha1_ProviderConfigSource(in *cluster.ProviderConfigSource, out *ProviderConfigSource, s conversion.Scope) error { + out.MachineClass = (*MachineClassRef)(unsafe.Pointer(in.MachineClass)) return nil } diff --git a/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go b/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go index fbcfbd7ee..35b4e196b 100644 --- a/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go +++ b/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go @@ -70,6 +70,18 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*Machine).DeepCopyInto(out.(*Machine)) return nil }, InType: reflect.TypeOf(&Machine{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*MachineClass).DeepCopyInto(out.(*MachineClass)) + return nil + }, InType: reflect.TypeOf(&MachineClass{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*MachineClassList).DeepCopyInto(out.(*MachineClassList)) + return nil + }, InType: reflect.TypeOf(&MachineClassList{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*MachineClassRef).DeepCopyInto(out.(*MachineClassRef)) + return nil + }, InType: reflect.TypeOf(&MachineClassRef{})}, conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { in.(*MachineList).DeepCopyInto(out.(*MachineList)) return nil @@ -301,6 +313,105 @@ func (in *Machine) DeepCopyObject() runtime.Object { } } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineClass) DeepCopyInto(out *MachineClass) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Capacity != nil { + in, out := &in.Capacity, &out.Capacity + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + if in.Allocatable != nil { + in, out := &in.Allocatable, &out.Allocatable + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + in.ProviderConfig.DeepCopyInto(&out.ProviderConfig) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineClass. +func (in *MachineClass) DeepCopy() *MachineClass { + if in == nil { + return nil + } + out := new(MachineClass) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MachineClass) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineClassList) DeepCopyInto(out *MachineClassList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]MachineClass, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineClassList. +func (in *MachineClassList) DeepCopy() *MachineClassList { + if in == nil { + return nil + } + out := new(MachineClassList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MachineClassList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineClassRef) DeepCopyInto(out *MachineClassRef) { + *out = *in + if in.Parameters != nil { + in, out := &in.Parameters, &out.Parameters + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineClassRef. +func (in *MachineClassRef) DeepCopy() *MachineClassRef { + if in == nil { + return nil + } + out := new(MachineClassRef) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineList) DeepCopyInto(out *MachineList) { *out = *in @@ -626,7 +737,7 @@ func (in *ProviderConfig) DeepCopyInto(out *ProviderConfig) { *out = nil } else { *out = new(ProviderConfigSource) - **out = **in + (*in).DeepCopyInto(*out) } } return @@ -645,6 +756,15 @@ func (in *ProviderConfig) DeepCopy() *ProviderConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ProviderConfigSource) DeepCopyInto(out *ProviderConfigSource) { *out = *in + if in.MachineClass != nil { + in, out := &in.MachineClass, &out.MachineClass + if *in == nil { + *out = nil + } else { + *out = new(MachineClassRef) + (*in).DeepCopyInto(*out) + } + } return } diff --git a/cluster-api/pkg/apis/cluster/zz_generated.api.register.go b/cluster-api/pkg/apis/cluster/zz_generated.api.register.go index d7536b00a..2b877fc4b 100644 --- a/cluster-api/pkg/apis/cluster/zz_generated.api.register.go +++ b/cluster-api/pkg/apis/cluster/zz_generated.api.register.go @@ -53,6 +53,16 @@ var ( func() runtime.Object { return &Machine{} }, func() runtime.Object { return &MachineList{} }, ) + InternalMachineClass = builders.NewInternalResource( + "machineclasses", + func() runtime.Object { return &MachineClass{} }, + func() runtime.Object { return &MachineClassList{} }, + ) + InternalMachineClassStatus = builders.NewInternalResourceStatus( + "machineclasses", + func() runtime.Object { return &MachineClass{} }, + func() runtime.Object { return &MachineClassList{} }, + ) InternalMachineSet = builders.NewInternalResource( "machinesets", func() runtime.Object { return &MachineSet{} }, @@ -69,6 +79,8 @@ var ( InternalClusterStatus, InternalMachine, InternalMachineStatus, + InternalMachineClass, + InternalMachineClassStatus, InternalMachineSet, InternalMachineSetStatus, ) @@ -96,6 +108,18 @@ func Resource(resource string) schema.GroupResource { // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type MachineClass struct { + metav1.TypeMeta + metav1.ObjectMeta + Capacity corev1.ResourceList + Allocatable corev1.ResourceList + ProviderConfig pkgruntime.RawExtension +} + +// +genclient +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + type Machine struct { metav1.TypeMeta metav1.ObjectMeta @@ -186,6 +210,7 @@ type MachineSet struct { } type ProviderConfigSource struct { + MachineClass *MachineClassRef } type MachineSetStatus struct { @@ -198,6 +223,11 @@ type MachineSetStatus struct { ErrorMessage *string } +type MachineClassRef struct { + Name string + Parameters map[string]string +} + type MachineSetSpec struct { Replicas *int32 MinReadySeconds int32 @@ -450,6 +480,106 @@ func (s *storageMachine) DeleteMachine(ctx request.Context, id string) (bool, er return sync, err } +// +// MachineClass Functions and Structs +// +// +k8s:deepcopy-gen=false +type MachineClassStrategy struct { + builders.DefaultStorageStrategy +} + +// +k8s:deepcopy-gen=false +type MachineClassStatusStrategy struct { + builders.DefaultStatusStorageStrategy +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type MachineClassList struct { + metav1.TypeMeta + metav1.ListMeta + Items []MachineClass +} + +func (pc *MachineClass) GetObjectMeta() *metav1.ObjectMeta { + return &pc.ObjectMeta +} + +func (pc *MachineClass) SetGeneration(generation int64) { + pc.ObjectMeta.Generation = generation +} + +func (pc MachineClass) GetGeneration() int64 { + return pc.ObjectMeta.Generation +} + +// Registry is an interface for things that know how to store MachineClass. +// +k8s:deepcopy-gen=false +type MachineClassRegistry interface { + ListMachineClasss(ctx request.Context, options *internalversion.ListOptions) (*MachineClassList, error) + GetMachineClass(ctx request.Context, id string, options *metav1.GetOptions) (*MachineClass, error) + CreateMachineClass(ctx request.Context, id *MachineClass) (*MachineClass, error) + UpdateMachineClass(ctx request.Context, id *MachineClass) (*MachineClass, error) + DeleteMachineClass(ctx request.Context, id string) (bool, error) +} + +// NewRegistry returns a new Registry interface for the given Storage. Any mismatched types will panic. +func NewMachineClassRegistry(sp builders.StandardStorageProvider) MachineClassRegistry { + return &storageMachineClass{sp} +} + +// Implement Registry +// storage puts strong typing around storage calls +// +k8s:deepcopy-gen=false +type storageMachineClass struct { + builders.StandardStorageProvider +} + +func (s *storageMachineClass) ListMachineClasss(ctx request.Context, options *internalversion.ListOptions) (*MachineClassList, error) { + if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { + return nil, fmt.Errorf("field selector not supported yet") + } + st := s.GetStandardStorage() + obj, err := st.List(ctx, options) + if err != nil { + return nil, err + } + return obj.(*MachineClassList), err +} + +func (s *storageMachineClass) GetMachineClass(ctx request.Context, id string, options *metav1.GetOptions) (*MachineClass, error) { + st := s.GetStandardStorage() + obj, err := st.Get(ctx, id, options) + if err != nil { + return nil, err + } + return obj.(*MachineClass), nil +} + +func (s *storageMachineClass) CreateMachineClass(ctx request.Context, object *MachineClass) (*MachineClass, error) { + st := s.GetStandardStorage() + obj, err := st.Create(ctx, object, false) + if err != nil { + return nil, err + } + return obj.(*MachineClass), nil +} + +func (s *storageMachineClass) UpdateMachineClass(ctx request.Context, object *MachineClass) (*MachineClass, error) { + st := s.GetStandardStorage() + obj, _, err := st.Update(ctx, object.Name, rest.DefaultUpdatedObjectInfo(object, builders.Scheme)) + if err != nil { + return nil, err + } + return obj.(*MachineClass), nil +} + +func (s *storageMachineClass) DeleteMachineClass(ctx request.Context, id string) (bool, error) { + st := s.GetStandardStorage() + _, sync, err := st.Delete(ctx, id, nil) + return sync, err +} + // // MachineSet Functions and Structs // diff --git a/cluster-api/pkg/apis/cluster/zz_generated.deepcopy.go b/cluster-api/pkg/apis/cluster/zz_generated.deepcopy.go index bbe0a9daf..2910dd74f 100644 --- a/cluster-api/pkg/apis/cluster/zz_generated.deepcopy.go +++ b/cluster-api/pkg/apis/cluster/zz_generated.deepcopy.go @@ -70,6 +70,18 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*Machine).DeepCopyInto(out.(*Machine)) return nil }, InType: reflect.TypeOf(&Machine{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*MachineClass).DeepCopyInto(out.(*MachineClass)) + return nil + }, InType: reflect.TypeOf(&MachineClass{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*MachineClassList).DeepCopyInto(out.(*MachineClassList)) + return nil + }, InType: reflect.TypeOf(&MachineClassList{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*MachineClassRef).DeepCopyInto(out.(*MachineClassRef)) + return nil + }, InType: reflect.TypeOf(&MachineClassRef{})}, conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { in.(*MachineList).DeepCopyInto(out.(*MachineList)) return nil @@ -301,6 +313,105 @@ func (in *Machine) DeepCopyObject() runtime.Object { } } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineClass) DeepCopyInto(out *MachineClass) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Capacity != nil { + in, out := &in.Capacity, &out.Capacity + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + if in.Allocatable != nil { + in, out := &in.Allocatable, &out.Allocatable + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + in.ProviderConfig.DeepCopyInto(&out.ProviderConfig) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineClass. +func (in *MachineClass) DeepCopy() *MachineClass { + if in == nil { + return nil + } + out := new(MachineClass) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MachineClass) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineClassList) DeepCopyInto(out *MachineClassList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]MachineClass, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineClassList. +func (in *MachineClassList) DeepCopy() *MachineClassList { + if in == nil { + return nil + } + out := new(MachineClassList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MachineClassList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineClassRef) DeepCopyInto(out *MachineClassRef) { + *out = *in + if in.Parameters != nil { + in, out := &in.Parameters, &out.Parameters + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineClassRef. +func (in *MachineClassRef) DeepCopy() *MachineClassRef { + if in == nil { + return nil + } + out := new(MachineClassRef) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineList) DeepCopyInto(out *MachineList) { *out = *in @@ -626,7 +737,7 @@ func (in *ProviderConfig) DeepCopyInto(out *ProviderConfig) { *out = nil } else { *out = new(ProviderConfigSource) - **out = **in + (*in).DeepCopyInto(*out) } } return @@ -645,6 +756,15 @@ func (in *ProviderConfig) DeepCopy() *ProviderConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ProviderConfigSource) DeepCopyInto(out *ProviderConfigSource) { *out = *in + if in.MachineClass != nil { + in, out := &in.MachineClass, &out.MachineClass + if *in == nil { + *out = nil + } else { + *out = new(MachineClassRef) + (*in).DeepCopyInto(*out) + } + } return } diff --git a/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/cluster_client.go b/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/cluster_client.go index d138b32c0..067a4b3b8 100644 --- a/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/cluster_client.go +++ b/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/cluster_client.go @@ -26,6 +26,7 @@ type ClusterV1alpha1Interface interface { RESTClient() rest.Interface ClustersGetter MachinesGetter + MachineClassesGetter MachineSetsGetter } @@ -42,6 +43,10 @@ func (c *ClusterV1alpha1Client) Machines(namespace string) MachineInterface { return newMachines(c, namespace) } +func (c *ClusterV1alpha1Client) MachineClasses(namespace string) MachineClassInterface { + return newMachineClasses(c, namespace) +} + func (c *ClusterV1alpha1Client) MachineSets(namespace string) MachineSetInterface { return newMachineSets(c, namespace) } diff --git a/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake/fake_cluster_client.go b/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake/fake_cluster_client.go index 094638cf0..716e97317 100644 --- a/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake/fake_cluster_client.go +++ b/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake/fake_cluster_client.go @@ -33,6 +33,10 @@ func (c *FakeClusterV1alpha1) Machines(namespace string) v1alpha1.MachineInterfa return &FakeMachines{c, namespace} } +func (c *FakeClusterV1alpha1) MachineClasses(namespace string) v1alpha1.MachineClassInterface { + return &FakeMachineClasses{c, namespace} +} + func (c *FakeClusterV1alpha1) MachineSets(namespace string) v1alpha1.MachineSetInterface { return &FakeMachineSets{c, namespace} } diff --git a/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake/fake_machineclass.go b/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake/fake_machineclass.go new file mode 100644 index 000000000..1aea7bdd5 --- /dev/null +++ b/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake/fake_machineclass.go @@ -0,0 +1,125 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1alpha1 "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1" +) + +// FakeMachineClasses implements MachineClassInterface +type FakeMachineClasses struct { + Fake *FakeClusterV1alpha1 + ns string +} + +var machineclassesResource = schema.GroupVersionResource{Group: "cluster.k8s.io", Version: "v1alpha1", Resource: "machineclasses"} + +var machineclassesKind = schema.GroupVersionKind{Group: "cluster.k8s.io", Version: "v1alpha1", Kind: "MachineClass"} + +// Get takes name of the machineClass, and returns the corresponding machineClass object, and an error if there is any. +func (c *FakeMachineClasses) Get(name string, options v1.GetOptions) (result *v1alpha1.MachineClass, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(machineclassesResource, c.ns, name), &v1alpha1.MachineClass{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MachineClass), err +} + +// List takes label and field selectors, and returns the list of MachineClasses that match those selectors. +func (c *FakeMachineClasses) List(opts v1.ListOptions) (result *v1alpha1.MachineClassList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(machineclassesResource, machineclassesKind, c.ns, opts), &v1alpha1.MachineClassList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.MachineClassList{} + for _, item := range obj.(*v1alpha1.MachineClassList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested machineClasses. +func (c *FakeMachineClasses) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(machineclassesResource, c.ns, opts)) + +} + +// Create takes the representation of a machineClass and creates it. Returns the server's representation of the machineClass, and an error, if there is any. +func (c *FakeMachineClasses) Create(machineClass *v1alpha1.MachineClass) (result *v1alpha1.MachineClass, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(machineclassesResource, c.ns, machineClass), &v1alpha1.MachineClass{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MachineClass), err +} + +// Update takes the representation of a machineClass and updates it. Returns the server's representation of the machineClass, and an error, if there is any. +func (c *FakeMachineClasses) Update(machineClass *v1alpha1.MachineClass) (result *v1alpha1.MachineClass, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(machineclassesResource, c.ns, machineClass), &v1alpha1.MachineClass{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MachineClass), err +} + +// Delete takes name of the machineClass and deletes it. Returns an error if one occurs. +func (c *FakeMachineClasses) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(machineclassesResource, c.ns, name), &v1alpha1.MachineClass{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeMachineClasses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(machineclassesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.MachineClassList{}) + return err +} + +// Patch applies the patch and returns the patched machineClass. +func (c *FakeMachineClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MachineClass, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(machineclassesResource, c.ns, name, data, subresources...), &v1alpha1.MachineClass{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MachineClass), err +} diff --git a/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/generated_expansion.go b/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/generated_expansion.go index 51ff22b81..625d29cd9 100644 --- a/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/generated_expansion.go +++ b/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/generated_expansion.go @@ -19,4 +19,6 @@ type ClusterExpansion interface{} type MachineExpansion interface{} +type MachineClassExpansion interface{} + type MachineSetExpansion interface{} diff --git a/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/machineclass.go b/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/machineclass.go new file mode 100644 index 000000000..02cd0e98e --- /dev/null +++ b/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/machineclass.go @@ -0,0 +1,154 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1alpha1 "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1" + scheme "k8s.io/kube-deploy/cluster-api/pkg/client/clientset_generated/clientset/scheme" +) + +// MachineClassesGetter has a method to return a MachineClassInterface. +// A group's client should implement this interface. +type MachineClassesGetter interface { + MachineClasses(namespace string) MachineClassInterface +} + +// MachineClassInterface has methods to work with MachineClass resources. +type MachineClassInterface interface { + Create(*v1alpha1.MachineClass) (*v1alpha1.MachineClass, error) + Update(*v1alpha1.MachineClass) (*v1alpha1.MachineClass, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.MachineClass, error) + List(opts v1.ListOptions) (*v1alpha1.MachineClassList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MachineClass, err error) + MachineClassExpansion +} + +// machineClasses implements MachineClassInterface +type machineClasses struct { + client rest.Interface + ns string +} + +// newMachineClasses returns a MachineClasses +func newMachineClasses(c *ClusterV1alpha1Client, namespace string) *machineClasses { + return &machineClasses{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the machineClass, and returns the corresponding machineClass object, and an error if there is any. +func (c *machineClasses) Get(name string, options v1.GetOptions) (result *v1alpha1.MachineClass, err error) { + result = &v1alpha1.MachineClass{} + err = c.client.Get(). + Namespace(c.ns). + Resource("machineclasses"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of MachineClasses that match those selectors. +func (c *machineClasses) List(opts v1.ListOptions) (result *v1alpha1.MachineClassList, err error) { + result = &v1alpha1.MachineClassList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("machineclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested machineClasses. +func (c *machineClasses) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("machineclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a machineClass and creates it. Returns the server's representation of the machineClass, and an error, if there is any. +func (c *machineClasses) Create(machineClass *v1alpha1.MachineClass) (result *v1alpha1.MachineClass, err error) { + result = &v1alpha1.MachineClass{} + err = c.client.Post(). + Namespace(c.ns). + Resource("machineclasses"). + Body(machineClass). + Do(). + Into(result) + return +} + +// Update takes the representation of a machineClass and updates it. Returns the server's representation of the machineClass, and an error, if there is any. +func (c *machineClasses) Update(machineClass *v1alpha1.MachineClass) (result *v1alpha1.MachineClass, err error) { + result = &v1alpha1.MachineClass{} + err = c.client.Put(). + Namespace(c.ns). + Resource("machineclasses"). + Name(machineClass.Name). + Body(machineClass). + Do(). + Into(result) + return +} + +// Delete takes name of the machineClass and deletes it. Returns an error if one occurs. +func (c *machineClasses) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("machineclasses"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *machineClasses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("machineclasses"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched machineClass. +func (c *machineClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MachineClass, err error) { + result = &v1alpha1.MachineClass{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("machineclasses"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1/interface.go b/cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1/interface.go index f46ac455a..c11bee8ca 100644 --- a/cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1/interface.go +++ b/cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1/interface.go @@ -28,6 +28,8 @@ type Interface interface { Clusters() ClusterInformer // Machines returns a MachineInformer. Machines() MachineInformer + // MachineClasses returns a MachineClassInformer. + MachineClasses() MachineClassInformer // MachineSets returns a MachineSetInformer. MachineSets() MachineSetInformer } @@ -51,6 +53,11 @@ func (v *version) Machines() MachineInformer { return &machineInformer{factory: v.SharedInformerFactory} } +// MachineClasses returns a MachineClassInformer. +func (v *version) MachineClasses() MachineClassInformer { + return &machineClassInformer{factory: v.SharedInformerFactory} +} + // MachineSets returns a MachineSetInformer. func (v *version) MachineSets() MachineSetInformer { return &machineSetInformer{factory: v.SharedInformerFactory} diff --git a/cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1/machineclass.go b/cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1/machineclass.go new file mode 100644 index 000000000..4d6d2f279 --- /dev/null +++ b/cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1/machineclass.go @@ -0,0 +1,73 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file was automatically generated by informer-gen + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + cluster_v1alpha1 "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1" + clientset "k8s.io/kube-deploy/cluster-api/pkg/client/clientset_generated/clientset" + internalinterfaces "k8s.io/kube-deploy/cluster-api/pkg/client/informers_generated/externalversions/internalinterfaces" + v1alpha1 "k8s.io/kube-deploy/cluster-api/pkg/client/listers_generated/cluster/v1alpha1" + time "time" +) + +// MachineClassInformer provides access to a shared informer and lister for +// MachineClasses. +type MachineClassInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.MachineClassLister +} + +type machineClassInformer struct { + factory internalinterfaces.SharedInformerFactory +} + +// NewMachineClassInformer constructs a new informer for MachineClass type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewMachineClassInformer(client clientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + return client.ClusterV1alpha1().MachineClasses(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + return client.ClusterV1alpha1().MachineClasses(namespace).Watch(options) + }, + }, + &cluster_v1alpha1.MachineClass{}, + resyncPeriod, + indexers, + ) +} + +func defaultMachineClassInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewMachineClassInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) +} + +func (f *machineClassInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&cluster_v1alpha1.MachineClass{}, defaultMachineClassInformer) +} + +func (f *machineClassInformer) Lister() v1alpha1.MachineClassLister { + return v1alpha1.NewMachineClassLister(f.Informer().GetIndexer()) +} diff --git a/cluster-api/pkg/client/informers_generated/externalversions/generic.go b/cluster-api/pkg/client/informers_generated/externalversions/generic.go index a53bc53e0..890ab1d1f 100644 --- a/cluster-api/pkg/client/informers_generated/externalversions/generic.go +++ b/cluster-api/pkg/client/informers_generated/externalversions/generic.go @@ -56,6 +56,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1alpha1().Clusters().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("machines"): return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1alpha1().Machines().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("machineclasses"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1alpha1().MachineClasses().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("machinesets"): return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1alpha1().MachineSets().Informer()}, nil diff --git a/cluster-api/pkg/client/listers_generated/cluster/internalversion/expansion_generated.go b/cluster-api/pkg/client/listers_generated/cluster/internalversion/expansion_generated.go index a1707cc5a..b620cc0b0 100644 --- a/cluster-api/pkg/client/listers_generated/cluster/internalversion/expansion_generated.go +++ b/cluster-api/pkg/client/listers_generated/cluster/internalversion/expansion_generated.go @@ -34,6 +34,14 @@ type MachineListerExpansion interface{} // MachineNamespaceLister. type MachineNamespaceListerExpansion interface{} +// MachineClassListerExpansion allows custom methods to be added to +// MachineClassLister. +type MachineClassListerExpansion interface{} + +// MachineClassNamespaceListerExpansion allows custom methods to be added to +// MachineClassNamespaceLister. +type MachineClassNamespaceListerExpansion interface{} + // MachineSetListerExpansion allows custom methods to be added to // MachineSetLister. type MachineSetListerExpansion interface{} diff --git a/cluster-api/pkg/client/listers_generated/cluster/internalversion/machineclass.go b/cluster-api/pkg/client/listers_generated/cluster/internalversion/machineclass.go new file mode 100644 index 000000000..af7da6683 --- /dev/null +++ b/cluster-api/pkg/client/listers_generated/cluster/internalversion/machineclass.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file was automatically generated by lister-gen + +package internalversion + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + cluster "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster" +) + +// MachineClassLister helps list MachineClasses. +type MachineClassLister interface { + // List lists all MachineClasses in the indexer. + List(selector labels.Selector) (ret []*cluster.MachineClass, err error) + // MachineClasses returns an object that can list and get MachineClasses. + MachineClasses(namespace string) MachineClassNamespaceLister + MachineClassListerExpansion +} + +// machineClassLister implements the MachineClassLister interface. +type machineClassLister struct { + indexer cache.Indexer +} + +// NewMachineClassLister returns a new MachineClassLister. +func NewMachineClassLister(indexer cache.Indexer) MachineClassLister { + return &machineClassLister{indexer: indexer} +} + +// List lists all MachineClasses in the indexer. +func (s *machineClassLister) List(selector labels.Selector) (ret []*cluster.MachineClass, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*cluster.MachineClass)) + }) + return ret, err +} + +// MachineClasses returns an object that can list and get MachineClasses. +func (s *machineClassLister) MachineClasses(namespace string) MachineClassNamespaceLister { + return machineClassNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// MachineClassNamespaceLister helps list and get MachineClasses. +type MachineClassNamespaceLister interface { + // List lists all MachineClasses in the indexer for a given namespace. + List(selector labels.Selector) (ret []*cluster.MachineClass, err error) + // Get retrieves the MachineClass from the indexer for a given namespace and name. + Get(name string) (*cluster.MachineClass, error) + MachineClassNamespaceListerExpansion +} + +// machineClassNamespaceLister implements the MachineClassNamespaceLister +// interface. +type machineClassNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all MachineClasses in the indexer for a given namespace. +func (s machineClassNamespaceLister) List(selector labels.Selector) (ret []*cluster.MachineClass, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*cluster.MachineClass)) + }) + return ret, err +} + +// Get retrieves the MachineClass from the indexer for a given namespace and name. +func (s machineClassNamespaceLister) Get(name string) (*cluster.MachineClass, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(cluster.Resource("machineclass"), name) + } + return obj.(*cluster.MachineClass), nil +} diff --git a/cluster-api/pkg/client/listers_generated/cluster/v1alpha1/expansion_generated.go b/cluster-api/pkg/client/listers_generated/cluster/v1alpha1/expansion_generated.go index 098d5f673..a7ffe529a 100644 --- a/cluster-api/pkg/client/listers_generated/cluster/v1alpha1/expansion_generated.go +++ b/cluster-api/pkg/client/listers_generated/cluster/v1alpha1/expansion_generated.go @@ -34,6 +34,14 @@ type MachineListerExpansion interface{} // MachineNamespaceLister. type MachineNamespaceListerExpansion interface{} +// MachineClassListerExpansion allows custom methods to be added to +// MachineClassLister. +type MachineClassListerExpansion interface{} + +// MachineClassNamespaceListerExpansion allows custom methods to be added to +// MachineClassNamespaceLister. +type MachineClassNamespaceListerExpansion interface{} + // MachineSetListerExpansion allows custom methods to be added to // MachineSetLister. type MachineSetListerExpansion interface{} diff --git a/cluster-api/pkg/client/listers_generated/cluster/v1alpha1/machineclass.go b/cluster-api/pkg/client/listers_generated/cluster/v1alpha1/machineclass.go new file mode 100644 index 000000000..f766eabc3 --- /dev/null +++ b/cluster-api/pkg/client/listers_generated/cluster/v1alpha1/machineclass.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file was automatically generated by lister-gen + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1" +) + +// MachineClassLister helps list MachineClasses. +type MachineClassLister interface { + // List lists all MachineClasses in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.MachineClass, err error) + // MachineClasses returns an object that can list and get MachineClasses. + MachineClasses(namespace string) MachineClassNamespaceLister + MachineClassListerExpansion +} + +// machineClassLister implements the MachineClassLister interface. +type machineClassLister struct { + indexer cache.Indexer +} + +// NewMachineClassLister returns a new MachineClassLister. +func NewMachineClassLister(indexer cache.Indexer) MachineClassLister { + return &machineClassLister{indexer: indexer} +} + +// List lists all MachineClasses in the indexer. +func (s *machineClassLister) List(selector labels.Selector) (ret []*v1alpha1.MachineClass, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.MachineClass)) + }) + return ret, err +} + +// MachineClasses returns an object that can list and get MachineClasses. +func (s *machineClassLister) MachineClasses(namespace string) MachineClassNamespaceLister { + return machineClassNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// MachineClassNamespaceLister helps list and get MachineClasses. +type MachineClassNamespaceLister interface { + // List lists all MachineClasses in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.MachineClass, err error) + // Get retrieves the MachineClass from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.MachineClass, error) + MachineClassNamespaceListerExpansion +} + +// machineClassNamespaceLister implements the MachineClassNamespaceLister +// interface. +type machineClassNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all MachineClasses in the indexer for a given namespace. +func (s machineClassNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.MachineClass, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.MachineClass)) + }) + return ret, err +} + +// Get retrieves the MachineClass from the indexer for a given namespace and name. +func (s machineClassNamespaceLister) Get(name string) (*v1alpha1.MachineClass, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("machineclass"), name) + } + return obj.(*v1alpha1.MachineClass), nil +} diff --git a/cluster-api/pkg/openapi/openapi_generated.go b/cluster-api/pkg/openapi/openapi_generated.go index 7421978b9..1695bd9d3 100644 --- a/cluster-api/pkg/openapi/openapi_generated.go +++ b/cluster-api/pkg/openapi/openapi_generated.go @@ -21212,6 +21212,191 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA Dependencies: []string{ "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineSpec", "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineStatus"}, }, + "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineClass": { + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MachineClass can be used to templatize and re-use provider configuration across multiple Machines / MachineSets / MachineDeployments.", + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "capacity": { + SchemaProps: spec.SchemaProps{ + Description: "The total capacity available on this machine type (cpu/memory/disk).\n\nWARNING: It is up to the creator of the MachineClass to ensure that this field is consistent with the underlying machine that will be provisioned when this class is used, to inform higher level automation (e.g. the cluster autoscaler).", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "allocatable": { + SchemaProps: spec.SchemaProps{ + Description: "How much capacity is actually allocatable on this machine. Must be equal to or less than the capacity, and when less indicates the resources reserved for system overhead.\n\nWARNING: It is up to the creator of the MachineClass to ensure that this field is consistent with the underlying machine that will be provisioned when this class is used, to inform higher level automation (e.g. the cluster autoscaler).", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "providerConfig": { + SchemaProps: spec.SchemaProps{ + Description: "Provider-specific configuration to use during node creation.", + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + }, + Required: []string{"capacity", "allocatable", "providerConfig"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/api/resource.Quantity", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "k8s.io/apimachinery/pkg/runtime.RawExtension"}, + }, + "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineClassList": { + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineClass"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta", "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineClass"}, + }, + "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineClassRef": { + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Properties: map[string]spec.Schema{ + "Name": { + SchemaProps: spec.SchemaProps{ + Description: "The name of the MachineClass.", + Type: []string{"string"}, + Format: "", + }, + }, + "Parameters": { + SchemaProps: spec.SchemaProps{ + Description: "Parameters allow basic substitution to be applied to a MachineClass (where supported). Keys must not be empty. The maximum number of parameters is 512, with a cumulative max size of 256K.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"Name"}, + }, + }, + Dependencies: []string{}, + }, + "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineClassSchemeFns": { + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MachineClass Functions and Structs", + Properties: map[string]spec.Schema{ + "DefaultSchemeFns": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/kubernetes-incubator/apiserver-builder/pkg/builders.DefaultSchemeFns"), + }, + }, + }, + Required: []string{"DefaultSchemeFns"}, + }, + }, + Dependencies: []string{ + "github.com/kubernetes-incubator/apiserver-builder/pkg/builders.DefaultSchemeFns"}, + }, + "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineClassStatusStrategy": { + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Properties: map[string]spec.Schema{ + "DefaultStatusStorageStrategy": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/kubernetes-incubator/apiserver-builder/pkg/builders.DefaultStatusStorageStrategy"), + }, + }, + }, + Required: []string{"DefaultStatusStorageStrategy"}, + }, + }, + Dependencies: []string{ + "github.com/kubernetes-incubator/apiserver-builder/pkg/builders.DefaultStatusStorageStrategy"}, + }, + "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineClassStrategy": { + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Properties: map[string]spec.Schema{ + "DefaultStorageStrategy": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/kubernetes-incubator/apiserver-builder/pkg/builders.DefaultStorageStrategy"), + }, + }, + }, + Required: []string{"DefaultStorageStrategy"}, + }, + }, + Dependencies: []string{ + "github.com/kubernetes-incubator/apiserver-builder/pkg/builders.DefaultStorageStrategy"}, + }, "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineList": { Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -21525,9 +21710,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA }, "providerConfig": { SchemaProps: spec.SchemaProps{ - Description: "Provider-specific serialized configuration to use during node creation. It is recommended that providers maintain their own versioned API types that should be serialized/deserialized from this field, akin to component config.", - Type: []string{"string"}, - Format: "", + Description: "Provider-specific configuration to use during node creation.", + Ref: ref("k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.ProviderConfig"), }, }, "roles": { @@ -21560,7 +21744,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA }, }, Dependencies: []string{ - "k8s.io/api/core/v1.NodeConfigSource", "k8s.io/api/core/v1.Taint", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineVersionInfo"}, + "k8s.io/api/core/v1.NodeConfigSource", "k8s.io/api/core/v1.Taint", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineVersionInfo", "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.ProviderConfig"}, }, "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineStatus": { Schema: spec.Schema{ @@ -21714,5 +21898,45 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA }, Dependencies: []string{}, }, + "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.ProviderConfig": { + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ProviderConfig defines the configuration to use during node creation.", + Properties: map[string]spec.Schema{ + "value": { + SchemaProps: spec.SchemaProps{ + Description: "Value is an inlined, serialized representation of the node configuration. It is recommended that providers maintain their own versioned API types that should be serialized/deserialized from this field, akin to component config.", + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + "ValueFrom": { + SchemaProps: spec.SchemaProps{ + Description: "Source for the provider configuration. Cannot be used if value is not empty.", + Ref: ref("k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.ProviderConfigSource"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/runtime.RawExtension", "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.ProviderConfigSource"}, + }, + "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.ProviderConfigSource": { + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ProviderConfigSource represents a source for the provider-specific node configuration.", + Properties: map[string]spec.Schema{ + "MachineClass": { + SchemaProps: spec.SchemaProps{ + Description: "The machine class from which the provider config should be sourced.", + Ref: ref("k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineClassRef"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/kube-deploy/cluster-api/pkg/apis/cluster/v1alpha1.MachineClassRef"}, + }, } } From da230c7c0e48647fa246c2dc2ac8e630ef07b690 Mon Sep 17 00:00:00 2001 From: Robert Bailey Date: Fri, 23 Mar 2018 11:24:44 -0700 Subject: [PATCH 3/3] Add a sample machine class yaml file. --- cluster-api/sample/machineclass.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 cluster-api/sample/machineclass.yaml diff --git a/cluster-api/sample/machineclass.yaml b/cluster-api/sample/machineclass.yaml new file mode 100644 index 000000000..dc007be43 --- /dev/null +++ b/cluster-api/sample/machineclass.yaml @@ -0,0 +1,19 @@ +apiVersion: "cluster.k8s.io/v1alpha1" +kind: MachineClass +metadata: + name: small +capacity: + cpu: 2 + memory: 7.5Gi + storage: 20Gi +allocatable: + cpu: 2 + memory: 7.5Gi + storage: 20Gi +providerConfig: + apiVersion: "gceproviderconfig/v1alpha1" + kind: "GCEProviderConfig" + project: "$GCLOUD_PROJECT" + zone: "${ZONE:-us-central1-f}" + machineType: "n1-standard-2" + image: "projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts"