Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap: switch to chrony for ignition config #436

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions bootstrap/internal/ignition/butane/butane.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import (
)

// The template contains configurations for two main sections: systemd units and storage files.
// The first section defines two systemd units: rke2-install.service and ntpd.service.
// The first section defines two systemd units: rke2-install.service and chronyd.service.
// The rke2-install.service unit is enabled and is executed only once during the boot process to run the /etc/rke2-install.sh script.
// This script installs and deploys RKE2, and performs pre and post-installation commands.
// The ntpd.service unit is enabled only if NTP servers are specified.
// The chronyd.service unit is enabled only if NTP servers are specified.
// The second section defines storage files for the system. It creates a file at /etc/rke2-install.sh.
// If NTP servers are specified, it creates an NTP configuration file at /etc/ntp.conf.
// If NTP servers are specified, it creates an NTP configuration file at /etc/chrony.conf.
const (
butaneTemplate = `
variant: fcos
Expand All @@ -62,7 +62,7 @@ systemd:
[Install]
WantedBy=multi-user.target
{{- if .NTPServers }}
- name: ntpd.service
- name: chronyd.service
enabled: true
{{- end }}
storage:
Expand Down Expand Up @@ -129,28 +129,22 @@ storage:
{{ . | Indent 10 }}
{{- end }}
{{- if .NTPServers }}
- path: /etc/ntp.conf
- path: /etc/chrony.conf
mode: 0644
overwrite: true
contents:
inline: |
# Common pool
# Configured by RKE2 CAPI bootstrap provider
{{- range .NTPServers }}
server {{ . }}
{{- end }}

# Warning: Using default NTP settings will leave your NTP
# server accessible to all hosts on the Internet.

# If you want to deny all machines (including your own)
# from accessing the NTP server, uncomment:
#restrict default ignore

# Default configuration:
# - Allow only time queries, at a limited rate, sending KoD when in excess.
# - Allow all local queries (IPv4, IPv6)
restrict default nomodify nopeer noquery notrap limited kod
restrict 127.0.0.1
restrict [::1]
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
ntsdumpdir /var/lib/chrony
logdir /var/log/chrony
include /etc/chrony.d/*.conf
sourcedir /run/chrony-dhcp
{{- end }}
`
)
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/internal/ignition/butane/butane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ var _ = Describe("Render", func() {

Expect(ign.Storage.Files[3].Path).To(Equal("/etc/rke2-install.sh"))

Expect(ign.Storage.Files[4].Path).To(Equal("/etc/ntp.conf"))
Expect(ign.Storage.Files[4].Path).To(Equal("/etc/chrony.conf"))

Expect(ign.Systemd.Units).To(HaveLen(3))
Expect(ign.Systemd.Units[0].Name).To(Equal("rke2-install.service"))
Expect(ign.Systemd.Units[0].Contents).To(Equal(pointer.String("[Unit]\nDescription=rke2-install\nWants=network-online.target\nAfter=network-online.target network.target\nConditionPathExists=!/etc/cluster-api/bootstrap-success.complete\n[Service]\nUser=root\n# To not restart the unit when it exits, as it is expected.\nType=oneshot\nExecStart=/etc/rke2-install.sh\n[Install]\nWantedBy=multi-user.target\n")))
Expect(ign.Systemd.Units[0].Enabled).To(Equal(pointer.Bool(true)))

Expect(ign.Systemd.Units[1].Name).To(Equal("ntpd.service"))
Expect(ign.Systemd.Units[1].Name).To(Equal("chronyd.service"))
Expect(ign.Systemd.Units[1].Enabled).To(Equal(pointer.Bool(true)))

Expect(ign.Systemd.Units[2].Name).To(Equal("test.service"))
Expand Down
Loading