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 31, 2021
1 parent 9775182 commit baff30d
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/cluster_spec.md
Expand Up @@ -1293,3 +1293,14 @@ spec:

In the case of containerd, the cgroup-driver is dependant on the cgroup driver of kubelet. To use cgroupfs, just update the
cgroupDriver of kubelet to use cgroupfs.

## NTP

The installation and the configuration of NTP can be skipped by setting `managed` to `false`.

```yaml
spec:
ntp:
managed: false
```

9 changes: 9 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Expand Up @@ -3913,6 +3913,15 @@ spec:
NonMasqueradeCIDR is the CIDR for the internal k8s network (on which
pods & services live) It cannot overlap ServiceClusterIPRange
type: string
ntp:
description: NTPConfig is the configuration for NTP.
properties:
managed:
description: Managed controls if the NTP configuration is managed
by kOps. The NTP configuration task is skipped if this is set
to false.
type: boolean
type: object
podCIDR:
description: PodCIDR is the CIDR from which we allocate IPs for pods
type: string
Expand Down
13 changes: 13 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.managed() {
klog.Infof("Managed is set to false; 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,11 @@ NTP=` + host + `
Mode: s("0644"),
}
}

// managed determines if kops should manage the installation and configuration of NTP.
func (b *NTPBuilder) managed() bool {
n := b.Cluster.Spec.NTP
// Consider the NTP is managed when the NTP configuration
// is not specified (for backward compatibility).
return n == nil || n.Managed == nil || *n.Managed
}
1 change: 1 addition & 0 deletions pkg/apis/kops/BUILD.bazel

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

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
24 changes: 24 additions & 0 deletions pkg/apis/kops/ntpconfig.go
@@ -0,0 +1,24 @@
/*
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 {
// Managed controls if the NTP configuration is managed by kOps.
// The NTP configuration task is skipped if this is set to false.
Managed *bool `json:"managed,omitempty"`
}
1 change: 1 addition & 0 deletions pkg/apis/kops/v1alpha2/BUILD.bazel

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

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
24 changes: 24 additions & 0 deletions pkg/apis/kops/v1alpha2/ntpconfig.go
@@ -0,0 +1,24 @@
/*
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 {
// Managed controls if the NTP configuration is managed by kOps.
// The NTP configuration task is skipped if this is set to false.
Managed *bool `json:"managed,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.

26 changes: 26 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.

26 changes: 26 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 baff30d

Please sign in to comment.