Skip to content

Commit

Permalink
add-timezone-support (kubernetes-sigs#9263)
Browse files Browse the repository at this point in the history
  • Loading branch information
yankay authored Sep 15, 2022
1 parent e76385e commit 97ca2f3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/ntp.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ ntp_servers:
- "3.your-ntp-server.org iburst"
```

## Setting the TimeZone

The timezone can also be set by the `ntp_timezone` , eg: "Etc/UTC","Asia/Shanghai". If not set, the timezone will not change.

```ShellSession
ntp_enabled: true
ntp_timezone: Etc/UTC
```

## Advanced Configure

Enable `tinker panic` is useful when running NTP in a VM environment to avoiding clock drift on VMs. It only takes effect when ntp_manage_config is true.
Expand Down
3 changes: 3 additions & 0 deletions roles/kubernetes/preinstall/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,6 @@ ntp_tinker_panic: false

# Force sync time immediately after the ntp installed, which is useful in in newly installed system.
ntp_force_sync_immediately: false

# Set the timezone for your server. eg: "Etc/UTC","Etc/GMT-8". If not set, the timezone will not change.
ntp_timezone: ""
14 changes: 14 additions & 0 deletions roles/kubernetes/preinstall/tasks/0081-ntp-configurations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,17 @@
name: "{{ ntp_service_name }}"
state: started
enabled: true

- name: Ensure tzdata package
package:
name:
- tzdata
state: present
when:
- ntp_timezone

- name: Set timezone
timezone:
name: "{{ ntp_timezone }}"
when:
- ntp_timezone
1 change: 1 addition & 0 deletions tests/files/packet_almalinux8-calico.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ loadbalancer_apiserver_type: haproxy

# NTP mangement
ntp_enabled: true
ntp_timezone: Etc/UTC
ntp_manage_config: true
ntp_tinker_panic: true
ntp_force_sync_immediately: true

0 comments on commit 97ca2f3

Please sign in to comment.