diff --git a/Makefile b/Makefile index d0b09668..a49aa75b 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ ADMISSION_NAME := admission-ironcore IMAGE_PREFIX := $(REGISTRY)/extensions REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) HACK_DIR := $(REPO_ROOT)/hack +VERSION := $(shell cat "$(REPO_ROOT)/VERSION") EFFECTIVE_VERSION := $(VERSION)-$(shell git rev-parse HEAD) LD_FLAGS := "-w $(shell bash $(GARDENER_HACK_DIR)/get-build-ld-flags.sh k8s.io/component-base $(REPO_ROOT)/VERSION $(EXTENSION_PREFIX))" LEADER_ELECTION := false diff --git a/pkg/apis/ironcore/types_infrastructure.go b/pkg/apis/ironcore/types_infrastructure.go index eec8842d..481576d9 100644 --- a/pkg/apis/ironcore/types_infrastructure.go +++ b/pkg/apis/ironcore/types_infrastructure.go @@ -33,6 +33,6 @@ type InfrastructureStatus struct { NetworkRef commonv1alpha1.LocalUIDReference // NATGatewayRef is the reference to the NAT gateway used NATGatewayRef commonv1alpha1.LocalUIDReference - // PrefixRef is the reference to the Prefix used - PrefixRef commonv1alpha1.LocalUIDReference + // PrefixRefs are the references to the Prefixes used + PrefixRefs []commonv1alpha1.LocalUIDReference } diff --git a/pkg/apis/ironcore/v1alpha1/types_infrastructure.go b/pkg/apis/ironcore/v1alpha1/types_infrastructure.go index 2c59c1ae..e6abbca6 100644 --- a/pkg/apis/ironcore/v1alpha1/types_infrastructure.go +++ b/pkg/apis/ironcore/v1alpha1/types_infrastructure.go @@ -33,6 +33,6 @@ type InfrastructureStatus struct { NetworkRef commonv1alpha1.LocalUIDReference `json:"networkRef,omitempty"` // NATGatewayRef is the reference to the NAT gateway used NATGatewayRef commonv1alpha1.LocalUIDReference `json:"natGatewayRef,omitempty"` - // PrefixRef is the reference to the Prefix used + // PrefixRefs are the references to the Prefixes used PrefixRefs []commonv1alpha1.LocalUIDReference `json:"prefixRefs,omitempty"` } diff --git a/pkg/apis/ironcore/v1alpha1/zz_generated.conversion.go b/pkg/apis/ironcore/v1alpha1/zz_generated.conversion.go index 503ba17c..88f3504d 100644 --- a/pkg/apis/ironcore/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/ironcore/v1alpha1/zz_generated.conversion.go @@ -13,6 +13,7 @@ import ( unsafe "unsafe" ironcore "github.com/ironcore-dev/gardener-extension-provider-ironcore/pkg/apis/ironcore" + commonv1alpha1 "github.com/ironcore-dev/ironcore/api/common/v1alpha1" v1 "k8s.io/api/core/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" @@ -241,17 +242,27 @@ func Convert_ironcore_InfrastructureConfig_To_v1alpha1_InfrastructureConfig(in * func autoConvert_v1alpha1_InfrastructureStatus_To_ironcore_InfrastructureStatus(in *InfrastructureStatus, out *ironcore.InfrastructureStatus, s conversion.Scope) error { out.NetworkRef = in.NetworkRef out.NATGatewayRef = in.NATGatewayRef - // WARNING: in.PrefixRefs requires manual conversion: does not exist in peer-type + out.PrefixRefs = *(*[]commonv1alpha1.LocalUIDReference)(unsafe.Pointer(&in.PrefixRefs)) return nil } +// Convert_v1alpha1_InfrastructureStatus_To_ironcore_InfrastructureStatus is an autogenerated conversion function. +func Convert_v1alpha1_InfrastructureStatus_To_ironcore_InfrastructureStatus(in *InfrastructureStatus, out *ironcore.InfrastructureStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_InfrastructureStatus_To_ironcore_InfrastructureStatus(in, out, s) +} + func autoConvert_ironcore_InfrastructureStatus_To_v1alpha1_InfrastructureStatus(in *ironcore.InfrastructureStatus, out *InfrastructureStatus, s conversion.Scope) error { out.NetworkRef = in.NetworkRef out.NATGatewayRef = in.NATGatewayRef - // WARNING: in.PrefixRef requires manual conversion: does not exist in peer-type + out.PrefixRefs = *(*[]commonv1alpha1.LocalUIDReference)(unsafe.Pointer(&in.PrefixRefs)) return nil } +// Convert_ironcore_InfrastructureStatus_To_v1alpha1_InfrastructureStatus is an autogenerated conversion function. +func Convert_ironcore_InfrastructureStatus_To_v1alpha1_InfrastructureStatus(in *ironcore.InfrastructureStatus, out *InfrastructureStatus, s conversion.Scope) error { + return autoConvert_ironcore_InfrastructureStatus_To_v1alpha1_InfrastructureStatus(in, out, s) +} + func autoConvert_v1alpha1_MachineImage_To_ironcore_MachineImage(in *MachineImage, out *ironcore.MachineImage, s conversion.Scope) error { out.Name = in.Name out.Version = in.Version diff --git a/pkg/apis/ironcore/zz_generated.deepcopy.go b/pkg/apis/ironcore/zz_generated.deepcopy.go index 71996cf0..23837374 100644 --- a/pkg/apis/ironcore/zz_generated.deepcopy.go +++ b/pkg/apis/ironcore/zz_generated.deepcopy.go @@ -10,6 +10,7 @@ package ironcore import ( + v1alpha1 "github.com/ironcore-dev/ironcore/api/common/v1alpha1" v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -148,7 +149,11 @@ func (in *InfrastructureStatus) DeepCopyInto(out *InfrastructureStatus) { out.TypeMeta = in.TypeMeta out.NetworkRef = in.NetworkRef out.NATGatewayRef = in.NATGatewayRef - out.PrefixRef = in.PrefixRef + if in.PrefixRefs != nil { + in, out := &in.PrefixRefs, &out.PrefixRefs + *out = make([]v1alpha1.LocalUIDReference, len(*in)) + copy(*out, *in) + } return } diff --git a/pkg/controller/bastion/actuator_reconcile.go b/pkg/controller/bastion/actuator_reconcile.go index be8af600..1ef510cd 100644 --- a/pkg/controller/bastion/actuator_reconcile.go +++ b/pkg/controller/bastion/actuator_reconcile.go @@ -252,8 +252,9 @@ func generateMachine(namespace string, bastionConfig *controllerconfig.BastionCo Spec: ipamv1alpha1.PrefixSpec{ // request single IP PrefixLength: 32, + // TODO do we need to generate IPv6 bastion hosts? ParentRef: &corev1.LocalObjectReference{ - Name: infraStatus.PrefixRef.Name, + Name: infraStatus.PrefixRefs[0].Name, }, }, }, diff --git a/pkg/controller/bastion/configvalidator.go b/pkg/controller/bastion/configvalidator.go index 8ac68983..ffda5fd9 100644 --- a/pkg/controller/bastion/configvalidator.go +++ b/pkg/controller/bastion/configvalidator.go @@ -122,8 +122,10 @@ func validateInfrastructureStatus(infrastructureStatus *api.InfrastructureStatus return fmt.Errorf("network ref must be not empty for infrastructure provider status") } - if infrastructureStatus.PrefixRef == emptyref { - return fmt.Errorf("prefix ref must be not empty for infrastructure provider status") + for _, prefixRef := range infrastructureStatus.PrefixRefs { + if prefixRef == emptyref { + return fmt.Errorf("prefix ref must be not empty for infrastructure provider status") + } } return nil diff --git a/pkg/controller/controlplane/valuesprovider.go b/pkg/controller/controlplane/valuesprovider.go index b0de65c1..9abe0630 100644 --- a/pkg/controller/controlplane/valuesprovider.go +++ b/pkg/controller/controlplane/valuesprovider.go @@ -217,10 +217,14 @@ func (vp *valuesProvider) GetConfigChartValues( return nil, fmt.Errorf("failed to decode infrastructure status: %w", err) } // Collect config chart values + var prefixNames []string + for _, prefix := range infrastructureStatus.PrefixRefs { + prefixNames = append(prefixNames, prefix.Name) + } return map[string]interface{}{ - ironcore.NetworkFieldName: infrastructureStatus.NetworkRef.Name, - ironcore.PrefixFieldName: infrastructureStatus.PrefixRef.Name, - ironcore.ClusterFieldName: cluster.ObjectMeta.Name, + ironcore.NetworkFieldName: infrastructureStatus.NetworkRef.Name, + ironcore.PrefixesFieldName: prefixNames, + ironcore.ClusterFieldName: cluster.ObjectMeta.Name, }, nil } diff --git a/pkg/controller/worker/machines.go b/pkg/controller/worker/machines.go index 75504692..71c6748d 100644 --- a/pkg/controller/worker/machines.go +++ b/pkg/controller/worker/machines.go @@ -144,7 +144,7 @@ func (w *workerDelegate) generateMachineClassAndSecrets(ctx context.Context) ([] prefixNames = append(prefixNames, prefix.Name) } machineClassProviderSpec[ironcore.NetworkFieldName] = infrastructureStatus.NetworkRef.Name - machineClassProviderSpec[ironcore.PrefixFieldName] = prefixNames + machineClassProviderSpec[ironcore.PrefixesFieldName] = prefixNames machineClassProviderSpec[ironcore.LabelsFieldName] = map[string]string{ ironcore.ClusterNameLabel: w.cluster.ObjectMeta.Name, } diff --git a/pkg/ironcore/types.go b/pkg/ironcore/types.go index 72ca48b7..856c67ee 100644 --- a/pkg/ironcore/types.go +++ b/pkg/ironcore/types.go @@ -50,8 +50,8 @@ const ( TokenFieldName = "token" // NetworkFieldName is the name of network field NetworkFieldName = "networkName" - // PrefixFieldName is the name of the prefix field - PrefixFieldName = "prefixNames" + // PrefixesFieldName is the name of the prefix field + PrefixesFieldName = "prefixNames" // ClusterFieldName is the name of the cluster field ClusterFieldName = "clusterName" // LabelsFieldName is the name of the labels field diff --git a/pkg/webhook/controlplane/ensurer.go b/pkg/webhook/controlplane/ensurer.go index 9fffa501..0840da4a 100644 --- a/pkg/webhook/controlplane/ensurer.go +++ b/pkg/webhook/controlplane/ensurer.go @@ -16,7 +16,6 @@ import ( "github.com/go-logr/logr" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" vpaautoscalingv1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1" @@ -77,24 +76,13 @@ func (e *ensurer) EnsureMachineControllerManagerDeployment(_ context.Context, _ // EnsureMachineControllerManagerVPA ensures that the machine-controller-manager VPA conforms to the provider requirements. func (e *ensurer) EnsureMachineControllerManagerVPA(_ context.Context, _ extensionscontextwebhook.GardenContext, newObj, _ *vpaautoscalingv1.VerticalPodAutoscaler) error { - var ( - minAllowed = corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("30m"), - corev1.ResourceMemory: resource.MustParse("64Mi"), - } - maxAllowed = corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("2"), - corev1.ResourceMemory: resource.MustParse("5G"), - } - ) - if newObj.Spec.ResourcePolicy == nil { newObj.Spec.ResourcePolicy = &vpaautoscalingv1.PodResourcePolicy{} } newObj.Spec.ResourcePolicy.ContainerPolicies = extensionswebhook.EnsureVPAContainerResourcePolicyWithName( newObj.Spec.ResourcePolicy.ContainerPolicies, - machinecontrollermanager.ProviderSidecarVPAContainerPolicy(ironcore.ProviderName, minAllowed, maxAllowed), + machinecontrollermanager.ProviderSidecarVPAContainerPolicy(ironcore.ProviderName), ) return nil }