An important configuration when running a Kubernetes cluster is to ensure that your nodes' clocks are in sync. Because of this, it is possible to configure DKP clusters to use custom NTP servers on cluster creation. When creating a cluster using the DKP CLI, you can specify the --dry-run flag to get the entire yaml output before creating a cluster using the below command:
dkp create cluster aws --cluster-name=${CLUSTER_NAME} \
--dry-run \
--output=yaml \
> ${CLUSTER_NAME}.yaml
All of the necessary YAML files for a default cluster are located in the output. To set custom NTP server values, you will need to edit the KubeAdmControlPlane
and the KubeadmConfigTemplate
resources. For the KubeAdmControlPlane
object, you will need to add the below entry into the .spec.kubeadmConfigSpec
section:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlane
metadata:
name: myControlplane-control-plane
namespace: default
spec:
kubeadmConfigSpec:
ntp:
enabled: true
servers:
- <your ntp1>
- <your ntp2>
For the KubeadmConfigTemplate
, you will need to add a .spec.ntp
entry such as the below:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: adoll-04202-md-0
namespace: default
spec:
template:
spec:
ntp:
enabled: true
servers:
- <your ntp>
- <your ntp>
After modifying your kubeadm objects, you can create all of your cluster objects by applying them to the bootstrap cluster with kubectl create -f <modified
yaml>
. After applying the yaml, wait for your cluster to fully deploy; you can watch things by running kubectl --kubeconfig $HOME/.kube/config wait --for=condition=controlplaneready
"clusters/${CLUSTER_NAME}" --timeout=60m
. Once the CLI has informed you that your cluster is ready, you can check your nodes by viewing the Chrony configuration file located in /etc/chrony. In this case, I applied two public NTP servers to my cluster yaml, 0.pool.ntp.org
and 1.pool.ntp.org
. When viewing the Chrony configuration file on the worker and control-plane nodes, we can see that the configuration was applied successfully:
root@ip:cat /etc/chrony/chrony.conf
# Welcome to the chrony configuration file. See chrony.conf(5) for more
# information about usuable directives.
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
# servers
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst