mirror of https://github.com/k3s-io/k3s
Merge pull request #75178 from rosti/kill-commonconfig
kubeadm: Cleanup CommonConfigurationk3s-v1.15.3
commit
0c93929298
|
@ -411,50 +411,3 @@ type HostPathMount struct {
|
||||||
// PathType is the type of the HostPath.
|
// PathType is the type of the HostPath.
|
||||||
PathType v1.HostPathType
|
PathType v1.HostPathType
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommonConfiguration defines the list of common configuration elements and the getter
|
|
||||||
// methods that must exist for both the InitConfiguration and JoinConfiguration objects.
|
|
||||||
// This is used internally to deduplicate the kubeadm preflight checks.
|
|
||||||
type CommonConfiguration interface {
|
|
||||||
GetCRISocket() string
|
|
||||||
GetNodeName() string
|
|
||||||
GetKubernetesVersion() string
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCRISocket will return the CRISocket that is defined for the InitConfiguration.
|
|
||||||
// This is used internally to deduplicate the kubeadm preflight checks.
|
|
||||||
func (cfg *InitConfiguration) GetCRISocket() string {
|
|
||||||
return cfg.NodeRegistration.CRISocket
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetNodeName will return the NodeName that is defined for the InitConfiguration.
|
|
||||||
// This is used internally to deduplicate the kubeadm preflight checks.
|
|
||||||
func (cfg *InitConfiguration) GetNodeName() string {
|
|
||||||
return cfg.NodeRegistration.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetKubernetesVersion will return the KubernetesVersion that is defined for the InitConfiguration.
|
|
||||||
// This is used internally to deduplicate the kubeadm preflight checks.
|
|
||||||
func (cfg *InitConfiguration) GetKubernetesVersion() string {
|
|
||||||
return cfg.KubernetesVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCRISocket will return the CRISocket that is defined for the JoinConfiguration.
|
|
||||||
// This is used internally to deduplicate the kubeadm preflight checks.
|
|
||||||
func (cfg *JoinConfiguration) GetCRISocket() string {
|
|
||||||
return cfg.NodeRegistration.CRISocket
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetNodeName will return the NodeName that is defined for the JoinConfiguration.
|
|
||||||
// This is used internally to deduplicate the kubeadm preflight checks.
|
|
||||||
func (cfg *JoinConfiguration) GetNodeName() string {
|
|
||||||
return cfg.NodeRegistration.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetKubernetesVersion will return an empty string since KubernetesVersion is not a
|
|
||||||
// defined property for JoinConfiguration. This will just cause the regex validation
|
|
||||||
// of the defined version to be skipped during the preflight checks.
|
|
||||||
// This is used internally to deduplicate the kubeadm preflight checks.
|
|
||||||
func (cfg *JoinConfiguration) GetKubernetesVersion() string {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
|
@ -423,7 +423,7 @@ func NewCmdConfigImagesPull() *cobra.Command {
|
||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
internalcfg, err := configutil.LoadOrDefaultInitConfiguration(cfgPath, externalcfg)
|
internalcfg, err := configutil.LoadOrDefaultInitConfiguration(cfgPath, externalcfg)
|
||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), internalcfg.GetCRISocket())
|
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), internalcfg.NodeRegistration.CRISocket)
|
||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
imagesPull := NewImagesPull(containerRuntime, images.GetAllImages(&internalcfg.ClusterConfiguration))
|
imagesPull := NewImagesPull(containerRuntime, images.GetAllImages(&internalcfg.ClusterConfiguration))
|
||||||
kubeadmutil.CheckErr(imagesPull.PullAll())
|
kubeadmutil.CheckErr(imagesPull.PullAll())
|
||||||
|
|
|
@ -901,7 +901,7 @@ func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigura
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isSecondaryControlPlane {
|
if !isSecondaryControlPlane {
|
||||||
checks = addCommonChecks(execer, cfg, checks)
|
checks = addCommonChecks(execer, cfg.KubernetesVersion, &cfg.NodeRegistration, checks)
|
||||||
|
|
||||||
// Check IVPS required kernel module once we use IVPS kube-proxy mode
|
// Check IVPS required kernel module once we use IVPS kube-proxy mode
|
||||||
if cfg.ComponentConfigs.KubeProxy != nil && cfg.ComponentConfigs.KubeProxy.Mode == ipvsutil.IPVSProxyMode {
|
if cfg.ComponentConfigs.KubeProxy != nil && cfg.ComponentConfigs.KubeProxy.Mode == ipvsutil.IPVSProxyMode {
|
||||||
|
@ -959,7 +959,7 @@ func RunJoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.JoinConfigura
|
||||||
FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletKubeConfigFileName)},
|
FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletKubeConfigFileName)},
|
||||||
FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletBootstrapKubeConfigFileName)},
|
FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletBootstrapKubeConfigFileName)},
|
||||||
}
|
}
|
||||||
checks = addCommonChecks(execer, cfg, checks)
|
checks = addCommonChecks(execer, "", &cfg.NodeRegistration, checks)
|
||||||
if cfg.ControlPlane == nil {
|
if cfg.ControlPlane == nil {
|
||||||
checks = append(checks, FileAvailableCheck{Path: cfg.CACertPath})
|
checks = append(checks, FileAvailableCheck{Path: cfg.CACertPath})
|
||||||
}
|
}
|
||||||
|
@ -1006,8 +1006,8 @@ func RunOptionalJoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.Clust
|
||||||
|
|
||||||
// addCommonChecks is a helper function to deplicate checks that are common between both the
|
// addCommonChecks is a helper function to deplicate checks that are common between both the
|
||||||
// kubeadm init and join commands
|
// kubeadm init and join commands
|
||||||
func addCommonChecks(execer utilsexec.Interface, cfg kubeadmapi.CommonConfiguration, checks []Checker) []Checker {
|
func addCommonChecks(execer utilsexec.Interface, k8sVersion string, nodeReg *kubeadmapi.NodeRegistrationOptions, checks []Checker) []Checker {
|
||||||
containerRuntime, err := utilruntime.NewContainerRuntime(execer, cfg.GetCRISocket())
|
containerRuntime, err := utilruntime.NewContainerRuntime(execer, nodeReg.CRISocket)
|
||||||
isDocker := false
|
isDocker := false
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("[preflight] WARNING: Couldn't create the interface used for talking to the container runtime: %v\n", err)
|
fmt.Printf("[preflight] WARNING: Couldn't create the interface used for talking to the container runtime: %v\n", err)
|
||||||
|
@ -1044,8 +1044,8 @@ func addCommonChecks(execer utilsexec.Interface, cfg kubeadmapi.CommonConfigurat
|
||||||
}
|
}
|
||||||
checks = append(checks,
|
checks = append(checks,
|
||||||
SystemVerificationCheck{IsDocker: isDocker},
|
SystemVerificationCheck{IsDocker: isDocker},
|
||||||
HostnameCheck{nodeName: cfg.GetNodeName()},
|
HostnameCheck{nodeName: nodeReg.Name},
|
||||||
KubeletVersionCheck{KubernetesVersion: cfg.GetKubernetesVersion(), exec: execer},
|
KubeletVersionCheck{KubernetesVersion: k8sVersion, exec: execer},
|
||||||
ServiceCheck{Service: "kubelet", CheckIfActive: false},
|
ServiceCheck{Service: "kubelet", CheckIfActive: false},
|
||||||
PortOpenCheck{port: ports.KubeletPort})
|
PortOpenCheck{port: ports.KubeletPort})
|
||||||
return checks
|
return checks
|
||||||
|
@ -1062,7 +1062,7 @@ func RunRootCheckOnly(ignorePreflightErrors sets.String) error {
|
||||||
|
|
||||||
// RunPullImagesCheck will pull images kubeadm needs if they are not found on the system
|
// RunPullImagesCheck will pull images kubeadm needs if they are not found on the system
|
||||||
func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.String) error {
|
func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.String) error {
|
||||||
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), cfg.GetCRISocket())
|
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), cfg.NodeRegistration.CRISocket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue