feat: add support for disabling time

Adds the capability to diasable NTP when it cannot be provided in the deployed network

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

add document update.

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>
This commit is contained in:
Niklas Wik 2020-09-29 09:04:07 +03:00 committed by talos-bot
parent 21f1bc6853
commit eb9ee06dbc
9 changed files with 25 additions and 6 deletions

View File

@ -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.

View File

@ -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{},
)

View File

@ -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"}
}

View File

@ -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"}
}

View File

@ -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"}
}

View File

@ -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"}
}

View File

@ -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
}

View File

@ -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

View File

@ -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`