mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Add criSocket to kubeadm MasterConfiguration manifest
This commit is contained in:
parent
3c6392985f
commit
2c956cf19e
@ -44,6 +44,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
|
|||||||
obj.CertificatesDir = "foo"
|
obj.CertificatesDir = "foo"
|
||||||
obj.APIServerCertSANs = []string{"foo"}
|
obj.APIServerCertSANs = []string{"foo"}
|
||||||
obj.Token = "foo"
|
obj.Token = "foo"
|
||||||
|
obj.CRISocket = "foo"
|
||||||
obj.Etcd.Image = "foo"
|
obj.Etcd.Image = "foo"
|
||||||
obj.Etcd.DataDir = "foo"
|
obj.Etcd.DataDir = "foo"
|
||||||
obj.ImageRepository = "foo"
|
obj.ImageRepository = "foo"
|
||||||
|
@ -62,6 +62,9 @@ type MasterConfiguration struct {
|
|||||||
// TokenTTL is a ttl for Token. Defaults to 24h.
|
// TokenTTL is a ttl for Token. Defaults to 24h.
|
||||||
TokenTTL *metav1.Duration
|
TokenTTL *metav1.Duration
|
||||||
|
|
||||||
|
// CRISocket is used to retrieve container runtime info.
|
||||||
|
CRISocket string
|
||||||
|
|
||||||
// APIServerExtraArgs is a set of extra flags to pass to the API Server or override
|
// APIServerExtraArgs is a set of extra flags to pass to the API Server or override
|
||||||
// default ones in form of <flagname>=<value>.
|
// default ones in form of <flagname>=<value>.
|
||||||
// TODO: This is temporary and ideally we would like to switch all components to
|
// TODO: This is temporary and ideally we would like to switch all components to
|
||||||
|
@ -50,6 +50,8 @@ const (
|
|||||||
DefaultImageRepository = "gcr.io/google_containers"
|
DefaultImageRepository = "gcr.io/google_containers"
|
||||||
// DefaultManifestsDir defines default manifests directory
|
// DefaultManifestsDir defines default manifests directory
|
||||||
DefaultManifestsDir = "/etc/kubernetes/manifests"
|
DefaultManifestsDir = "/etc/kubernetes/manifests"
|
||||||
|
// DefaultCRISocket defines the default cri socket
|
||||||
|
DefaultCRISocket = "/var/run/dockershim.sock"
|
||||||
|
|
||||||
// DefaultEtcdDataDir defines default location of etcd where static pods will save data to
|
// DefaultEtcdDataDir defines default location of etcd where static pods will save data to
|
||||||
DefaultEtcdDataDir = "/var/lib/etcd"
|
DefaultEtcdDataDir = "/var/lib/etcd"
|
||||||
@ -105,6 +107,10 @@ func SetDefaults_MasterConfiguration(obj *MasterConfiguration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if obj.CRISocket == "" {
|
||||||
|
obj.CRISocket = DefaultCRISocket
|
||||||
|
}
|
||||||
|
|
||||||
if obj.ImageRepository == "" {
|
if obj.ImageRepository == "" {
|
||||||
obj.ImageRepository = DefaultImageRepository
|
obj.ImageRepository = DefaultImageRepository
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,9 @@ type MasterConfiguration struct {
|
|||||||
// TokenTTL is a ttl for Token. Defaults to 24h.
|
// TokenTTL is a ttl for Token. Defaults to 24h.
|
||||||
TokenTTL *metav1.Duration `json:"tokenTTL,omitempty"`
|
TokenTTL *metav1.Duration `json:"tokenTTL,omitempty"`
|
||||||
|
|
||||||
|
// CRISocket is used to retrieve container runtime info.
|
||||||
|
CRISocket string `json:"criSocket,omitempty"`
|
||||||
|
|
||||||
// APIServerExtraArgs is a set of extra flags to pass to the API Server or override
|
// APIServerExtraArgs is a set of extra flags to pass to the API Server or override
|
||||||
// default ones in form of <flagname>=<value>.
|
// default ones in form of <flagname>=<value>.
|
||||||
// TODO: This is temporary and ideally we would like to switch all components to
|
// TODO: This is temporary and ideally we would like to switch all components to
|
||||||
|
@ -205,6 +205,7 @@ func autoConvert_v1alpha1_MasterConfiguration_To_kubeadm_MasterConfiguration(in
|
|||||||
out.PrivilegedPods = in.PrivilegedPods
|
out.PrivilegedPods = in.PrivilegedPods
|
||||||
out.Token = in.Token
|
out.Token = in.Token
|
||||||
out.TokenTTL = (*v1.Duration)(unsafe.Pointer(in.TokenTTL))
|
out.TokenTTL = (*v1.Duration)(unsafe.Pointer(in.TokenTTL))
|
||||||
|
out.CRISocket = in.CRISocket
|
||||||
out.APIServerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.APIServerExtraArgs))
|
out.APIServerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.APIServerExtraArgs))
|
||||||
out.ControllerManagerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.ControllerManagerExtraArgs))
|
out.ControllerManagerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.ControllerManagerExtraArgs))
|
||||||
out.SchedulerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.SchedulerExtraArgs))
|
out.SchedulerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.SchedulerExtraArgs))
|
||||||
@ -247,6 +248,7 @@ func autoConvert_kubeadm_MasterConfiguration_To_v1alpha1_MasterConfiguration(in
|
|||||||
out.PrivilegedPods = in.PrivilegedPods
|
out.PrivilegedPods = in.PrivilegedPods
|
||||||
out.Token = in.Token
|
out.Token = in.Token
|
||||||
out.TokenTTL = (*v1.Duration)(unsafe.Pointer(in.TokenTTL))
|
out.TokenTTL = (*v1.Duration)(unsafe.Pointer(in.TokenTTL))
|
||||||
|
out.CRISocket = in.CRISocket
|
||||||
out.APIServerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.APIServerExtraArgs))
|
out.APIServerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.APIServerExtraArgs))
|
||||||
out.ControllerManagerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.ControllerManagerExtraArgs))
|
out.ControllerManagerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.ControllerManagerExtraArgs))
|
||||||
out.SchedulerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.SchedulerExtraArgs))
|
out.SchedulerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.SchedulerExtraArgs))
|
||||||
|
@ -113,7 +113,6 @@ func NewCmdInit(out io.Writer) *cobra.Command {
|
|||||||
var skipTokenPrint bool
|
var skipTokenPrint bool
|
||||||
var dryRun bool
|
var dryRun bool
|
||||||
var featureGatesString string
|
var featureGatesString string
|
||||||
var criSocket string
|
|
||||||
var ignorePreflightErrors []string
|
var ignorePreflightErrors []string
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
@ -132,7 +131,7 @@ func NewCmdInit(out io.Writer) *cobra.Command {
|
|||||||
ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(ignorePreflightErrors, skipPreFlight)
|
ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(ignorePreflightErrors, skipPreFlight)
|
||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
|
|
||||||
i, err := NewInit(cfgPath, internalcfg, ignorePreflightErrorsSet, skipTokenPrint, dryRun, criSocket)
|
i, err := NewInit(cfgPath, internalcfg, ignorePreflightErrorsSet, skipTokenPrint, dryRun)
|
||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
kubeadmutil.CheckErr(i.Validate(cmd))
|
kubeadmutil.CheckErr(i.Validate(cmd))
|
||||||
kubeadmutil.CheckErr(i.Run(out))
|
kubeadmutil.CheckErr(i.Run(out))
|
||||||
@ -140,7 +139,7 @@ func NewCmdInit(out io.Writer) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AddInitConfigFlags(cmd.PersistentFlags(), cfg, &featureGatesString)
|
AddInitConfigFlags(cmd.PersistentFlags(), cfg, &featureGatesString)
|
||||||
AddInitOtherFlags(cmd.PersistentFlags(), &cfgPath, &skipPreFlight, &skipTokenPrint, &dryRun, &criSocket, &ignorePreflightErrors)
|
AddInitOtherFlags(cmd.PersistentFlags(), &cfgPath, &skipPreFlight, &skipTokenPrint, &dryRun, &ignorePreflightErrors)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
@ -191,6 +190,10 @@ func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiext.MasterConfigur
|
|||||||
&cfg.TokenTTL.Duration, "token-ttl", cfg.TokenTTL.Duration,
|
&cfg.TokenTTL.Duration, "token-ttl", cfg.TokenTTL.Duration,
|
||||||
"The duration before the bootstrap token is automatically deleted. If set to '0', the token will never expire.",
|
"The duration before the bootstrap token is automatically deleted. If set to '0', the token will never expire.",
|
||||||
)
|
)
|
||||||
|
flagSet.StringVar(
|
||||||
|
&cfg.CRISocket, "cri-socket", cfg.CRISocket,
|
||||||
|
`Specify the CRI socket to connect to.`,
|
||||||
|
)
|
||||||
flagSet.StringVar(featureGatesString, "feature-gates", *featureGatesString, "A set of key=value pairs that describe feature gates for various features. "+
|
flagSet.StringVar(featureGatesString, "feature-gates", *featureGatesString, "A set of key=value pairs that describe feature gates for various features. "+
|
||||||
"Options are:\n"+strings.Join(features.KnownFeatures(&features.InitFeatureGates), "\n"))
|
"Options are:\n"+strings.Join(features.KnownFeatures(&features.InitFeatureGates), "\n"))
|
||||||
|
|
||||||
@ -200,7 +203,7 @@ func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiext.MasterConfigur
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddInitOtherFlags adds init flags that are not bound to a configuration file to the given flagset
|
// AddInitOtherFlags adds init flags that are not bound to a configuration file to the given flagset
|
||||||
func AddInitOtherFlags(flagSet *flag.FlagSet, cfgPath *string, skipPreFlight, skipTokenPrint, dryRun *bool, criSocket *string, ignorePreflightErrors *[]string) {
|
func AddInitOtherFlags(flagSet *flag.FlagSet, cfgPath *string, skipPreFlight, skipTokenPrint, dryRun *bool, ignorePreflightErrors *[]string) {
|
||||||
flagSet.StringVar(
|
flagSet.StringVar(
|
||||||
cfgPath, "config", *cfgPath,
|
cfgPath, "config", *cfgPath,
|
||||||
"Path to kubeadm config file. WARNING: Usage of a configuration file is experimental.",
|
"Path to kubeadm config file. WARNING: Usage of a configuration file is experimental.",
|
||||||
@ -225,14 +228,10 @@ func AddInitOtherFlags(flagSet *flag.FlagSet, cfgPath *string, skipPreFlight, sk
|
|||||||
dryRun, "dry-run", *dryRun,
|
dryRun, "dry-run", *dryRun,
|
||||||
"Don't apply any changes; just output what would be done.",
|
"Don't apply any changes; just output what would be done.",
|
||||||
)
|
)
|
||||||
flagSet.StringVar(
|
|
||||||
criSocket, "cri-socket", "/var/run/dockershim.sock",
|
|
||||||
`Specify the CRI socket to connect to.`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInit validates given arguments and instantiates Init struct with provided information.
|
// NewInit validates given arguments and instantiates Init struct with provided information.
|
||||||
func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, ignorePreflightErrors sets.String, skipTokenPrint, dryRun bool, criSocket string) (*Init, error) {
|
func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, ignorePreflightErrors sets.String, skipTokenPrint, dryRun bool) (*Init, error) {
|
||||||
|
|
||||||
if cfgPath != "" {
|
if cfgPath != "" {
|
||||||
b, err := ioutil.ReadFile(cfgPath)
|
b, err := ioutil.ReadFile(cfgPath)
|
||||||
@ -265,7 +264,7 @@ func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, ignorePrefligh
|
|||||||
|
|
||||||
fmt.Println("[preflight] Running pre-flight checks.")
|
fmt.Println("[preflight] Running pre-flight checks.")
|
||||||
|
|
||||||
if err := preflight.RunInitMasterChecks(utilsexec.New(), cfg, criSocket, ignorePreflightErrors); err != nil {
|
if err := preflight.RunInitMasterChecks(utilsexec.New(), cfg, ignorePreflightErrors); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,8 +70,7 @@ func NewCmdPreFlightMaster() *cobra.Command {
|
|||||||
Example: masterPreflightExample,
|
Example: masterPreflightExample,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cfg := &kubeadmapi.MasterConfiguration{}
|
cfg := &kubeadmapi.MasterConfiguration{}
|
||||||
criSocket := ""
|
err := preflight.RunInitMasterChecks(utilsexec.New(), cfg, sets.NewString())
|
||||||
err := preflight.RunInitMasterChecks(utilsexec.New(), cfg, criSocket, sets.NewString())
|
|
||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -851,7 +851,7 @@ func getEtcdVersionResponse(client *http.Client, url string, target interface{})
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RunInitMasterChecks executes all individual, applicable to Master node checks.
|
// RunInitMasterChecks executes all individual, applicable to Master node checks.
|
||||||
func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfiguration, criSocket string, ignorePreflightErrors sets.String) error {
|
func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfiguration, ignorePreflightErrors sets.String) error {
|
||||||
// First, check if we're root separately from the other preflight checks and fail fast
|
// First, check if we're root separately from the other preflight checks and fail fast
|
||||||
if err := RunRootCheckOnly(ignorePreflightErrors); err != nil {
|
if err := RunRootCheckOnly(ignorePreflightErrors); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -869,7 +869,7 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfi
|
|||||||
|
|
||||||
checks := []Checker{
|
checks := []Checker{
|
||||||
KubernetesVersionCheck{KubernetesVersion: cfg.KubernetesVersion, KubeadmVersion: kubeadmversion.Get().GitVersion},
|
KubernetesVersionCheck{KubernetesVersion: cfg.KubernetesVersion, KubeadmVersion: kubeadmversion.Get().GitVersion},
|
||||||
SystemVerificationCheck{CRISocket: criSocket},
|
SystemVerificationCheck{CRISocket: cfg.CRISocket},
|
||||||
IsPrivilegedUserCheck{},
|
IsPrivilegedUserCheck{},
|
||||||
HostnameCheck{nodeName: cfg.NodeName},
|
HostnameCheck{nodeName: cfg.NodeName},
|
||||||
KubeletVersionCheck{KubernetesVersion: cfg.KubernetesVersion},
|
KubeletVersionCheck{KubernetesVersion: cfg.KubernetesVersion},
|
||||||
|
@ -223,7 +223,7 @@ func TestRunInitMasterChecks(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, rt := range tests {
|
for _, rt := range tests {
|
||||||
actual := RunInitMasterChecks(exec.New(), rt.cfg, "", sets.NewString())
|
actual := RunInitMasterChecks(exec.New(), rt.cfg, sets.NewString())
|
||||||
if (actual == nil) != rt.expected {
|
if (actual == nil) != rt.expected {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"failed RunInitMasterChecks:\n\texpected: %t\n\t actual: %t\n\t error: %v",
|
"failed RunInitMasterChecks:\n\texpected: %t\n\t actual: %t\n\t error: %v",
|
||||||
|
Loading…
Reference in New Issue
Block a user