Skip to content

Commit

Permalink
Fix rest issues
Browse files Browse the repository at this point in the history
  • Loading branch information
damyan committed Dec 3, 2024
1 parent 65413d9 commit d6c0a2e
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 28 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/ironcore/types_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion pkg/apis/ironcore/v1alpha1/types_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
15 changes: 13 additions & 2 deletions pkg/apis/ironcore/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion pkg/apis/ironcore/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/controller/bastion/actuator_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
Expand Down
6 changes: 4 additions & 2 deletions pkg/controller/bastion/configvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions pkg/controller/controlplane/valuesprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/worker/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/ironcore/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 1 addition & 13 deletions pkg/webhook/controlplane/ensurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit d6c0a2e

Please sign in to comment.