Add ntp to network catalogue

Adds an ntp object to the NetworkCatalogue schema
and populates default ntp servers into the networking
base catalogue. Also adds replacement rules in:

* function/k8scontrol/replacements
* function/workers-capm3/replacements

Change-Id: I5dedda563c8825c283e7ba846bedb0b282459d41
This commit is contained in:
Matthew Fuller 2021-03-19 18:48:29 +00:00
parent c8d9160fe2
commit b69a641940
7 changed files with 75 additions and 0 deletions

View File

@ -67,3 +67,9 @@ spec:
type: dns type: dns
- address: 8.8.4.4 - address: 8.8.4.4
type: dns type: dns
ntp:
servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
- 2.pool.ntp.org
- 3.pool.ntp.org

View File

@ -175,6 +175,16 @@ spec:
format: cidr format: cidr
type: string type: string
type: object 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
type: object type: object
served: true served: true

View File

@ -43,3 +43,14 @@ replacements:
objref: objref:
kind: Metal3Cluster kind: Metal3Cluster
fieldrefs: ["spec.controlPlaneEndpoint"] 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"]

View File

@ -3,3 +3,4 @@ kind: Kustomization
resources: resources:
- workers-env-vars.yaml - workers-env-vars.yaml
- generated-secrets.yaml - generated-secrets.yaml
- networking.yaml

View File

@ -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"]

View File

@ -108,11 +108,18 @@ type IronicSpec struct {
IronicInspectorEndpoint string `json:"ironicInspectorEndpoint,omitempty"` 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 // NetworkCatalogueSpec defines the default networking catalogs hosted in airshipctl
type NetworkCatalogueSpec struct { type NetworkCatalogueSpec struct {
CommonHostNetworking HostNetworkingSpec `json:"commonHostNetworking,omitempty"` CommonHostNetworking HostNetworkingSpec `json:"commonHostNetworking,omitempty"`
Kubernetes KubernetesSpec `json:"kubernetes,omitempty"` Kubernetes KubernetesSpec `json:"kubernetes,omitempty"`
Ironic IronicSpec `json:"ironic,omitempty"` Ironic IronicSpec `json:"ironic,omitempty"`
Ntp NtpSpec `json:"ntp,omitempty"`
} }
// +kubebuilder:object:root=true // +kubebuilder:object:root=true

View File

@ -1178,6 +1178,7 @@ func (in *NetworkCatalogueSpec) DeepCopyInto(out *NetworkCatalogueSpec) {
in.CommonHostNetworking.DeepCopyInto(&out.CommonHostNetworking) in.CommonHostNetworking.DeepCopyInto(&out.CommonHostNetworking)
out.Kubernetes = in.Kubernetes out.Kubernetes = in.Kubernetes
out.Ironic = in.Ironic out.Ironic = in.Ironic
in.Ntp.DeepCopyInto(&out.Ntp)
} }
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkCatalogueSpec. // 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 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. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Phase) DeepCopyInto(out *Phase) { func (in *Phase) DeepCopyInto(out *Phase) {
*out = *in *out = *in