From 9388f67a213158de57c730a5b383b6109822b449 Mon Sep 17 00:00:00 2001 From: Mohamed Chiheb Ben Jemaa Date: Wed, 20 Mar 2024 17:34:48 +0100 Subject: [PATCH] Remove ipam dependency --- api/v1alpha1/proxmoxcluster_types.go | 26 ++++++++++++++----- api/v1alpha1/zz_generated.deepcopy.go | 25 +++++++++++++++--- ...ture.cluster.x-k8s.io_proxmoxclusters.yaml | 26 ------------------- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/api/v1alpha1/proxmoxcluster_types.go b/api/v1alpha1/proxmoxcluster_types.go index eb8ad0d6..e9479950 100644 --- a/api/v1alpha1/proxmoxcluster_types.go +++ b/api/v1alpha1/proxmoxcluster_types.go @@ -19,10 +19,9 @@ package v1alpha1 import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "k8s.io/utils/ptr" - ipamicv1 "sigs.k8s.io/cluster-api-ipam-provider-in-cluster/api/v1alpha2" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/client" ) const ( @@ -55,20 +54,35 @@ type ProxmoxClusterSpec struct { // either IPv4Config or IPv6Config must be provided. // +optional // +kubebuilder:validation:XValidation:rule="self.addresses.size() > 0",message="IPv4Config addresses must be provided" - IPv4Config *ipamicv1.InClusterIPPoolSpec `json:"ipv4Config,omitempty"` + IPv4Config *IPPoolSpec `json:"ipv4Config,omitempty"` // IPv6Config contains information about available IPV6 address pools and the gateway. // this can be combined with ipv4Config in order to enable dual stack. // either IPv4Config or IPv6Config must be provided. // +optional // +kubebuilder:validation:XValidation:rule="self.addresses.size() > 0",message="IPv6Config addresses must be provided" - IPv6Config *ipamicv1.InClusterIPPoolSpec `json:"ipv6Config,omitempty"` + IPv6Config *IPPoolSpec `json:"ipv6Config,omitempty"` // DNSServers contains information about nameservers used by machines network-config. // +kubebuilder:validation:MinItems=1 DNSServers []string `json:"dnsServers"` } +// IPPoolSpec defines the desired state of IP Pool. +type IPPoolSpec struct { + // Addresses is a list of IP addresses that can be assigned. This set of + // addresses can be non-contiguous. + Addresses []string `json:"addresses"` + + // Prefix is the network prefix to use. + // +kubebuilder:validation:Maximum=128 + Prefix int `json:"prefix"` + + // Gateway + // +optional + Gateway string `json:"gateway,omitempty"` +} + // SchedulerHints allows to pass the scheduler instructions to (dis)allow over- or enforce underprovisioning of resources. type SchedulerHints struct { // MemoryAdjustment allows to adjust a node's memory by a given percentage. @@ -172,7 +186,7 @@ func (c *ProxmoxCluster) SetConditions(conditions clusterv1.Conditions) { // SetInClusterIPPoolRef will set the reference to the provided InClusterIPPool. // If nil was provided, the status field will be cleared. -func (c *ProxmoxCluster) SetInClusterIPPoolRef(pool *ipamicv1.InClusterIPPool) { +func (c *ProxmoxCluster) SetInClusterIPPoolRef(pool client.Object) { if pool == nil || pool.GetName() == "" { c.Status.InClusterIPPoolRef = nil return diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index d4d38cba..096bea1f 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -8,7 +8,6 @@ package v1alpha1 import ( "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/cluster-api-ipam-provider-in-cluster/api/v1alpha2" "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/errors" ) @@ -74,6 +73,26 @@ func (in *IPAddress) DeepCopy() *IPAddress { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPPoolSpec) DeepCopyInto(out *IPPoolSpec) { + *out = *in + if in.Addresses != nil { + in, out := &in.Addresses, &out.Addresses + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolSpec. +func (in *IPPoolSpec) DeepCopy() *IPPoolSpec { + if in == nil { + return nil + } + out := new(IPPoolSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InterfaceConfig) DeepCopyInto(out *InterfaceConfig) { *out = *in @@ -293,12 +312,12 @@ func (in *ProxmoxClusterSpec) DeepCopyInto(out *ProxmoxClusterSpec) { } if in.IPv4Config != nil { in, out := &in.IPv4Config, &out.IPv4Config - *out = new(v1alpha2.InClusterIPPoolSpec) + *out = new(IPPoolSpec) (*in).DeepCopyInto(*out) } if in.IPv6Config != nil { in, out := &in.IPv6Config, &out.IPv6Config - *out = new(v1alpha2.InClusterIPPoolSpec) + *out = new(IPPoolSpec) (*in).DeepCopyInto(*out) } if in.DNSServers != nil { diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml index dd32fda3..45d09b39 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml @@ -91,19 +91,6 @@ spec: items: type: string type: array - allocateReservedIPAddresses: - description: AllocateReservedIPAddresses causes the provider to - allocate the network address (the first address in the inferred - subnet) and broadcast address (the last address in the inferred - subnet) when IPv4. The provider will allocate the anycast address - address (the first address in the inferred subnet) when IPv6. - type: boolean - excludedAddresses: - description: ExcludedAddresses is a list of IP addresses, which - will be excluded from the set of assignable IP addresses. - items: - type: string - type: array gateway: description: Gateway type: string @@ -130,19 +117,6 @@ spec: items: type: string type: array - allocateReservedIPAddresses: - description: AllocateReservedIPAddresses causes the provider to - allocate the network address (the first address in the inferred - subnet) and broadcast address (the last address in the inferred - subnet) when IPv4. The provider will allocate the anycast address - address (the first address in the inferred subnet) when IPv6. - type: boolean - excludedAddresses: - description: ExcludedAddresses is a list of IP addresses, which - will be excluded from the set of assignable IP addresses. - items: - type: string - type: array gateway: description: Gateway type: string