diff --git a/docs/website/content/v0.7/en/configuration/v1alpha1.md b/docs/website/content/v0.7/en/configuration/v1alpha1.md index 5a277fcb7..bdcbf3299 100644 --- a/docs/website/content/v0.7/en/configuration/v1alpha1.md +++ b/docs/website/content/v0.7/en/configuration/v1alpha1.md @@ -870,6 +870,13 @@ Valid Values: ### TimeConfig +#### enabled + +Indicates if time (ntp) is enabled for the machine +Defaults to `true`. + +Type: `bool` + #### servers Specifies time (ntp) servers to use for setting system time. diff --git a/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer_tasks.go b/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer_tasks.go index c20583d07..df3d6ab19 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer_tasks.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer_tasks.go @@ -613,7 +613,7 @@ func StartAllServices(seq runtime.Sequence, data interface{}) (runtime.TaskExecu &services.Kubelet{}, ) - if r.State().Platform().Mode() != runtime.ModeContainer { + if r.State().Platform().Mode() != runtime.ModeContainer && r.Config().Machine().Time().Enabled() { svcs.Load( &services.Timed{}, ) diff --git a/internal/app/machined/pkg/system/services/apid.go b/internal/app/machined/pkg/system/services/apid.go index dbb8b2db4..f3c25beaf 100644 --- a/internal/app/machined/pkg/system/services/apid.go +++ b/internal/app/machined/pkg/system/services/apid.go @@ -63,7 +63,7 @@ func (o *APID) Condition(r runtime.Runtime) conditions.Condition { // DependsOn implements the Service interface. func (o *APID) DependsOn(r runtime.Runtime) []string { - if r.State().Platform().Mode() == runtime.ModeContainer { + if r.State().Platform().Mode() == runtime.ModeContainer || !r.Config().Machine().Time().Enabled() { return []string{"containerd", "networkd"} } diff --git a/internal/app/machined/pkg/system/services/etcd.go b/internal/app/machined/pkg/system/services/etcd.go index 46330b800..a1c63728e 100644 --- a/internal/app/machined/pkg/system/services/etcd.go +++ b/internal/app/machined/pkg/system/services/etcd.go @@ -85,7 +85,7 @@ func (e *Etcd) Condition(r runtime.Runtime) conditions.Condition { // DependsOn implements the Service interface. func (e *Etcd) DependsOn(r runtime.Runtime) []string { - if r.State().Platform().Mode() == runtime.ModeContainer { + if r.State().Platform().Mode() == runtime.ModeContainer || !r.Config().Machine().Time().Enabled() { return []string{"containerd", "networkd"} } diff --git a/internal/app/machined/pkg/system/services/kubelet.go b/internal/app/machined/pkg/system/services/kubelet.go index 42054aab5..5bb02963c 100644 --- a/internal/app/machined/pkg/system/services/kubelet.go +++ b/internal/app/machined/pkg/system/services/kubelet.go @@ -136,7 +136,7 @@ func (k *Kubelet) Condition(r runtime.Runtime) conditions.Condition { // DependsOn implements the Service interface. func (k *Kubelet) DependsOn(r runtime.Runtime) []string { - if r.State().Platform().Mode() == runtime.ModeContainer { + if r.State().Platform().Mode() == runtime.ModeContainer || !r.Config().Machine().Time().Enabled() { return []string{"cri", "networkd"} } diff --git a/internal/app/machined/pkg/system/services/trustd.go b/internal/app/machined/pkg/system/services/trustd.go index 72a1d96ee..2fc366a56 100644 --- a/internal/app/machined/pkg/system/services/trustd.go +++ b/internal/app/machined/pkg/system/services/trustd.go @@ -51,7 +51,7 @@ func (t *Trustd) Condition(r runtime.Runtime) conditions.Condition { // DependsOn implements the Service interface. func (t *Trustd) DependsOn(r runtime.Runtime) []string { - if r.State().Platform().Mode() == runtime.ModeContainer { + if r.State().Platform().Mode() == runtime.ModeContainer || !r.Config().Machine().Time().Enabled() { return []string{"containerd", "networkd"} } diff --git a/pkg/machinery/config/provider.go b/pkg/machinery/config/provider.go index c1dda58c3..d05663d8e 100644 --- a/pkg/machinery/config/provider.go +++ b/pkg/machinery/config/provider.go @@ -167,6 +167,7 @@ type Route interface { // Time defines the requirements for a config that pertains to time related // options. type Time interface { + Enabled() bool Servers() []string } diff --git a/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go b/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go index d5dbb7fe1..b826e985d 100644 --- a/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go +++ b/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go @@ -113,7 +113,9 @@ func (m *MachineConfig) Network() config.MachineNetwork { // Time implements the config.Provider interface. func (m *MachineConfig) Time() config.Time { if m.MachineTime == nil { - return &TimeConfig{} + return &TimeConfig{ + TimeEnabled: true, + } } return m.MachineTime @@ -920,6 +922,11 @@ func (v *Vlan) ID() uint16 { return v.VlanID } +// Enabled implements the config.Provider interface. +func (t *TimeConfig) Enabled() bool { + return t.TimeEnabled +} + // Servers implements the config.Provider interface. func (t *TimeConfig) Servers() []string { return t.TimeServers diff --git a/pkg/machinery/config/types/v1alpha1/v1alpha1_types.go b/pkg/machinery/config/types/v1alpha1/v1alpha1_types.go index b1f0bbc64..4d536f5d9 100644 --- a/pkg/machinery/config/types/v1alpha1/v1alpha1_types.go +++ b/pkg/machinery/config/types/v1alpha1/v1alpha1_types.go @@ -530,6 +530,10 @@ type InstallConfig struct { // TimeConfig represents the options for configuring time on a node. type TimeConfig struct { + // description: | + // Indicates if time (ntp) is enabled for the machine + // Defaults to `true`. + TimeEnabled bool `yaml:"enabled"` // description: | // Specifies time (ntp) servers to use for setting system time. // Defaults to `pool.ntp.org`