Skip to content
Permalink
Browse files

Merge pull request kubernetes#65940 from luxas/kubeadm_internal_compo…

…nentconfigs

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

kubeadm: Start using internal versions for ComponentConfigs in the internal API

**What this PR does / why we need it**:
This PR changes kubeadm to store the internal API versions of the ComponentConfig APIs, in order to in the future be able to read multiple external versions with conversion. It also moves all the ComponentConfigs to a common struct instead of splitting them out in many. This makes it possible to more easily host more ComponentConfigs in the future. In v1alpha3, the ComponentConfigs will later be removed from the external version of the API (see: kubernetes#65787), but for this PR no changes to the external API are made.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
ref: kubernetes/kubeadm#911
Depends on:
 - [x] kubernetes#65776
 - [x] kubernetes#65628
 - [x] kubernetes#65629
 - [x] kubernetes#65631

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
@kubernetes/sig-cluster-lifecycle-pr-reviews
  • Loading branch information...
Kubernetes Submit Queue
Kubernetes Submit Queue committed Jul 8, 2018
2 parents 4d98735 + 5e6be9d commit 502857736020924b6b702fea8d1b6835c3660616
Showing with 567 additions and 533 deletions.
  1. +2 −2 cmd/kubeadm/app/apis/kubeadm/BUILD
  2. +3 −1 cmd/kubeadm/app/apis/kubeadm/fuzzer/BUILD
  3. +51 −50 cmd/kubeadm/app/apis/kubeadm/fuzzer/fuzzer.go
  4. +13 −16 cmd/kubeadm/app/apis/kubeadm/types.go
  5. +3 −0 cmd/kubeadm/app/apis/kubeadm/v1alpha2/BUILD
  6. +91 −0 cmd/kubeadm/app/apis/kubeadm/v1alpha2/conversion.go
  7. +3 −68 cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.conversion.go
  8. +3 −0 cmd/kubeadm/app/apis/kubeadm/v1alpha3/BUILD
  9. +95 −0 cmd/kubeadm/app/apis/kubeadm/v1alpha3/conversion.go
  10. +3 −68 cmd/kubeadm/app/apis/kubeadm/v1alpha3/zz_generated.conversion.go
  11. +2 −5 cmd/kubeadm/app/apis/kubeadm/validation/BUILD
  12. +11 −37 cmd/kubeadm/app/apis/kubeadm/validation/validation.go
  13. +94 −98 cmd/kubeadm/app/apis/kubeadm/validation/validation_test.go
  14. +29 −46 cmd/kubeadm/app/apis/kubeadm/zz_generated.deepcopy.go
  15. +1 −1 cmd/kubeadm/app/cmd/init.go
  16. +1 −1 cmd/kubeadm/app/cmd/phases/kubelet.go
  17. +1 −2 cmd/kubeadm/app/phases/addons/proxy/proxy.go
  18. +4 −4 cmd/kubeadm/app/phases/addons/proxy/proxy_test.go
  19. +2 −1 cmd/kubeadm/app/phases/kubelet/BUILD
  20. +4 −3 cmd/kubeadm/app/phases/kubelet/config.go
  21. +3 −3 cmd/kubeadm/app/phases/kubelet/config_test.go
  22. +7 −10 cmd/kubeadm/app/phases/uploadconfig/uploadconfig.go
  23. +1 −1 cmd/kubeadm/app/preflight/checks.go
  24. +2 −2 cmd/kubeadm/app/util/config/masterconfig.go
  25. +134 −110 cmd/kubeadm/app/util/config/testdata/conversion/master/internal.yaml
  26. +2 −2 cmd/kubeadm/app/util/config/testdata/conversion/master/v1alpha2.yaml
  27. +2 −2 cmd/kubeadm/app/util/config/testdata/conversion/master/v1alpha3.yaml
@@ -18,8 +18,8 @@ go_library(
],
importpath = "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm",
deps = [
"//pkg/kubelet/apis/kubeletconfig/v1beta1:go_default_library",
"//pkg/proxy/apis/kubeproxyconfig/v1alpha1:go_default_library",
"//pkg/kubelet/apis/kubeletconfig:go_default_library",
"//pkg/proxy/apis/kubeproxyconfig:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
@@ -12,8 +12,10 @@ go_library(
importpath = "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/fuzzer",
deps = [
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
"//pkg/kubelet/apis/kubeletconfig:go_default_library",
"//pkg/kubelet/apis/kubeletconfig/scheme:go_default_library",
"//pkg/kubelet/apis/kubeletconfig/v1beta1:go_default_library",
"//pkg/proxy/apis/kubeproxyconfig/v1alpha1:go_default_library",
"//pkg/proxy/apis/kubeproxyconfig:go_default_library",
"//pkg/util/pointer:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
@@ -25,8 +25,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
kubeletconfigscheme "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/scheme"
kubeletconfigv1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1beta1"
kubeproxyconfigv1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/v1alpha1"
"k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
)

@@ -81,60 +83,59 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
Name: "foo",
Taints: []v1.Taint{},
}
obj.KubeletConfiguration = kubeadm.KubeletConfiguration{
BaseConfig: &kubeletconfigv1beta1.KubeletConfiguration{
StaticPodPath: "foo",
ClusterDNS: []string{"foo"},
ClusterDomain: "foo",
Authorization: kubeletconfigv1beta1.KubeletAuthorization{
Mode: "Webhook",
extkubeletconfig := &kubeletconfigv1beta1.KubeletConfiguration{
StaticPodPath: "foo",
ClusterDNS: []string{"foo"},
ClusterDomain: "foo",
Authorization: kubeletconfigv1beta1.KubeletAuthorization{
Mode: "Webhook",
},
Authentication: kubeletconfigv1beta1.KubeletAuthentication{
X509: kubeletconfigv1beta1.KubeletX509Authentication{
ClientCAFile: "/etc/kubernetes/pki/ca.crt",
},
Authentication: kubeletconfigv1beta1.KubeletAuthentication{
X509: kubeletconfigv1beta1.KubeletX509Authentication{
ClientCAFile: "/etc/kubernetes/pki/ca.crt",
},
Anonymous: kubeletconfigv1beta1.KubeletAnonymousAuthentication{
Enabled: utilpointer.BoolPtr(false),
},
Anonymous: kubeletconfigv1beta1.KubeletAnonymousAuthentication{
Enabled: utilpointer.BoolPtr(false),
},
RotateCertificates: true,
},
RotateCertificates: true,
}
kubeletconfigv1beta1.SetDefaults_KubeletConfiguration(obj.KubeletConfiguration.BaseConfig)
obj.KubeProxy = kubeadm.KubeProxy{
Config: &kubeproxyconfigv1alpha1.KubeProxyConfiguration{
FeatureGates: map[string]bool{"foo": true},
BindAddress: "foo",
HealthzBindAddress: "foo:10256",
MetricsBindAddress: "foo:",
EnableProfiling: bool(true),
ClusterCIDR: "foo",
HostnameOverride: "foo",
ClientConnection: kubeproxyconfigv1alpha1.ClientConnectionConfiguration{
KubeConfigFile: "foo",
AcceptContentTypes: "foo",
ContentType: "foo",
QPS: float32(5),
Burst: 10,
},
IPVS: kubeproxyconfigv1alpha1.KubeProxyIPVSConfiguration{
SyncPeriod: metav1.Duration{Duration: 1},
},
IPTables: kubeproxyconfigv1alpha1.KubeProxyIPTablesConfiguration{
MasqueradeBit: utilpointer.Int32Ptr(0),
SyncPeriod: metav1.Duration{Duration: 1},
},
OOMScoreAdj: utilpointer.Int32Ptr(0),
ResourceContainer: "foo",
UDPIdleTimeout: metav1.Duration{Duration: 1},
Conntrack: kubeproxyconfigv1alpha1.KubeProxyConntrackConfiguration{
MaxPerCore: utilpointer.Int32Ptr(2),
Min: utilpointer.Int32Ptr(1),
TCPEstablishedTimeout: &metav1.Duration{Duration: 5},
TCPCloseWaitTimeout: &metav1.Duration{Duration: 5},
},
ConfigSyncPeriod: metav1.Duration{Duration: 1},
obj.ComponentConfigs.Kubelet = &kubeletconfig.KubeletConfiguration{}
kubeletconfigv1beta1.SetDefaults_KubeletConfiguration(extkubeletconfig)
scheme, _, _ := kubeletconfigscheme.NewSchemeAndCodecs()
scheme.Convert(extkubeletconfig, obj.ComponentConfigs.Kubelet, nil)
obj.ComponentConfigs.KubeProxy = &kubeproxyconfig.KubeProxyConfiguration{
FeatureGates: map[string]bool{"foo": true},
BindAddress: "foo",
HealthzBindAddress: "foo:10256",
MetricsBindAddress: "foo:",
EnableProfiling: bool(true),
ClusterCIDR: "foo",
HostnameOverride: "foo",
ClientConnection: kubeproxyconfig.ClientConnectionConfiguration{
KubeConfigFile: "foo",
AcceptContentTypes: "foo",
ContentType: "foo",
QPS: float32(5),
Burst: 10,
},
IPVS: kubeproxyconfig.KubeProxyIPVSConfiguration{
SyncPeriod: metav1.Duration{Duration: 1},
},
IPTables: kubeproxyconfig.KubeProxyIPTablesConfiguration{
MasqueradeBit: utilpointer.Int32Ptr(0),
SyncPeriod: metav1.Duration{Duration: 1},
},
OOMScoreAdj: utilpointer.Int32Ptr(0),
ResourceContainer: "foo",
UDPIdleTimeout: metav1.Duration{Duration: 1},
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
MaxPerCore: utilpointer.Int32Ptr(2),
Min: utilpointer.Int32Ptr(1),
TCPEstablishedTimeout: &metav1.Duration{Duration: 5},
TCPCloseWaitTimeout: &metav1.Duration{Duration: 5},
},
ConfigSyncPeriod: metav1.Duration{Duration: 1},
}
obj.AuditPolicyConfiguration = kubeadm.AuditPolicyConfiguration{
Path: "foo",
@@ -19,8 +19,8 @@ package kubeadm
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubeletconfigv1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1beta1"
kubeproxyconfigv1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/v1alpha1"
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
"k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
@@ -41,18 +41,17 @@ type MasterConfiguration struct {
// NodeRegistration holds fields that relate to registering the new master node to the cluster
NodeRegistration NodeRegistrationOptions

// ComponentConfigs holds internal ComponentConfig struct types known to kubeadm, should long-term only exist in the internal kubeadm API
ComponentConfigs ComponentConfigs

// Cluster-wide configuration
// TODO: Move these fields under some kind of ClusterConfiguration or similar struct that describes
// one cluster. Eventually we want this kind of spec to align well with the Cluster API spec.

// API holds configuration for the k8s apiserver.
API API
// KubeProxy holds configuration for the k8s service proxy.
KubeProxy KubeProxy
// Etcd holds configuration for etcd.
Etcd Etcd
// KubeletConfiguration holds configuration for the kubelet.
KubeletConfiguration KubeletConfiguration
// Networking holds configuration for the networking topology of the cluster.
Networking Networking
// KubernetesVersion is the target version of the control plane.
@@ -110,6 +109,14 @@ type MasterConfiguration struct {
ClusterName string
}

// ComponentConfigs holds known internal ComponentConfig types for other components
type ComponentConfigs struct {
// Kubelet holds the ComponentConfiguration for the kubelet
Kubelet *kubeletconfig.KubeletConfiguration
// KubeProxy holds the ComponentConfiguration for the kube-proxy
KubeProxy *kubeproxyconfig.KubeProxyConfiguration
}

// API struct contains elements of API server address.
type API struct {
// AdvertiseAddress sets the IP address for the API server to advertise.
@@ -288,11 +295,6 @@ type NodeConfiguration struct {
FeatureGates map[string]bool
}

// KubeletConfiguration contains elements describing initial remote configuration of kubelet.
type KubeletConfiguration struct {
BaseConfig *kubeletconfigv1beta1.KubeletConfiguration
}

// GetControlPlaneImageRepository returns name of image repository
// for control plane images (API,Controller Manager,Scheduler and Proxy)
// It will override location with CI registry name in case user requests special
@@ -321,11 +323,6 @@ type HostPathMount struct {
PathType v1.HostPathType
}

// KubeProxy contains elements describing the proxy configuration.
type KubeProxy struct {
Config *kubeproxyconfigv1alpha1.KubeProxyConfiguration
}

// AuditPolicyConfiguration holds the options for configuring the api server audit policy.
type AuditPolicyConfiguration struct {
// Path is the local path to an audit policy.
@@ -4,6 +4,7 @@ go_library(
name = "go_default_library",
srcs = [
"bootstraptokenstring.go",
"conversion.go",
"defaults.go",
"defaults_unix.go",
"defaults_windows.go",
@@ -19,8 +20,10 @@ go_library(
deps = [
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
"//cmd/kubeadm/app/constants:go_default_library",
"//pkg/kubelet/apis/kubeletconfig:go_default_library",
"//pkg/kubelet/apis/kubeletconfig/scheme:go_default_library",
"//pkg/kubelet/apis/kubeletconfig/v1beta1:go_default_library",
"//pkg/proxy/apis/kubeproxyconfig:go_default_library",
"//pkg/proxy/apis/kubeproxyconfig/scheme:go_default_library",
"//pkg/proxy/apis/kubeproxyconfig/v1alpha1:go_default_library",
"//pkg/util/pointer:go_default_library",
@@ -0,0 +1,91 @@
/*
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 v1alpha2

import (
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
kubeletconfigscheme "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/scheme"
kubeletconfigv1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1beta1"
"k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig"
kubeproxyconfigscheme "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/scheme"
kubeproxyconfigv1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/v1alpha1"
)

func Convert_v1alpha2_MasterConfiguration_To_kubeadm_MasterConfiguration(in *MasterConfiguration, out *kubeadm.MasterConfiguration, s conversion.Scope) error {
if err := autoConvert_v1alpha2_MasterConfiguration_To_kubeadm_MasterConfiguration(in, out, s); err != nil {
return err
}

if in.KubeProxy.Config != nil {
if out.ComponentConfigs.KubeProxy == nil {
out.ComponentConfigs.KubeProxy = &kubeproxyconfig.KubeProxyConfiguration{}
}

if err := kubeproxyconfigscheme.Scheme.Convert(in.KubeProxy.Config, out.ComponentConfigs.KubeProxy, nil); err != nil {
return err
}
}
if in.KubeletConfiguration.BaseConfig != nil {
if out.ComponentConfigs.Kubelet == nil {
out.ComponentConfigs.Kubelet = &kubeletconfig.KubeletConfiguration{}
}

scheme, _, err := kubeletconfigscheme.NewSchemeAndCodecs()
if err != nil {
return err
}

if err := scheme.Convert(in.KubeletConfiguration.BaseConfig, out.ComponentConfigs.Kubelet, nil); err != nil {
return err
}
}

return nil
}

func Convert_kubeadm_MasterConfiguration_To_v1alpha2_MasterConfiguration(in *kubeadm.MasterConfiguration, out *MasterConfiguration, s conversion.Scope) error {
if err := autoConvert_kubeadm_MasterConfiguration_To_v1alpha2_MasterConfiguration(in, out, s); err != nil {
return err
}

if in.ComponentConfigs.KubeProxy != nil {
if out.KubeProxy.Config == nil {
out.KubeProxy.Config = &kubeproxyconfigv1alpha1.KubeProxyConfiguration{}
}

if err := kubeproxyconfigscheme.Scheme.Convert(in.ComponentConfigs.KubeProxy, out.KubeProxy.Config, nil); err != nil {
return err
}
}
if in.ComponentConfigs.Kubelet != nil {
if out.KubeletConfiguration.BaseConfig == nil {
out.KubeletConfiguration.BaseConfig = &kubeletconfigv1beta1.KubeletConfiguration{}
}

scheme, _, err := kubeletconfigscheme.NewSchemeAndCodecs()
if err != nil {
return err
}

if err := scheme.Convert(in.ComponentConfigs.Kubelet, out.KubeletConfiguration.BaseConfig, nil); err != nil {
return err
}
}
return nil
}
Oops, something went wrong.

0 comments on commit 5028577

Please sign in to comment.
You can’t perform that action at this time.