mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #110791 from SataQiu/fix-kubeadm-20220626
kubeadm: fix the bug that configurable KubernetesVersion not respected during kubeadm join
This commit is contained in:
commit
fa16bf8e12
@ -77,10 +77,11 @@ func fuzzClusterConfiguration(obj *kubeadm.ClusterConfiguration, c fuzz.Continue
|
|||||||
|
|
||||||
// Pinning values for fields that get defaults if fuzz value is empty string or nil (thus making the round trip test fail)
|
// Pinning values for fields that get defaults if fuzz value is empty string or nil (thus making the round trip test fail)
|
||||||
obj.CertificatesDir = "foo"
|
obj.CertificatesDir = "foo"
|
||||||
obj.CIImageRepository = "" //This fields doesn't exists in public API >> using default to get the roundtrip test pass
|
|
||||||
obj.ClusterName = "bar"
|
obj.ClusterName = "bar"
|
||||||
obj.ImageRepository = "baz"
|
obj.ImageRepository = "baz"
|
||||||
|
obj.CIImageRepository = "" // This fields doesn't exists in public API >> using default to get the roundtrip test pass
|
||||||
obj.KubernetesVersion = "qux"
|
obj.KubernetesVersion = "qux"
|
||||||
|
obj.CIKubernetesVersion = "" // This fields doesn't exists in public API >> using default to get the roundtrip test pass
|
||||||
obj.APIServer.TimeoutForControlPlane = &metav1.Duration{
|
obj.APIServer.TimeoutForControlPlane = &metav1.Duration{
|
||||||
Duration: constants.DefaultControlPlaneTimeout,
|
Duration: constants.DefaultControlPlaneTimeout,
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,15 @@ type ClusterConfiguration struct {
|
|||||||
|
|
||||||
// Networking holds configuration for the networking topology of the cluster.
|
// Networking holds configuration for the networking topology of the cluster.
|
||||||
Networking Networking
|
Networking Networking
|
||||||
|
|
||||||
// KubernetesVersion is the target version of the control plane.
|
// KubernetesVersion is the target version of the control plane.
|
||||||
KubernetesVersion string
|
KubernetesVersion string
|
||||||
|
|
||||||
|
// CIKubernetesVersion is the target CI version of the control plane.
|
||||||
|
// Useful for running kubeadm with CI Kubernetes version.
|
||||||
|
// +k8s:conversion-gen=false
|
||||||
|
CIKubernetesVersion string
|
||||||
|
|
||||||
// ControlPlaneEndpoint sets a stable IP address or DNS name for the control plane; it
|
// ControlPlaneEndpoint sets a stable IP address or DNS name for the control plane; it
|
||||||
// can be a valid IP address or a RFC-1123 DNS subdomain, both with optional TCP port.
|
// can be a valid IP address or a RFC-1123 DNS subdomain, both with optional TCP port.
|
||||||
// In case the ControlPlaneEndpoint is not specified, the AdvertiseAddress + BindPort
|
// In case the ControlPlaneEndpoint is not specified, the AdvertiseAddress + BindPort
|
||||||
|
@ -346,6 +346,7 @@ func autoConvert_kubeadm_ClusterConfiguration_To_v1beta2_ClusterConfiguration(in
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.KubernetesVersion = in.KubernetesVersion
|
out.KubernetesVersion = in.KubernetesVersion
|
||||||
|
// INFO: in.CIKubernetesVersion opted out of conversion generation
|
||||||
out.ControlPlaneEndpoint = in.ControlPlaneEndpoint
|
out.ControlPlaneEndpoint = in.ControlPlaneEndpoint
|
||||||
if err := Convert_kubeadm_APIServer_To_v1beta2_APIServer(&in.APIServer, &out.APIServer, s); err != nil {
|
if err := Convert_kubeadm_APIServer_To_v1beta2_APIServer(&in.APIServer, &out.APIServer, s); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -345,6 +345,7 @@ func autoConvert_kubeadm_ClusterConfiguration_To_v1beta3_ClusterConfiguration(in
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.KubernetesVersion = in.KubernetesVersion
|
out.KubernetesVersion = in.KubernetesVersion
|
||||||
|
// INFO: in.CIKubernetesVersion opted out of conversion generation
|
||||||
out.ControlPlaneEndpoint = in.ControlPlaneEndpoint
|
out.ControlPlaneEndpoint = in.ControlPlaneEndpoint
|
||||||
if err := Convert_kubeadm_APIServer_To_v1beta3_APIServer(&in.APIServer, &out.APIServer, s); err != nil {
|
if err := Convert_kubeadm_APIServer_To_v1beta3_APIServer(&in.APIServer, &out.APIServer, s); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -49,6 +49,11 @@ func UploadConfiguration(cfg *kubeadmapi.InitConfiguration, client clientset.Int
|
|||||||
clusterConfigurationToUpload := cfg.ClusterConfiguration.DeepCopy()
|
clusterConfigurationToUpload := cfg.ClusterConfiguration.DeepCopy()
|
||||||
clusterConfigurationToUpload.ComponentConfigs = kubeadmapi.ComponentConfigMap{}
|
clusterConfigurationToUpload.ComponentConfigs = kubeadmapi.ComponentConfigMap{}
|
||||||
|
|
||||||
|
// restore the resolved Kubernetes version as CI Kubernetes version if needed
|
||||||
|
if len(clusterConfigurationToUpload.CIKubernetesVersion) > 0 {
|
||||||
|
clusterConfigurationToUpload.KubernetesVersion = clusterConfigurationToUpload.CIKubernetesVersion
|
||||||
|
}
|
||||||
|
|
||||||
// Marshal the ClusterConfiguration into YAML
|
// Marshal the ClusterConfiguration into YAML
|
||||||
clusterConfigurationYaml, err := configutil.MarshalKubeadmConfigObject(clusterConfigurationToUpload)
|
clusterConfigurationYaml, err := configutil.MarshalKubeadmConfigObject(clusterConfigurationToUpload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -18,6 +18,7 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@ -90,8 +91,10 @@ func validateSupportedVersion(gv schema.GroupVersion, allowDeprecated bool) erro
|
|||||||
// image registry if requested for CI builds, and validates minimal
|
// image registry if requested for CI builds, and validates minimal
|
||||||
// version that kubeadm SetInitDynamicDefaultssupports.
|
// version that kubeadm SetInitDynamicDefaultssupports.
|
||||||
func NormalizeKubernetesVersion(cfg *kubeadmapi.ClusterConfiguration) error {
|
func NormalizeKubernetesVersion(cfg *kubeadmapi.ClusterConfiguration) error {
|
||||||
|
isCIVersion := kubeadmutil.KubernetesIsCIVersion(cfg.KubernetesVersion)
|
||||||
|
|
||||||
// Requested version is automatic CI build, thus use KubernetesCI Image Repository for core images
|
// Requested version is automatic CI build, thus use KubernetesCI Image Repository for core images
|
||||||
if kubeadmutil.KubernetesIsCIVersion(cfg.KubernetesVersion) {
|
if isCIVersion {
|
||||||
cfg.CIImageRepository = constants.DefaultCIImageRepository
|
cfg.CIImageRepository = constants.DefaultCIImageRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +103,12 @@ func NormalizeKubernetesVersion(cfg *kubeadmapi.ClusterConfiguration) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Requested version is automatic CI build, thus mark CIKubernetesVersion as `ci/<resolved-version>`
|
||||||
|
if isCIVersion {
|
||||||
|
cfg.CIKubernetesVersion = fmt.Sprintf("ci/%s", ver)
|
||||||
|
}
|
||||||
|
|
||||||
cfg.KubernetesVersion = ver
|
cfg.KubernetesVersion = ver
|
||||||
|
|
||||||
// Parse the given kubernetes version and make sure it's higher than the lowest supported
|
// Parse the given kubernetes version and make sure it's higher than the lowest supported
|
||||||
|
Loading…
Reference in New Issue
Block a user