From a6d84534d8b04af5d71e7be707430a2514a8b295 Mon Sep 17 00:00:00 2001 From: Sandhya Dasu Date: Mon, 9 Dec 2019 16:11:51 -0500 Subject: [PATCH] Add baremetal provisioning configuration in a new CR Add a new CR within operator scope or all the provisioning config items needed by metal3 to provision baremetal servers. Implements : https://github.com/openshift/enhancements/blob/master/enhancements/baremetal/baremetal-provisioning-config.md --- ...0_30_metal3provisioning_00_config.crd.yaml | 185 ++++++++++++++++++ operator/v1/register.go | 2 + operator/v1/types_metal3provisioning.go | 109 +++++++++++ operator/v1/zz_generated.deepcopy.go | 112 +++++++++++ .../v1/zz_generated.swagger_doc_generated.go | 47 +++++ 5 files changed, 455 insertions(+) create mode 100644 operator/v1/0000_30_metal3provisioning_00_config.crd.yaml create mode 100644 operator/v1/types_metal3provisioning.go diff --git a/operator/v1/0000_30_metal3provisioning_00_config.crd.yaml b/operator/v1/0000_30_metal3provisioning_00_config.crd.yaml new file mode 100644 index 00000000000..9e8a9bd7931 --- /dev/null +++ b/operator/v1/0000_30_metal3provisioning_00_config.crd.yaml @@ -0,0 +1,185 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: metal3provisioning.operator.openshift.io +spec: + group: operator.openshift.io + names: + kind: Metal3Provisioning + listKind: Metal3ProvisioningList + singular: metal3provisioning + scope: "" + preserveUnknownFields: false + subresources: + scale: + labelSelectorPath: .status.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.availableReplicas + status: {} + validation: + openAPIV3Schema: + description: "Metal3Provisioning contains configuration used by the Provisioning + service (Ironic) to provision baremetal hosts. \n Metal3Provisioning is created + by the Openshift installer using admin or user provided information about + the provisioning network and the NIC on the server that can be used to PXE + boot it. \n This CR is a singleton, created by the installer and currently + only consumed by the machine-api-operator to bring up and update containers + in a metal3 cluster." + type: object + required: + - spec + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: spec is the specification of the desired behavior of Metal3Provisioning. + type: object + properties: + provisioningInterface: + description: "provisioningInterface is the name of the network interface + on a baremetal server to the provisioning network. It can have values + like eth1 or ens3." + type: string + provisioningIP: + description: "provisioningIP is the IP address assigned to the provisioningInterface + of the baremetal server. This IP address should be within the provisioning + subnet, and outside of the DHCP range." + type: string + provisioningNetworkCIDR: + description: "provisioningNetworkCIDR is the network on which the baremetal + nodes are provisioned. The provisioningIP and the IPs in the dhcpRange + all come from within this network." + type: string + provisioningDHCP: + description: "provisioningDHCP consists of two parameters that represents + whether the DHCP server is internal or external to the metal3 cluster. + If it is internal, the second parameter represents the DHCP address + range to be provided to the baremetal hosts." + type: object + properties: + logLevel: + description: logLevel is an intent based logging for an overall + component. It does not give fine grained control, but it is a + simple way to manage coarse grained logging choices that operators + have to interpret for their operands. + type: string + managementState: + description: managementState indicates whether DHCP server is present + within the metal3 cluster or external to it. A managementState + value of Removed indicates an external DHCP server and a value + of Managed indicates a DHCP server managed within the metal3 cluster. + type: string + pattern: ^(Managed|Removed)$ + observedConfig: + description: observedConfig holds a sparse config that controller + has observed from the cluster state. It exists in spec because + it is an input to the level for the operator + type: object + nullable: true + x-kubernetes-preserve-unknown-fields: true + operatorLogLevel: + description: operatorLogLevel is an intent based logging for the + operator itself. It does not give fine grained control, but it + is a simple way to manage coarse grained logging choices that + operators have to interpret for themselves. + type: string + unsupportedConfigOverrides: + description: 'unsupportedConfigOverrides holds a sparse config that + will override any previously set options. It only needs to be + the fields to override it will end up overlaying in the following + order: 1. hardcoded defaults 2. observedConfig 3. unsupportedConfigOverrides' + type: object + nullable: true + x-kubernetes-preserve-unknown-fields: true + DHCPRange: + description: Needs to be interpreted along with the managementState. + If the ManagementState within the OperatorStatus is set to "Managed", + then the DHCPRange represents the range of IP addresses that the + DHCP server running within the metal3 cluster can use while provisioning + baremetal servers. If the value of ManagementState is set to "Removed", + then the value of DHCPRange will be ignored. If the ManagementState + is "Managed" and the value of DHCPRange is not set, then the DHCP + range is taken to be the default range which goes from .10 to + .100 of the ProvisioningNetworkCIDR. This is the only value in + all of the provisioning configuration that can be changed after + the installer has created the CR. + type: string + nullable: true + status: + description: status holds observed values from the cluster. They may not + be overridden. + type: object + properties: + conditions: + description: conditions is a list of conditions and their status + type: array + items: + description: OperatorCondition is just the standard condition fields. + type: object + properties: + lastTransitionTime: + type: string + format: date-time + message: + type: string + reason: + type: string + status: + type: string + type: + type: string + generations: + description: generations are used to determine when an item needs to + be reconciled or has changed in a way that needs a reaction. + type: array + items: + description: GenerationStatus keeps track of the generation for a + given resource so that decisions about forced updates can be made. + type: object + properties: + group: + description: group is the group of the thing you're tracking + type: string + hash: + description: hash is an optional field set for resources without + generation that are content sensitive like secrets and configmaps + type: string + lastGeneration: + description: lastGeneration is the last generation of the workload + controller involved + type: integer + format: int64 + name: + description: name is the name of the thing you're tracking + type: string + namespace: + description: namespace is where the thing you're tracking is + type: string + resource: + description: resource is the resource type of the thing you're + tracking + type: string + observedGeneration: + description: observedGeneration is the last generation change you've + dealt with + type: integer + format: int64 + readyReplicas: + description: readyReplicas indicates how many replicas are ready and + at the desired state + type: integer + format: int32 + version: + description: version is the level this availability applies to + type: string diff --git a/operator/v1/register.go b/operator/v1/register.go index ab0b1ffa7f4..c842113e408 100644 --- a/operator/v1/register.go +++ b/operator/v1/register.go @@ -62,6 +62,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ServiceCatalogControllerManagerList{}, &IngressController{}, &IngressControllerList{}, + &Metal3Provisioning{}, + &Metal3ProvisioningList{}, ) return nil diff --git a/operator/v1/types_metal3provisioning.go b/operator/v1/types_metal3provisioning.go new file mode 100644 index 00000000000..2f57a25086d --- /dev/null +++ b/operator/v1/types_metal3provisioning.go @@ -0,0 +1,109 @@ +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status + +// Metal3Provisioning contains configuration used by the Provisioning +// service (Ironic) to provision baremetal hosts. +// +// Metal3Provisioning is created by the Openshift installer using admin +// or user provided information about the provisioning network and the NIC +// on the server that can be used to PXE boot it. +// +// This CR is a singleton, created by the installer and currently only +// consumed by the machine-api-operator to bring up and update containers +// in a metal3 cluster. +// +type Metal3Provisioning struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // spec is the specification of the desired behavior of the + // Metal3Provisioning. + Spec Metal3ProvisioningSpec `json:"spec,omitempty"` + + // status is the most recently observed status of the + // Metal3Provisioning. + Status Metal3ProvisioningStatus `json:"status,omitempty"` +} + +// ProvisioningDHCP represents just the configuration required to fully +// identify the way DHCP would be handled during baremetal host bringup. +// +// DHCP services could be provided external to the metal3 cluster, in +// which case, IP address assignment for the baremetal servers should +// happen via this external DHCP server and not via a DHCP server started +// within the metal3 cluster. +// If IP address assignment needs to happen via the DHCP server within the +// metal3 cluster, then the CR needs to contain the DHCP address range that +// this internal DHCP server needs to use. +// +type ProvisioningDHCP struct { + // ManagementState within the OperatorSpec needs to be set to + // indicate if the DHCP server is internal or external to the + // metal3 cluster. ManagementState set to "Removed" indicates + // that the DHCP server is outside the metal3 cluster. And a + // value of "Managed" indicates that the DHCP services are + // managed within the metal3 cluster. + // The other fields of OperatorSpec retain their existing + // semantics. + OperatorSpec `json:",inline"` + + // If the ManagementState within the OperatorStatus is set to + // "Managed", then the DHCPRange represents the range of IP addresses + // that the DHCP server running within the metal3 cluster can use + // while provisioning baremetal servers. If the value of ManagementState + // is set to "Removed", then the value of DHCPRange will be ignored. + // If the ManagementState is "Managed" and the value of DHCPRange is + // not set, then the DHCP range is taken to be the default range which + // goes from .10 to .100 of the ProvisioningNetworkCIDR. This is the only + // value in all of the provisioning configuration that can be changed + // after the installer has created the CR. + DHCPRange string `json:"DHCPRange,omitempty"` +} + +// Metal3ProvisioningSpec is the specification of the desired behavior of the +// Metal3Provisioning. +type Metal3ProvisioningSpec struct { + // provisioningInterface is the name of the network interface on a Baremetal + // server to the provisioning network. It can have values like "eth1" or "ens3". + ProvisioningInterface string `json:"provisioningInterface"` + + // provisioningIP is the IP address assigned to the provisioningInterface of + // the baremetal server. This IP address should be within the provisioning + // subnet, and outside of the DHCP range. + ProvisioningIP string `json:"provisioningIP"` + + // provisioningNetworkCIDR is the network on which the baremetal nodes are + // provisioned. The provisioningIP and the IPs in the dhcpRange all come from + // within this network. + ProvisioningNetworkCIDR string `json:"provisioningNetworkCIDR"` + + // provisioningDHCP consists of two parameters that represents whether the DHCP + // server is internal or external to the metal3 cluster. If it is internal, + // the second parameter represents the DHCP address range to be provided + // to the baremetal hosts. + ProvisioningDHCP ProvisioningDHCP `json:"provisioningDHCP"` +} + +// Metal3ProvisioningStatus defines the observed status of Metal3Provisioning. +type Metal3ProvisioningStatus struct { + OperatorStatus `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true + +// Metal3ProvisioningList contains a list of Metal3Provisioning. +type Metal3ProvisioningList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3Provisioning `json:"items"` +} diff --git a/operator/v1/zz_generated.deepcopy.go b/operator/v1/zz_generated.deepcopy.go index 3aa43915217..c8d77486c56 100644 --- a/operator/v1/zz_generated.deepcopy.go +++ b/operator/v1/zz_generated.deepcopy.go @@ -1209,6 +1209,101 @@ func (in *LoadBalancerStrategy) DeepCopy() *LoadBalancerStrategy { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3Provisioning) DeepCopyInto(out *Metal3Provisioning) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3Provisioning. +func (in *Metal3Provisioning) DeepCopy() *Metal3Provisioning { + if in == nil { + return nil + } + out := new(Metal3Provisioning) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3Provisioning) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3ProvisioningList) DeepCopyInto(out *Metal3ProvisioningList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3Provisioning, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3ProvisioningList. +func (in *Metal3ProvisioningList) DeepCopy() *Metal3ProvisioningList { + if in == nil { + return nil + } + out := new(Metal3ProvisioningList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3ProvisioningList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3ProvisioningSpec) DeepCopyInto(out *Metal3ProvisioningSpec) { + *out = *in + in.ProvisioningDHCP.DeepCopyInto(&out.ProvisioningDHCP) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3ProvisioningSpec. +func (in *Metal3ProvisioningSpec) DeepCopy() *Metal3ProvisioningSpec { + if in == nil { + return nil + } + out := new(Metal3ProvisioningSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3ProvisioningStatus) DeepCopyInto(out *Metal3ProvisioningStatus) { + *out = *in + in.OperatorStatus.DeepCopyInto(&out.OperatorStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3ProvisioningStatus. +func (in *Metal3ProvisioningStatus) DeepCopy() *Metal3ProvisioningStatus { + if in == nil { + return nil + } + out := new(Metal3ProvisioningStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MyOperatorResource) DeepCopyInto(out *MyOperatorResource) { *out = *in @@ -1774,6 +1869,23 @@ func (in *PrivateStrategy) DeepCopy() *PrivateStrategy { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ProvisioningDHCP) DeepCopyInto(out *ProvisioningDHCP) { + *out = *in + in.OperatorSpec.DeepCopyInto(&out.OperatorSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProvisioningDHCP. +func (in *ProvisioningDHCP) DeepCopy() *ProvisioningDHCP { + if in == nil { + return nil + } + out := new(ProvisioningDHCP) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in ProxyArgumentList) DeepCopyInto(out *ProxyArgumentList) { { diff --git a/operator/v1/zz_generated.swagger_doc_generated.go b/operator/v1/zz_generated.swagger_doc_generated.go index ff803952d01..844059111cf 100644 --- a/operator/v1/zz_generated.swagger_doc_generated.go +++ b/operator/v1/zz_generated.swagger_doc_generated.go @@ -399,6 +399,53 @@ func (KubeStorageVersionMigratorList) SwaggerDoc() map[string]string { return map_KubeStorageVersionMigratorList } +var map_Metal3Provisioning = map[string]string{ + "": "Metal3Provisioning contains configuration used by the Provisioning service (Ironic) to provision baremetal hosts.\n\nMetal3Provisioning is created by the Openshift installer using admin or user provided information about the provisioning network and the NIC on the server that can be used to PXE boot it.\n\nThis CR is a singleton, created by the installer and currently only consumed by the machine-api-operator to bring up and update containers in a metal3 cluster.", + "spec": "spec is the specification of the desired behavior of the Metal3Provisioning.", + "status": "status is the most recently observed status of the Metal3Provisioning.", +} + +func (Metal3Provisioning) SwaggerDoc() map[string]string { + return map_Metal3Provisioning +} + +var map_Metal3ProvisioningList = map[string]string{ + "": "Metal3ProvisioningList contains a list of Metal3Provisioning.", +} + +func (Metal3ProvisioningList) SwaggerDoc() map[string]string { + return map_Metal3ProvisioningList +} + +var map_Metal3ProvisioningSpec = map[string]string{ + "": "Metal3ProvisioningSpec is the specification of the desired behavior of the Metal3Provisioning.", + "provisioningInterface": "provisioningInterface is the name of the network interface on a Baremetal server to the provisioning network. It can have values like \"eth1\" or \"ens3\".", + "provisioningIP": "provisioningIP is the IP address assigned to the provisioningInterface of the baremetal server. This IP address should be within the provisioning subnet, and outside of the DHCP range.", + "provisioningNetworkCIDR": "provisioningNetworkCIDR is the network on which the baremetal nodes are provisioned. The provisioningIP and the IPs in the dhcpRange all come from within this network.", + "provisioningDHCP": "provisioningDHCP consists of two parameters that represents whether the DHCP server is internal or external to the metal3 cluster. If it is internal, the second parameter represents the DHCP address range to be provided to the baremetal hosts.", +} + +func (Metal3ProvisioningSpec) SwaggerDoc() map[string]string { + return map_Metal3ProvisioningSpec +} + +var map_Metal3ProvisioningStatus = map[string]string{ + "": "Metal3ProvisioningStatus defines the observed status of Metal3Provisioning.", +} + +func (Metal3ProvisioningStatus) SwaggerDoc() map[string]string { + return map_Metal3ProvisioningStatus +} + +var map_ProvisioningDHCP = map[string]string{ + "": "ProvisioningDHCP represents just the configuration required to fully identify the way DHCP would be handled during baremetal host bringup.\n\nDHCP services could be provided external to the metal3 cluster, in which case, IP address assignment for the baremetal servers should happen via this external DHCP server and not via a DHCP server started within the metal3 cluster. If IP address assignment needs to happen via the DHCP server within the metal3 cluster, then the CR needs to contain the DHCP address range that this internal DHCP server needs to use.", + "DHCPRange": "If the ManagementState within the OperatorStatus is set to \"Managed\", then the DHCPRange represents the range of IP addresses that the DHCP server running within the metal3 cluster can use while provisioning baremetal servers. If the value of ManagementState is set to \"Removed\", then the value of DHCPRange will be ignored. If the ManagementState is \"Managed\" and the value of DHCPRange is not set, then the DHCP range is taken to be the default range which goes from .10 to .100 of the ProvisioningNetworkCIDR. This is the only value in all of the provisioning configuration that can be changed after the installer has created the CR.", +} + +func (ProvisioningDHCP) SwaggerDoc() map[string]string { + return map_ProvisioningDHCP +} + var map_AdditionalNetworkDefinition = map[string]string{ "": "AdditionalNetworkDefinition configures an extra network that is available but not created by default. Instead, pods must request them by name. type must be specified, along with exactly one \"Config\" that matches the type.", "type": "type is the type of network The supported values are NetworkTypeRaw, NetworkTypeSimpleMacvlan",