From 4b030fed69d9288e38c84adc6950b9f2b0f83aa3 Mon Sep 17 00:00:00 2001 From: Robin Percy Date: Tue, 7 Feb 2017 07:04:08 -0800 Subject: [PATCH 1/3] Added taints property to IG Spec. - new property is only used when KubernetesVersion is 1.6 or greater - taints are passed to kubelet via --register-with-taints flag - Set a default NoSchedule taint on masters - Set --register-schedule=true when --register-with-taints is used - Changed the log message in taints.go to be less alarming if taints are found - since they are expected on 1.6.0+ clusters - Added Taints section to the InstanceGroup docs - Only default taints are allowed in the spec pre-1.6 - Custom taint validation happens as soon as IG specs are edited. --- cmd/kops/create_cluster.go | 1 + docs/instance_groups.md | 21 ++++ pkg/apis/kops/componentconfig.go | 3 + pkg/apis/kops/instancegroup.go | 26 +++++ pkg/apis/kops/kubeletconfig.go | 35 +++++- pkg/apis/kops/kubeletconfig_test.go | 100 ++++++++++++++++++ pkg/apis/kops/v1alpha1/componentconfig.go | 3 + pkg/apis/kops/v1alpha1/instancegroup.go | 3 + pkg/apis/kops/v1alpha2/componentconfig.go | 3 + pkg/apis/kops/v1alpha2/instancegroup.go | 3 + protokube/pkg/protokube/tainter.go | 8 +- .../create_cluster/ha/expected-v1alpha1.yaml | 6 ++ .../create_cluster/ha/expected-v1alpha2.yaml | 6 ++ .../ha_shared_zones/expected-v1alpha2.yaml | 10 ++ .../minimal/expected-v1alpha1.yaml | 2 + .../minimal/expected-v1alpha2.yaml | 2 + .../ngwspecified/expected-v1alpha1.yaml | 2 + .../ngwspecified/expected-v1alpha2.yaml | 2 + .../private/expected-v1alpha1.yaml | 2 + .../private/expected-v1alpha2.yaml | 2 + 20 files changed, 235 insertions(+), 5 deletions(-) diff --git a/cmd/kops/create_cluster.go b/cmd/kops/create_cluster.go index 68ff5819c2..ba32ab7f8b 100644 --- a/cmd/kops/create_cluster.go +++ b/cmd/kops/create_cluster.go @@ -354,6 +354,7 @@ func RunCreateCluster(f *util.Factory, out io.Writer, c *CreateClusterOptions) e g := &api.InstanceGroup{} g.Spec.Role = api.InstanceGroupRoleMaster + g.Spec.Taints = []string{api.TaintNoScheduleMaster} g.Spec.Subnets = []string{subnet.Name} g.Spec.MinSize = fi.Int32(1) g.Spec.MaxSize = fi.Int32(1) diff --git a/docs/instance_groups.md b/docs/instance_groups.md index fa74c85d05..e8e8b1f354 100644 --- a/docs/instance_groups.md +++ b/docs/instance_groups.md @@ -131,6 +131,27 @@ So the procedure is: * Rolling-update, only if you want to apply changes immediately: `kops rolling-update cluster` +## Adding Taints to an Instance Group + +If you're running Kubernetes 1.6.0 or later, you can also control taints in the InstanceGroup. +The taints property takes a list of strings. The following example would add two taints to an IG, +using the same `edit` -> `update` -> `rolling-update` process as above. + +``` +metadata: + creationTimestamp: "2016-07-10T15:47:14Z" + name: nodes +spec: + machineType: m3.medium + maxSize: 3 + minSize: 3 + role: Node + taints: + - dedicated=gpu:NoSchedule + - team=search:PreferNoSchedule +``` + + ## Resizing the master (This procedure should be pretty familiar by now!) diff --git a/pkg/apis/kops/componentconfig.go b/pkg/apis/kops/componentconfig.go index a93787d210..71168882ff 100644 --- a/pkg/apis/kops/componentconfig.go +++ b/pkg/apis/kops/componentconfig.go @@ -314,6 +314,9 @@ type KubeletConfigSpec struct { // The full path of the directory in which to search for additional third party volume plugins VolumePluginDirectory string `json:"volumePluginDirectory,omitempty" flag:"volume-plugin-dir"` + + // Taints to add when registering a node in the cluster + Taints []string `json:"taints,omitempty" flag:"register-with-taints"` } type KubeProxyConfig struct { diff --git a/pkg/apis/kops/instancegroup.go b/pkg/apis/kops/instancegroup.go index 1f51b0dd03..e27b848bff 100644 --- a/pkg/apis/kops/instancegroup.go +++ b/pkg/apis/kops/instancegroup.go @@ -22,9 +22,11 @@ import ( "github.com/golang/glog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/kops/pkg/apis/kops/util" ) const LabelClusterName = "kops.k8s.io/cluster" +const TaintNoScheduleMaster = "dedicated=master:NoSchedule" // InstanceGroup represents a group of instances (either nodes or masters) with the same configuration type InstanceGroup struct { @@ -92,6 +94,9 @@ type InstanceGroupSpec struct { // Kubelet overrides kubelet config from the ClusterSpec Kubelet *KubeletConfigSpec `json:"kubelet,omitempty"` + + // Taints indicates the kubernetes taints for nodes in this group + Taints []string `json:"taints,omitempty"` } // PerformAssignmentsInstanceGroups populates InstanceGroups with default values @@ -171,6 +176,11 @@ func (g *InstanceGroup) CrossValidate(cluster *Cluster, strict bool) error { return err } + err = g.ValidateTaintsForKubeVersion(cluster) + if err != nil { + return err + } + // Check that instance groups are defined in valid zones { clusterSubnets := make(map[string]*ClusterSubnetSpec) @@ -191,3 +201,19 @@ func (g *InstanceGroup) CrossValidate(cluster *Cluster, strict bool) error { return nil } + +// Ensures that users don't try to specify custom taints on pre-1.6.0 IGs +func (g *InstanceGroup) ValidateTaintsForKubeVersion(cluster *Cluster) error { + kv, err := util.ParseKubernetesVersion(cluster.Spec.KubernetesVersion) + if err != nil { + return fmt.Errorf("Unable to determine kubernetes version from %q", cluster.Spec.KubernetesVersion) + } + + if kv.Major == 1 && kv.Minor <= 5 && len(g.Spec.Taints) > 0 { + if !(g.IsMaster() && g.Spec.Taints[0] == TaintNoScheduleMaster && len(g.Spec.Taints) == 1) { + return fmt.Errorf("User-specified taints are not supported before kubernetes version 1.6.0") + } + } + + return nil +} diff --git a/pkg/apis/kops/kubeletconfig.go b/pkg/apis/kops/kubeletconfig.go index aa5b1f0ef3..624d8f6886 100644 --- a/pkg/apis/kops/kubeletconfig.go +++ b/pkg/apis/kops/kubeletconfig.go @@ -16,7 +16,12 @@ limitations under the License. package kops -import "k8s.io/kops/upup/pkg/fi/utils" +import ( + "fmt" + "github.com/blang/semver" + "k8s.io/kops/pkg/apis/kops/util" + "k8s.io/kops/upup/pkg/fi/utils" +) const RoleLabelName = "kubernetes.io/role" const RoleMasterLabelValue = "master" @@ -60,5 +65,33 @@ func BuildKubeletConfigSpec(cluster *Cluster, instanceGroup *InstanceGroup) (*Ku utils.JsonMergeStruct(c, instanceGroup.Spec.Kubelet) } + sv, err := util.ParseKubernetesVersion(cluster.Spec.KubernetesVersion) + if err != nil { + return c, fmt.Errorf("Failed to lookup kubernetes version: %v", err) + } + + // --register-with-taints was available in the first 1.6.0 alpha, no need to rely on semver's pre/build ordering + sv.Pre = nil + sv.Build = nil + if sv.GTE(semver.Version{Major: 1, Minor: 6, Patch: 0, Pre: nil, Build: nil}) { + for i, t := range instanceGroup.Spec.Taints { + if c.Taints == nil { + c.Taints = make([]string, len(instanceGroup.Spec.Taints)) + } + c.Taints[i] = t + } + + // Enable scheduling since it can be controlled via taints. + // For pre-1.6.0 clusters, this is handled by tainter.go + registerSchedulable := true + c.RegisterSchedulable = ®isterSchedulable + + } else { + err = instanceGroup.ValidateTaintsForKubeVersion(cluster) + if err != nil { + return nil, err + } + } + return c, nil } diff --git a/pkg/apis/kops/kubeletconfig_test.go b/pkg/apis/kops/kubeletconfig_test.go index 9e7f4304b6..16c64d030a 100644 --- a/pkg/apis/kops/kubeletconfig_test.go +++ b/pkg/apis/kops/kubeletconfig_test.go @@ -20,14 +20,18 @@ import ( "testing" ) +var taintValidationError = "User-specified taints are not supported before kubernetes version 1.6.0" + func Test_InstanceGroupKubeletMerge(t *testing.T) { var cluster = &Cluster{} cluster.Spec.Kubelet = &KubeletConfigSpec{} cluster.Spec.Kubelet.NvidiaGPUs = 0 + cluster.Spec.KubernetesVersion = "1.6.0" var instanceGroup = &InstanceGroup{} instanceGroup.Spec.Kubelet = &KubeletConfigSpec{} instanceGroup.Spec.Kubelet.NvidiaGPUs = 1 + instanceGroup.Spec.Role = InstanceGroupRoleNode var mergedKubeletSpec, err = BuildKubeletConfigSpec(cluster, instanceGroup) if err != nil { @@ -41,3 +45,99 @@ func Test_InstanceGroupKubeletMerge(t *testing.T) { t.Errorf("InstanceGroup kubelet value (%d) should be reflected in merged output", instanceGroup.Spec.Kubelet.NvidiaGPUs) } } + +func TestTaintsAppliedAfter160(t *testing.T) { + exp := map[string]bool{ + "1.4.9": false, + "1.5.2": false, + "1.6.0-alpha.1": true, + "1.6.0": true, + "1.6.5": true, + "1.7.0": true, + } + + for ver, e := range exp { + helpTestTaintsForV(t, ver, e) + } +} + +func TestDefaultTaintsEnforcedBefore160(t *testing.T) { + type param struct { + ver string + role InstanceGroupRole + taints []string + shouldErr bool + } + + params := []param{ + {"1.5.0", InstanceGroupRoleNode, []string{TaintNoScheduleMaster}, true}, + {"1.5.1", InstanceGroupRoleNode, nil, false}, + {"1.5.2", InstanceGroupRoleNode, []string{}, false}, + {"1.6.0", InstanceGroupRoleNode, []string{TaintNoScheduleMaster}, false}, + {"1.6.1", InstanceGroupRoleNode, []string{"Foo"}, false}, + } + + for _, p := range params { + cluster := &Cluster{Spec: ClusterSpec{KubernetesVersion: p.ver}} + ig := &InstanceGroup{Spec: InstanceGroupSpec{ + Taints: p.taints, + Role: p.role, + }} + _, err := BuildKubeletConfigSpec(cluster, ig) + if p.shouldErr { + if err == nil { + t.Fatal("Expected error building kubelet config, received nil.") + } else if err.Error() != taintValidationError { + t.Fatalf("Received an unexpected error validating taints: '%s'", err.Error()) + } + } else { + if err != nil { + t.Fatalf("Received an unexpected error validating taints: '%s', params: '%v'", err.Error(), p) + } + } + } +} + +func helpTestTaintsForV(t *testing.T, version string, shouldApply bool) { + cluster := &Cluster{Spec: ClusterSpec{KubernetesVersion: version}} + ig := &InstanceGroup{Spec: InstanceGroupSpec{Role: InstanceGroupRoleMaster, Taints: []string{"foo", "bar", "baz"}}} + c, err := BuildKubeletConfigSpec(cluster, ig) + + var expTaints []string + + if shouldApply { + expTaints = []string{"foo", "bar", "baz"} + + if c.RegisterSchedulable == nil || !*c.RegisterSchedulable { + t.Fatalf("Expected RegisterSchedulable == &true, got %v", c.RegisterSchedulable) + } + + if !aEqual(expTaints, c.Taints) { + t.Fatalf("Expected taints %v, got %v", expTaints, c.Taints) + } + } else if err == nil || err.Error() != taintValidationError { + t.Fatalf("Received an unexpected error: '%s'", err.Error()) + } +} + +func aEqual(exp, other []string) bool { + if exp == nil && other != nil { + return false + } + + if exp != nil && other == nil { + return false + } + + if len(exp) != len(other) { + return false + } + + for i, e := range exp { + if other[i] != e { + return false + } + } + + return true +} diff --git a/pkg/apis/kops/v1alpha1/componentconfig.go b/pkg/apis/kops/v1alpha1/componentconfig.go index 36754af4e5..9f67732bbd 100644 --- a/pkg/apis/kops/v1alpha1/componentconfig.go +++ b/pkg/apis/kops/v1alpha1/componentconfig.go @@ -313,6 +313,9 @@ type KubeletConfigSpec struct { // The full path of the directory in which to search for additional third party volume plugins VolumePluginDirectory string `json:"volumePluginDirectory,omitempty" flag:"volume-plugin-dir"` + + // Taints to add when registering a node in the cluster + Taints []string `json:"taints,omitempty" flag:"register-with-taints"` } type KubeProxyConfig struct { diff --git a/pkg/apis/kops/v1alpha1/instancegroup.go b/pkg/apis/kops/v1alpha1/instancegroup.go index 7cff1b596b..f0187f215f 100644 --- a/pkg/apis/kops/v1alpha1/instancegroup.go +++ b/pkg/apis/kops/v1alpha1/instancegroup.go @@ -76,4 +76,7 @@ type InstanceGroupSpec struct { // NodeLabels indicates the kubernetes labels for nodes in this group NodeLabels map[string]string `json:"nodeLabels,omitempty"` + + // Taints indicates the kubernetes taints for nodes in this group + Taints []string `json:"taints,omitempty"` } diff --git a/pkg/apis/kops/v1alpha2/componentconfig.go b/pkg/apis/kops/v1alpha2/componentconfig.go index 54056a48ec..3b162fb048 100644 --- a/pkg/apis/kops/v1alpha2/componentconfig.go +++ b/pkg/apis/kops/v1alpha2/componentconfig.go @@ -135,6 +135,9 @@ type KubeletConfigSpec struct { // The full path of the directory in which to search for additional third party volume plugins VolumePluginDirectory string `json:"volumePluginDirectory,omitempty" flag:"volume-plugin-dir"` + + // Taints to add when registering a node in the cluster + Taints []string `json:"taints,omitempty" flag:"register-with-taints"` } type KubeProxyConfig struct { diff --git a/pkg/apis/kops/v1alpha2/instancegroup.go b/pkg/apis/kops/v1alpha2/instancegroup.go index 735e869814..ccab761be2 100644 --- a/pkg/apis/kops/v1alpha2/instancegroup.go +++ b/pkg/apis/kops/v1alpha2/instancegroup.go @@ -83,4 +83,7 @@ type InstanceGroupSpec struct { // NodeLabels indicates the kubernetes labels for nodes in this group NodeLabels map[string]string `json:"nodeLabels,omitempty"` + + // Taints indicates the kubernetes taints for nodes in this group + Taints []string `json:"taints,omitempty"` } diff --git a/protokube/pkg/protokube/tainter.go b/protokube/pkg/protokube/tainter.go index 8a90ad35c8..e0ca2c32bc 100644 --- a/protokube/pkg/protokube/tainter.go +++ b/protokube/pkg/protokube/tainter.go @@ -44,9 +44,9 @@ type nodePatchSpec struct { // Note that this is for k8s <= 1.5 only const TaintsAnnotationKey string = "scheduler.alpha.kubernetes.io/taints" -// ApplyMasterTaints finds masters that have not yet been tainted, and applies the master taint -// Once the kubelet support --taints (like --labels) this can probably go away entirely. -// It also sets the unschedulable flag to false, so pods (with a toleration) can target the node +// ApplyMasterTaints finds masters that have not yet been tainted, and applies the master taint. +// Once all supported kubelet versions accept the --register-with-taints flag introduced in 1.6.0, this can probably +// go away entirely. It also sets the unschedulable flag to false, so pods (with a toleration) can target the node func ApplyMasterTaints(kubeContext *KubernetesContext) error { client, err := kubeContext.KubernetesClient() if err != nil { @@ -74,7 +74,7 @@ func ApplyMasterTaints(kubeContext *KubernetesContext) error { nodeTaintJSON := node.Annotations[TaintsAnnotationKey] if nodeTaintJSON != "" { if nodeTaintJSON != string(taintJSON) { - glog.Infof("Node %q had unexpected taint: %v", node.Name, nodeTaintJSON) + glog.Infof("Node %q is registered with taint: %v", node.Name, nodeTaintJSON) } continue } diff --git a/tests/integration/create_cluster/ha/expected-v1alpha1.yaml b/tests/integration/create_cluster/ha/expected-v1alpha1.yaml index 7520752c9f..9de701dcd9 100644 --- a/tests/integration/create_cluster/ha/expected-v1alpha1.yaml +++ b/tests/integration/create_cluster/ha/expected-v1alpha1.yaml @@ -62,6 +62,8 @@ spec: maxSize: 1 minSize: 1 role: Master + taints: + - dedicated=master:NoSchedule zones: - us-test-1a @@ -80,6 +82,8 @@ spec: maxSize: 1 minSize: 1 role: Master + taints: + - dedicated=master:NoSchedule zones: - us-test-1b @@ -98,6 +102,8 @@ spec: maxSize: 1 minSize: 1 role: Master + taints: + - dedicated=master:NoSchedule zones: - us-test-1c diff --git a/tests/integration/create_cluster/ha/expected-v1alpha2.yaml b/tests/integration/create_cluster/ha/expected-v1alpha2.yaml index a9e6d24360..7a22e3a625 100644 --- a/tests/integration/create_cluster/ha/expected-v1alpha2.yaml +++ b/tests/integration/create_cluster/ha/expected-v1alpha2.yaml @@ -72,6 +72,8 @@ spec: role: Master subnets: - us-test-1a + taints: + - dedicated=master:NoSchedule --- @@ -90,6 +92,8 @@ spec: role: Master subnets: - us-test-1b + taints: + - dedicated=master:NoSchedule --- @@ -108,6 +112,8 @@ spec: role: Master subnets: - us-test-1c + taints: + - dedicated=master:NoSchedule --- diff --git a/tests/integration/create_cluster/ha_shared_zones/expected-v1alpha2.yaml b/tests/integration/create_cluster/ha_shared_zones/expected-v1alpha2.yaml index ca5c90cde9..cea5f1e403 100644 --- a/tests/integration/create_cluster/ha_shared_zones/expected-v1alpha2.yaml +++ b/tests/integration/create_cluster/ha_shared_zones/expected-v1alpha2.yaml @@ -76,6 +76,8 @@ spec: role: Master subnets: - us-test-1a + taints: + - dedicated=master:NoSchedule --- @@ -94,6 +96,8 @@ spec: role: Master subnets: - us-test-1a + taints: + - dedicated=master:NoSchedule --- @@ -112,6 +116,8 @@ spec: role: Master subnets: - us-test-1a + taints: + - dedicated=master:NoSchedule --- @@ -130,6 +136,8 @@ spec: role: Master subnets: - us-test-1b + taints: + - dedicated=master:NoSchedule --- @@ -148,6 +156,8 @@ spec: role: Master subnets: - us-test-1b + taints: + - dedicated=master:NoSchedule --- diff --git a/tests/integration/create_cluster/minimal/expected-v1alpha1.yaml b/tests/integration/create_cluster/minimal/expected-v1alpha1.yaml index 2510df120f..881993e4de 100644 --- a/tests/integration/create_cluster/minimal/expected-v1alpha1.yaml +++ b/tests/integration/create_cluster/minimal/expected-v1alpha1.yaml @@ -50,6 +50,8 @@ spec: maxSize: 1 minSize: 1 role: Master + taints: + - dedicated=master:NoSchedule zones: - us-test-1a diff --git a/tests/integration/create_cluster/minimal/expected-v1alpha2.yaml b/tests/integration/create_cluster/minimal/expected-v1alpha2.yaml index c0eebb7b1f..11a08f6d56 100644 --- a/tests/integration/create_cluster/minimal/expected-v1alpha2.yaml +++ b/tests/integration/create_cluster/minimal/expected-v1alpha2.yaml @@ -56,6 +56,8 @@ spec: role: Master subnets: - us-test-1a + taints: + - dedicated=master:NoSchedule --- diff --git a/tests/integration/create_cluster/ngwspecified/expected-v1alpha1.yaml b/tests/integration/create_cluster/ngwspecified/expected-v1alpha1.yaml index e5751e4ff2..ad3ce21e6e 100644 --- a/tests/integration/create_cluster/ngwspecified/expected-v1alpha1.yaml +++ b/tests/integration/create_cluster/ngwspecified/expected-v1alpha1.yaml @@ -74,6 +74,8 @@ spec: maxSize: 1 minSize: 1 role: Master + taints: + - dedicated=master:NoSchedule zones: - us-test-1a diff --git a/tests/integration/create_cluster/ngwspecified/expected-v1alpha2.yaml b/tests/integration/create_cluster/ngwspecified/expected-v1alpha2.yaml index fe22b51b97..afaa9003e4 100644 --- a/tests/integration/create_cluster/ngwspecified/expected-v1alpha2.yaml +++ b/tests/integration/create_cluster/ngwspecified/expected-v1alpha2.yaml @@ -82,6 +82,8 @@ spec: role: Master subnets: - us-test-1a + taints: + - dedicated=master:NoSchedule --- diff --git a/tests/integration/create_cluster/private/expected-v1alpha1.yaml b/tests/integration/create_cluster/private/expected-v1alpha1.yaml index cfae9fca00..58c8becf6d 100644 --- a/tests/integration/create_cluster/private/expected-v1alpha1.yaml +++ b/tests/integration/create_cluster/private/expected-v1alpha1.yaml @@ -80,6 +80,8 @@ spec: maxSize: 1 minSize: 1 role: Master + taints: + - dedicated=master:NoSchedule zones: - us-test-1a diff --git a/tests/integration/create_cluster/private/expected-v1alpha2.yaml b/tests/integration/create_cluster/private/expected-v1alpha2.yaml index 9bede48170..72c814e173 100644 --- a/tests/integration/create_cluster/private/expected-v1alpha2.yaml +++ b/tests/integration/create_cluster/private/expected-v1alpha2.yaml @@ -88,6 +88,8 @@ spec: role: Master subnets: - us-test-1a + taints: + - dedicated=master:NoSchedule --- From 3b814e109d9574361062c27e17a5c766b734bc64 Mon Sep 17 00:00:00 2001 From: Robin Percy Date: Sat, 25 Mar 2017 12:43:38 -0700 Subject: [PATCH 2/3] Fixing up InstanceGroup versions - Kubelet API hadn't yet been added to all versions, which was causing it to be deleted from apimachinery-generated conversions. --- pkg/apis/kops/v1alpha1/instancegroup.go | 3 +++ pkg/apis/kops/v1alpha2/instancegroup.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkg/apis/kops/v1alpha1/instancegroup.go b/pkg/apis/kops/v1alpha1/instancegroup.go index f0187f215f..16866dc7eb 100644 --- a/pkg/apis/kops/v1alpha1/instancegroup.go +++ b/pkg/apis/kops/v1alpha1/instancegroup.go @@ -77,6 +77,9 @@ type InstanceGroupSpec struct { // NodeLabels indicates the kubernetes labels for nodes in this group NodeLabels map[string]string `json:"nodeLabels,omitempty"` + // Kubelet overrides kubelet config from the ClusterSpec + Kubelet *KubeletConfigSpec `json:"kubelet,omitempty"` + // Taints indicates the kubernetes taints for nodes in this group Taints []string `json:"taints,omitempty"` } diff --git a/pkg/apis/kops/v1alpha2/instancegroup.go b/pkg/apis/kops/v1alpha2/instancegroup.go index ccab761be2..671eba2449 100644 --- a/pkg/apis/kops/v1alpha2/instancegroup.go +++ b/pkg/apis/kops/v1alpha2/instancegroup.go @@ -84,6 +84,9 @@ type InstanceGroupSpec struct { // NodeLabels indicates the kubernetes labels for nodes in this group NodeLabels map[string]string `json:"nodeLabels,omitempty"` + // Kubelet overrides kubelet config from the ClusterSpec + Kubelet *KubeletConfigSpec `json:"kubelet,omitempty"` + // Taints indicates the kubernetes taints for nodes in this group Taints []string `json:"taints,omitempty"` } From 5f4d0851e5fb281cfe510f7c33628c4fd6961a85 Mon Sep 17 00:00:00 2001 From: Robin Percy Date: Sat, 25 Mar 2017 18:38:33 -0700 Subject: [PATCH 3/3] Regenerated apimachinery conversions --- .../kops/v1alpha1/zz_generated.conversion.go | 52 ++++++++++--------- .../kops/v1alpha2/zz_generated.conversion.go | 52 ++++++++++--------- 2 files changed, 56 insertions(+), 48 deletions(-) diff --git a/pkg/apis/kops/v1alpha1/zz_generated.conversion.go b/pkg/apis/kops/v1alpha1/zz_generated.conversion.go index f03e803e74..541137ab8b 100644 --- a/pkg/apis/kops/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/kops/v1alpha1/zz_generated.conversion.go @@ -244,10 +244,7 @@ func Convert_kops_CloudConfiguration_To_v1alpha1_CloudConfiguration(in *kops.Clo } func autoConvert_v1alpha1_Cluster_To_kops_Cluster(in *Cluster, out *kops.Cluster, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_v1alpha1_ClusterSpec_To_kops_ClusterSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -259,10 +256,7 @@ func Convert_v1alpha1_Cluster_To_kops_Cluster(in *Cluster, out *kops.Cluster, s } func autoConvert_kops_Cluster_To_v1alpha1_Cluster(in *kops.Cluster, out *Cluster, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_kops_ClusterSpec_To_v1alpha1_ClusterSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -754,10 +748,7 @@ func Convert_kops_ExternalNetworkingSpec_To_v1alpha1_ExternalNetworkingSpec(in * } func autoConvert_v1alpha1_Federation_To_kops_Federation(in *Federation, out *kops.Federation, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_v1alpha1_FederationSpec_To_kops_FederationSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -769,10 +760,7 @@ func Convert_v1alpha1_Federation_To_kops_Federation(in *Federation, out *kops.Fe } func autoConvert_kops_Federation_To_v1alpha1_Federation(in *kops.Federation, out *Federation, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_kops_FederationSpec_To_v1alpha1_FederationSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -862,10 +850,7 @@ func Convert_kops_FlannelNetworkingSpec_To_v1alpha1_FlannelNetworkingSpec(in *ko } func autoConvert_v1alpha1_InstanceGroup_To_kops_InstanceGroup(in *InstanceGroup, out *kops.InstanceGroup, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_v1alpha1_InstanceGroupSpec_To_kops_InstanceGroupSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -877,10 +862,7 @@ func Convert_v1alpha1_InstanceGroup_To_kops_InstanceGroup(in *InstanceGroup, out } func autoConvert_kops_InstanceGroup_To_v1alpha1_InstanceGroup(in *kops.InstanceGroup, out *InstanceGroup, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_kops_InstanceGroupSpec_To_v1alpha1_InstanceGroupSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -945,6 +927,16 @@ func autoConvert_v1alpha1_InstanceGroupSpec_To_kops_InstanceGroupSpec(in *Instan out.AdditionalSecurityGroups = in.AdditionalSecurityGroups out.CloudLabels = in.CloudLabels out.NodeLabels = in.NodeLabels + if in.Kubelet != nil { + in, out := &in.Kubelet, &out.Kubelet + *out = new(kops.KubeletConfigSpec) + if err := Convert_v1alpha1_KubeletConfigSpec_To_kops_KubeletConfigSpec(*in, *out, s); err != nil { + return err + } + } else { + out.Kubelet = nil + } + out.Taints = in.Taints return nil } @@ -962,6 +954,16 @@ func autoConvert_kops_InstanceGroupSpec_To_v1alpha1_InstanceGroupSpec(in *kops.I out.AdditionalSecurityGroups = in.AdditionalSecurityGroups out.CloudLabels = in.CloudLabels out.NodeLabels = in.NodeLabels + if in.Kubelet != nil { + in, out := &in.Kubelet, &out.Kubelet + *out = new(KubeletConfigSpec) + if err := Convert_kops_KubeletConfigSpec_To_v1alpha1_KubeletConfigSpec(*in, *out, s); err != nil { + return err + } + } else { + out.Kubelet = nil + } + out.Taints = in.Taints return nil } @@ -1253,6 +1255,7 @@ func autoConvert_v1alpha1_KubeletConfigSpec_To_kops_KubeletConfigSpec(in *Kubele out.EvictionMaxPodGracePeriod = in.EvictionMaxPodGracePeriod out.EvictionMinimumReclaim = in.EvictionMinimumReclaim out.VolumePluginDirectory = in.VolumePluginDirectory + out.Taints = in.Taints return nil } @@ -1298,6 +1301,7 @@ func autoConvert_kops_KubeletConfigSpec_To_v1alpha1_KubeletConfigSpec(in *kops.K out.EvictionMaxPodGracePeriod = in.EvictionMaxPodGracePeriod out.EvictionMinimumReclaim = in.EvictionMinimumReclaim out.VolumePluginDirectory = in.VolumePluginDirectory + out.Taints = in.Taints return nil } diff --git a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go index ba73bf8f42..99a850c46e 100644 --- a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go +++ b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go @@ -270,10 +270,7 @@ func Convert_kops_CloudConfiguration_To_v1alpha2_CloudConfiguration(in *kops.Clo } func autoConvert_v1alpha2_Cluster_To_kops_Cluster(in *Cluster, out *kops.Cluster, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_v1alpha2_ClusterSpec_To_kops_ClusterSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -285,10 +282,7 @@ func Convert_v1alpha2_Cluster_To_kops_Cluster(in *Cluster, out *kops.Cluster, s } func autoConvert_kops_Cluster_To_v1alpha2_Cluster(in *kops.Cluster, out *Cluster, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_kops_ClusterSpec_To_v1alpha2_ClusterSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -844,10 +838,7 @@ func Convert_kops_ExternalNetworkingSpec_To_v1alpha2_ExternalNetworkingSpec(in * } func autoConvert_v1alpha2_Federation_To_kops_Federation(in *Federation, out *kops.Federation, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_v1alpha2_FederationSpec_To_kops_FederationSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -859,10 +850,7 @@ func Convert_v1alpha2_Federation_To_kops_Federation(in *Federation, out *kops.Fe } func autoConvert_kops_Federation_To_v1alpha2_Federation(in *kops.Federation, out *Federation, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_kops_FederationSpec_To_v1alpha2_FederationSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -952,10 +940,7 @@ func Convert_kops_FlannelNetworkingSpec_To_v1alpha2_FlannelNetworkingSpec(in *ko } func autoConvert_v1alpha2_InstanceGroup_To_kops_InstanceGroup(in *InstanceGroup, out *kops.InstanceGroup, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_v1alpha2_InstanceGroupSpec_To_kops_InstanceGroupSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -967,10 +952,7 @@ func Convert_v1alpha2_InstanceGroup_To_kops_InstanceGroup(in *InstanceGroup, out } func autoConvert_kops_InstanceGroup_To_v1alpha2_InstanceGroup(in *kops.InstanceGroup, out *InstanceGroup, s conversion.Scope) error { - // TODO: Inefficient conversion - can we improve it? - if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil { - return err - } + out.ObjectMeta = in.ObjectMeta if err := Convert_kops_InstanceGroupSpec_To_v1alpha2_InstanceGroupSpec(&in.Spec, &out.Spec, s); err != nil { return err } @@ -1035,6 +1017,16 @@ func autoConvert_v1alpha2_InstanceGroupSpec_To_kops_InstanceGroupSpec(in *Instan out.AdditionalSecurityGroups = in.AdditionalSecurityGroups out.CloudLabels = in.CloudLabels out.NodeLabels = in.NodeLabels + if in.Kubelet != nil { + in, out := &in.Kubelet, &out.Kubelet + *out = new(kops.KubeletConfigSpec) + if err := Convert_v1alpha2_KubeletConfigSpec_To_kops_KubeletConfigSpec(*in, *out, s); err != nil { + return err + } + } else { + out.Kubelet = nil + } + out.Taints = in.Taints return nil } @@ -1056,6 +1048,16 @@ func autoConvert_kops_InstanceGroupSpec_To_v1alpha2_InstanceGroupSpec(in *kops.I out.AdditionalSecurityGroups = in.AdditionalSecurityGroups out.CloudLabels = in.CloudLabels out.NodeLabels = in.NodeLabels + if in.Kubelet != nil { + in, out := &in.Kubelet, &out.Kubelet + *out = new(KubeletConfigSpec) + if err := Convert_kops_KubeletConfigSpec_To_v1alpha2_KubeletConfigSpec(*in, *out, s); err != nil { + return err + } + } else { + out.Kubelet = nil + } + out.Taints = in.Taints return nil } @@ -1351,6 +1353,7 @@ func autoConvert_v1alpha2_KubeletConfigSpec_To_kops_KubeletConfigSpec(in *Kubele out.EvictionMaxPodGracePeriod = in.EvictionMaxPodGracePeriod out.EvictionMinimumReclaim = in.EvictionMinimumReclaim out.VolumePluginDirectory = in.VolumePluginDirectory + out.Taints = in.Taints return nil } @@ -1396,6 +1399,7 @@ func autoConvert_kops_KubeletConfigSpec_To_v1alpha2_KubeletConfigSpec(in *kops.K out.EvictionMaxPodGracePeriod = in.EvictionMaxPodGracePeriod out.EvictionMinimumReclaim = in.EvictionMinimumReclaim out.VolumePluginDirectory = in.VolumePluginDirectory + out.Taints = in.Taints return nil }