Skip to content

Commit

Permalink
Add an option to skip NTP installation
Browse files Browse the repository at this point in the history
Add NTPConfig to ClusterSpec. NTPConfig has the SkipInstall option.

#9661
  • Loading branch information
kenji-cloudnatix committed Mar 30, 2021
1 parent 9775182 commit fe2dc8c
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nodeup/pkg/model/ntp.go
Expand Up @@ -34,6 +34,11 @@ var _ fi.ModelBuilder = &NTPBuilder{}

// Build is responsible for configuring NTP
func (b *NTPBuilder) Build(c *fi.ModelBuilderContext) error {
if b.skipInstall() {
klog.Infof("SkipInstall is set to true; won't install NTP")
return nil
}

switch b.Distribution {
case distributions.DistributionContainerOS:
klog.Infof("Detected ContainerOS; won't install ntp")
Expand Down Expand Up @@ -112,3 +117,10 @@ NTP=` + host + `
Mode: s("0644"),
}
}

// skipInstall determines if kops should skip the installation and configuration of NTP.
func (b *NTPBuilder) skipInstall() bool {
d := b.Cluster.Spec.NTP
// don't skip install if the user hasn't specified anything
return d != nil && d.SkipInstall
}
1 change: 1 addition & 0 deletions pkg/apis/kops/cluster.go
Expand Up @@ -159,6 +159,7 @@ type ClusterSpec struct {
MasterKubelet *KubeletConfigSpec `json:"masterKubelet,omitempty"`
CloudConfig *CloudConfiguration `json:"cloudConfig,omitempty"`
ExternalDNS *ExternalDNSConfig `json:"externalDns,omitempty"`
NTP *NTPConfig `json:"ntp,omitempty"`

// NodeTerminationHandler determines the cluster autoscaler configuration.
NodeTerminationHandler *NodeTerminationHandlerConfig `json:"nodeTerminationHandler,omitempty"`
Expand Down
23 changes: 23 additions & 0 deletions pkg/apis/kops/ntpconfig.go
@@ -0,0 +1,23 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package kops

// NTPConfig is the configuration for NTP.
type NTPConfig struct {
// SkipInstall is set to true when we prevent kops from installing and modifying NTP.
SkipInstall bool `json:"skipInstall,omitempty"`
}
1 change: 1 addition & 0 deletions pkg/apis/kops/v1alpha2/cluster.go
Expand Up @@ -158,6 +158,7 @@ type ClusterSpec struct {
MasterKubelet *KubeletConfigSpec `json:"masterKubelet,omitempty"`
CloudConfig *CloudConfiguration `json:"cloudConfig,omitempty"`
ExternalDNS *ExternalDNSConfig `json:"externalDns,omitempty"`
NTP *NTPConfig `json:"ntp,omitempty"`

// NodeTerminationHandler determines the cluster autoscaler configuration.
NodeTerminationHandler *NodeTerminationHandlerConfig `json:"nodeTerminationHandler,omitempty"`
Expand Down
23 changes: 23 additions & 0 deletions pkg/apis/kops/v1alpha2/ntpconfig.go
@@ -0,0 +1,23 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha2

// NTPConfig is the configuration for NTP.
type NTPConfig struct {
// SkipInstall when set to true will prevent kops from installing and modifying Docker in any way
SkipInstall bool `json:"skipInstall,omitempty"`
}
48 changes: 48 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fe2dc8c

Please sign in to comment.