diff --git a/manifests/function/airshipctl-base-catalogues/networking.yaml b/manifests/function/airshipctl-base-catalogues/networking.yaml index c420f874d..09440e304 100644 --- a/manifests/function/airshipctl-base-catalogues/networking.yaml +++ b/manifests/function/airshipctl-base-catalogues/networking.yaml @@ -67,3 +67,9 @@ spec: type: dns - address: 8.8.4.4 type: dns + ntp: + servers: + - 0.pool.ntp.org + - 1.pool.ntp.org + - 2.pool.ntp.org + - 3.pool.ntp.org \ No newline at end of file diff --git a/manifests/function/airshipctl-schemas/airshipit.org_networkcatalogues.yaml b/manifests/function/airshipctl-schemas/airshipit.org_networkcatalogues.yaml index fe0bb3454..72b8e5a78 100644 --- a/manifests/function/airshipctl-schemas/airshipit.org_networkcatalogues.yaml +++ b/manifests/function/airshipctl-schemas/airshipit.org_networkcatalogues.yaml @@ -175,6 +175,16 @@ spec: format: cidr type: string type: object + ntp: + description: NtpSpec defines the spec for NTP servers + properties: + enabled: + type: boolean + servers: + items: + type: string + type: array + type: object type: object type: object served: true diff --git a/manifests/function/k8scontrol/replacements/networking.yaml b/manifests/function/k8scontrol/replacements/networking.yaml index 10e02a86c..4ed7fee89 100644 --- a/manifests/function/k8scontrol/replacements/networking.yaml +++ b/manifests/function/k8scontrol/replacements/networking.yaml @@ -43,3 +43,14 @@ replacements: objref: kind: Metal3Cluster fieldrefs: ["spec.controlPlaneEndpoint"] + +# Replace the k8s controlplane NTP servers +- source: + objref: + kind: NetworkCatalogue + name: networking + fieldref: spec.ntp + target: + objref: + kind: KubeadmControlPlane + fieldrefs: ["spec.kubeadmConfigSpec.ntp"] diff --git a/manifests/function/workers-capm3/replacements/kustomization.yaml b/manifests/function/workers-capm3/replacements/kustomization.yaml index 13e5a5f7f..a23d0dd1e 100644 --- a/manifests/function/workers-capm3/replacements/kustomization.yaml +++ b/manifests/function/workers-capm3/replacements/kustomization.yaml @@ -3,3 +3,4 @@ kind: Kustomization resources: - workers-env-vars.yaml - generated-secrets.yaml + - networking.yaml diff --git a/manifests/function/workers-capm3/replacements/networking.yaml b/manifests/function/workers-capm3/replacements/networking.yaml new file mode 100644 index 000000000..15a4c7a3d --- /dev/null +++ b/manifests/function/workers-capm3/replacements/networking.yaml @@ -0,0 +1,19 @@ +apiVersion: airshipit.org/v1alpha1 +kind: ReplacementTransformer +metadata: + name: workers-networking-replacements + annotations: + config.kubernetes.io/function: |- + container: + image: quay.io/airshipit/replacement-transformer:latest +replacements: +- source: + objref: + kind: NetworkCatalogue + name: networking + fieldref: spec.ntp + target: + objref: + kind: KubeadmConfigTemplate + name: worker-1 + fieldrefs: ["spec.template.spec.ntp"] diff --git a/pkg/api/v1alpha1/networkcatalogue_types.go b/pkg/api/v1alpha1/networkcatalogue_types.go index bb901ad3b..9f2cdb98b 100644 --- a/pkg/api/v1alpha1/networkcatalogue_types.go +++ b/pkg/api/v1alpha1/networkcatalogue_types.go @@ -108,11 +108,18 @@ type IronicSpec struct { IronicInspectorEndpoint string `json:"ironicInspectorEndpoint,omitempty"` } +// NtpSpec defines the spec for NTP servers +type NtpSpec struct { + Enabled bool `json:"enabled,omitempty"` + Servers []string `json:"servers,omitempty"` +} + // NetworkCatalogueSpec defines the default networking catalogs hosted in airshipctl type NetworkCatalogueSpec struct { CommonHostNetworking HostNetworkingSpec `json:"commonHostNetworking,omitempty"` Kubernetes KubernetesSpec `json:"kubernetes,omitempty"` Ironic IronicSpec `json:"ironic,omitempty"` + Ntp NtpSpec `json:"ntp,omitempty"` } // +kubebuilder:object:root=true diff --git a/pkg/api/v1alpha1/zz_generated.deepcopy.go b/pkg/api/v1alpha1/zz_generated.deepcopy.go index 8f3b82718..81c853656 100644 --- a/pkg/api/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/api/v1alpha1/zz_generated.deepcopy.go @@ -1178,6 +1178,7 @@ func (in *NetworkCatalogueSpec) DeepCopyInto(out *NetworkCatalogueSpec) { in.CommonHostNetworking.DeepCopyInto(&out.CommonHostNetworking) out.Kubernetes = in.Kubernetes out.Ironic = in.Ironic + in.Ntp.DeepCopyInto(&out.Ntp) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkCatalogueSpec. @@ -1222,6 +1223,26 @@ func (in *NetworkCatalogues) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NtpSpec) DeepCopyInto(out *NtpSpec) { + *out = *in + if in.Servers != nil { + in, out := &in.Servers, &out.Servers + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NtpSpec. +func (in *NtpSpec) DeepCopy() *NtpSpec { + if in == nil { + return nil + } + out := new(NtpSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Phase) DeepCopyInto(out *Phase) { *out = *in