|
| 1 | +// Module included in the following assemblies: |
| 2 | +// * hosted_control_planes/hcp-machine-config.adoc |
| 3 | + |
| 4 | +:_mod-docs-content-type: PROCEDURE |
| 5 | +[id="hcp-configure-ntp_{context}"] |
| 6 | += Configuring the NTP server for hosted clusters |
| 7 | + |
| 8 | +You can configure the Network Time Protocol (NTP) server for your hosted clusters by using Butane. |
| 9 | + |
| 10 | +.Procedure |
| 11 | + |
| 12 | +. Create a Butane config file, `99-worker-chrony.bu`, that includes the contents of the `chrony.conf` file. For more information about Butane, see "Creating machine configs with Butane". |
| 13 | ++ |
| 14 | +.Example `99-worker-chrony.bu` configuration |
| 15 | +[source,yaml,subs="attributes+"] |
| 16 | +---- |
| 17 | +# ... |
| 18 | +variant: openshift |
| 19 | +version: {product-version}.0 |
| 20 | +metadata: |
| 21 | + name: 99-worker-chrony |
| 22 | + labels: |
| 23 | + machineconfiguration.openshift.io/role: worker |
| 24 | +storage: |
| 25 | + files: |
| 26 | + - path: /etc/chrony.conf |
| 27 | + mode: 0644 #<1> |
| 28 | + overwrite: true |
| 29 | + contents: |
| 30 | + inline: | |
| 31 | + pool 0.rhel.pool.ntp.org iburst #<2> |
| 32 | + driftfile /var/lib/chrony/drift |
| 33 | + makestep 1.0 3 |
| 34 | + rtcsync |
| 35 | + logdir /var/log/chrony |
| 36 | +# ... |
| 37 | +---- |
| 38 | +<1> Specify an octal value mode for the `mode` field in the machine config file. After creating the file and applying the changes, the `mode` field is converted to a decimal value. |
| 39 | +<2> Specify any valid, reachable time source, such as the one provided by your Dynamic Host Configuration Protocol (DHCP) server. |
| 40 | ++ |
| 41 | +[NOTE] |
| 42 | +==== |
| 43 | +For machine-to-machine communication, the NTP on the User Datagram Protocol (UDP) port is `123`. If you configured an external NTP time server, you must open UDP port `123`. |
| 44 | +==== |
| 45 | + |
| 46 | +. Use Butane to generate a `MachineConfig` object file, `99-worker-chrony.yaml`, that contains a configuration that Butane sends to the nodes. Run the following command: |
| 47 | ++ |
| 48 | +[source,terminal] |
| 49 | +---- |
| 50 | +$ butane 99-worker-chrony.bu -o 99-worker-chrony.yaml |
| 51 | +---- |
| 52 | ++ |
| 53 | +.Example `99-worker-chrony.yaml` configuration |
| 54 | +[source,yaml] |
| 55 | +---- |
| 56 | +# Generated by Butane; do not edit |
| 57 | +apiVersion: machineconfiguration.openshift.io/v1 |
| 58 | +kind: MachineConfig |
| 59 | +metadata: |
| 60 | + labels: |
| 61 | + machineconfiguration.openshift.io/role: worker |
| 62 | + name: <machineconfig_name> |
| 63 | +spec: |
| 64 | + config: |
| 65 | + ignition: |
| 66 | + version: 3.2.0 |
| 67 | + storage: |
| 68 | + files: |
| 69 | + - contents: |
| 70 | + source: data:... |
| 71 | + mode: 420 |
| 72 | + overwrite: true |
| 73 | + path: /example/path |
| 74 | +---- |
| 75 | + |
| 76 | +. Add the contents of the `99-worker-chrony.yaml` file inside of a config map in the management cluster: |
| 77 | ++ |
| 78 | +.Example config map |
| 79 | +[source,yaml] |
| 80 | +---- |
| 81 | +apiVersion: v1 |
| 82 | +kind: ConfigMap |
| 83 | +metadata: |
| 84 | + name: <configmap_name> |
| 85 | + namespace: <namespace> #<1> |
| 86 | +data: |
| 87 | + config: | |
| 88 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 89 | + kind: MachineConfig |
| 90 | + metadata: |
| 91 | + labels: |
| 92 | + machineconfiguration.openshift.io/role: worker |
| 93 | + name: <machineconfig_name> |
| 94 | + spec: |
| 95 | + config: |
| 96 | + ignition: |
| 97 | + version: 3.2.0 |
| 98 | + storage: |
| 99 | + files: |
| 100 | + - contents: |
| 101 | + source: data:... |
| 102 | + mode: 420 |
| 103 | + overwrite: true |
| 104 | + path: /example/path |
| 105 | +# ... |
| 106 | +---- |
| 107 | +<1> Replace `<namespace>` with the name of your namespace where you created the node pool, such as `clusters`. |
| 108 | + |
| 109 | +. Apply the config map to your node pool by running the following command: |
| 110 | ++ |
| 111 | +[source,terminal] |
| 112 | +---- |
| 113 | +$ oc edit nodepool <nodepool_name> --namespace <hosted_cluster_namespace> |
| 114 | +---- |
| 115 | ++ |
| 116 | +.Example `NodePool` configuration |
| 117 | +[source,yaml] |
| 118 | +---- |
| 119 | +apiVersion: hypershift.openshift.io/v1alpha1 |
| 120 | +kind: NodePool |
| 121 | +metadata: |
| 122 | +# ... |
| 123 | + name: nodepool-1 |
| 124 | + namespace: clusters |
| 125 | +# ... |
| 126 | +spec: |
| 127 | + config: |
| 128 | + - name: <configmap_name> #<1> |
| 129 | +# ... |
| 130 | +---- |
| 131 | +<1> Replace `<configmap_name>` with the name of your config map. |
| 132 | + |
| 133 | +. Add the list of your NTP servers in the `infra-env.yaml` file, which defines the `InfraEnv` custom resource (CR): |
| 134 | ++ |
| 135 | +.Example `infra-env.yaml` file |
| 136 | +[source,yaml] |
| 137 | +---- |
| 138 | +apiVersion: agent-install.openshift.io/v1beta1 |
| 139 | +kind: InfraEnv |
| 140 | +# ... |
| 141 | +spec: |
| 142 | + additionalNTPSources: |
| 143 | + - <ntp_server> #<1> |
| 144 | + - <ntp_server1> |
| 145 | + - <ntp_server2> |
| 146 | +# ... |
| 147 | +---- |
| 148 | +<1> Replace `<ntp_server>` with the name of your NTP server. For more details about creating a host inventory and the `InfraEnv` CR, see "Creating a host inventory". |
| 149 | + |
| 150 | +. Apply the `InfraEnv` CR by running the following command: |
| 151 | ++ |
| 152 | +[source,terminal] |
| 153 | +---- |
| 154 | +$ oc apply -f infra-env.yaml |
| 155 | +---- |
| 156 | + |
| 157 | +.Verification |
| 158 | + |
| 159 | +* Check the following fields to know the status of your host inventory: |
| 160 | ++ |
| 161 | +** `conditions`: The standard Kubernetes conditions indicating if the image was created successfully. |
| 162 | +** `isoDownloadURL`: The URL to download the Discovery Image. |
| 163 | +** `createdTime`: The time at which the image was last created. If you modify the `InfraEnv` CR, ensure that you have updated the timestamp before downloading a new image. |
| 164 | ++ |
| 165 | +Verify that your host inventory is created by running the following command: |
| 166 | ++ |
| 167 | +[source,terminal] |
| 168 | +---- |
| 169 | +$ oc describe infraenv <infraenv_resource_name> -n <infraenv_namespace> |
| 170 | +---- |
| 171 | ++ |
| 172 | +[NOTE] |
| 173 | +==== |
| 174 | +If you modify the `InfraEnv` CR, confirm that the `InfraEnv` CR has created a new Discovery Image by looking at the `createdTime` field. If you already booted hosts, boot them again with the latest Discovery Image. |
| 175 | +==== |
0 commit comments