helper

package
v1.137.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ProjectGVK is the GroupVersionKind for Gardener Project resources.
	ProjectGVK = schema.GroupVersionKind{Group: "core.gardener.cloud", Version: "v1beta1", Kind: "Project"}
	// SecretGVK is the GroupVersionKind for Kubernetes Secret resources.
	SecretGVK = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Secret"}
	// WorkloadIdentityGVK is the GroupVersionKind for Gardener WorkloadIdentity resources.
	WorkloadIdentityGVK = schema.GroupVersionKind{Group: "security.gardener.cloud", Version: "v1alpha1", Kind: "WorkloadIdentity"}
)

Functions

func AccessRestrictionsAreSupported

func AccessRestrictionsAreSupported(seedAccessRestrictions []core.AccessRestriction, shootAccessRestrictions []core.AccessRestrictionWithOptions) bool

AccessRestrictionsAreSupported returns true when all the given access restrictions are supported.

func AreCapabilitiesEqual

func AreCapabilitiesEqual(a, b core.Capabilities) bool

AreCapabilitiesEqual checks if two capabilities are semantically equal.

func CalculateEffectiveKubeletConfiguration

func CalculateEffectiveKubeletConfiguration(shootKubelet *core.KubeletConfig, workerKubernetes *core.WorkerKubernetes) *core.KubeletConfig

CalculateEffectiveKubeletConfiguration returns the worker group specific kubelet configuration if available. Otherwise the shoot kubelet configuration is returned

func CalculateEffectiveKubernetesVersion

func CalculateEffectiveKubernetesVersion(controlPlaneVersion *semver.Version, workerKubernetes *core.WorkerKubernetes) (*semver.Version, error)

CalculateEffectiveKubernetesVersion if a shoot has kubernetes version specified by worker group, return this, otherwise the shoot kubernetes version

func CalculateSeedUsage

func CalculateSeedUsage(shootList []*core.Shoot) map[string]int

CalculateSeedUsage returns a map representing the number of shoots per seed from the given list of shoots. It takes both spec.seedName and status.seedName into account.

func CapabilityDefinitionsToCapabilities

func CapabilityDefinitionsToCapabilities(capabilityDefinitions []core.CapabilityDefinition) core.Capabilities

CapabilityDefinitionsToCapabilities takes the capability definitions and converts them to capabilities.

func ControlPlaneWorkerPoolForShoot

func ControlPlaneWorkerPoolForShoot(workers []core.Worker) *core.Worker

ControlPlaneWorkerPoolForShoot returns the worker pool running the control plane in case the shoot is self-hosted.

func ConvertSeed

func ConvertSeed(obj runtime.Object) (*core.Seed, error)

ConvertSeed converts the given external Seed version to an internal version.

func ConvertSeedExternal

func ConvertSeedExternal(obj runtime.Object) (*gardencorev1beta1.Seed, error)

ConvertSeedExternal converts the given internal Seed version to an external version.

func ConvertSeedTemplate

func ConvertSeedTemplate(obj *gardencorev1beta1.SeedTemplate) (*core.SeedTemplate, error)

ConvertSeedTemplate converts the given external SeedTemplate version to an internal version.

func ConvertSeedTemplateExternal

func ConvertSeedTemplateExternal(obj *core.SeedTemplate) (*gardencorev1beta1.SeedTemplate, error)

ConvertSeedTemplateExternal converts the given internal SeedTemplate version to an external version.

func CurrentLifecycleClassification

func CurrentLifecycleClassification(version core.ExpirableVersion) core.VersionClassification

CurrentLifecycleClassification returns the current lifecycle classification of the given version. An empty classification is interpreted as supported. If the version is expired, it returns ClassificationExpired.

func DetermineLatestExpirableVersion

func DetermineLatestExpirableVersion(versions []core.ExpirableVersion, filterPreviewVersions bool) (core.ExpirableVersion, core.ExpirableVersion, error)

DetermineLatestExpirableVersion determines the latest expirable version and the latest non-deprecated version from a slice of ExpirableVersions. When filterPreviewVersions is set, versions with classification preview are not considered.

func DetermineLatestMachineImageVersion

func DetermineLatestMachineImageVersion(versions []core.MachineImageVersion, filterPreviewVersions bool) (core.MachineImageVersion, error)

DetermineLatestMachineImageVersion determines the latest MachineImageVersion from a slice of MachineImageVersion. When filterPreviewVersions is set, versions with classification preview are not considered. It will prefer older but non-deprecated versions over newer but deprecated versions.

func DetermineLatestMachineImageVersions

func DetermineLatestMachineImageVersions(images []core.MachineImage) (map[string]core.MachineImageVersion, error)

DetermineLatestMachineImageVersions determines the latest versions (semVer) of the given machine images from a slice of machine images

func DeterminePrimaryIPFamily

func DeterminePrimaryIPFamily(ipFamilies []core.IPFamily) core.IPFamily

DeterminePrimaryIPFamily determines the primary IP family out of a specified list of IP families.

func ExtractArchitecturesFromImageFlavors

func ExtractArchitecturesFromImageFlavors(imageFlavors []core.MachineImageFlavor) []string

ExtractArchitecturesFromImageFlavors extracts all architectures from a list of MachineImageFlavor.

func FilterVersionsWithClassification

func FilterVersionsWithClassification(versions []core.ExpirableVersion, classification core.VersionClassification) []core.ExpirableVersion

FilterVersionsWithClassification filters versions for a classification

func FindMachineImageVersion

func FindMachineImageVersion(machineImages []core.MachineImage, name, version string) (core.MachineImageVersion, bool)

FindMachineImageVersion finds the machine image version in the <cloudProfile> for the given <name> and <version>. In case no machine image version can be found with the given <name> or <version>, false is being returned.

func FindPrimaryDNSProvider

func FindPrimaryDNSProvider(providers []core.DNSProvider) *core.DNSProvider

FindPrimaryDNSProvider finds the primary provider among the given `providers`. It returns the first provider if multiple candidates are found.

func FindVersionsWithSameMajorMinor

func FindVersionsWithSameMajorMinor(versions []core.ExpirableVersion, version semver.Version) ([]core.ExpirableVersion, error)

FindVersionsWithSameMajorMinor filters the given versions slice for versions other the given one, having the same major and minor version as the given version

func FindWorkerByName

func FindWorkerByName(workers []core.Worker, name string) *core.Worker

FindWorkerByName tries to find the worker with the given name. If it cannot be found it returns nil.

func GetAddedVersions

func GetAddedVersions(old, new []core.ExpirableVersion) map[string]int

GetAddedVersions finds versions that have been added in the new compared to the new version slice. returns a map associating the version with its index in the old version slice.

func GetAllZonesFromShoot

func GetAllZonesFromShoot(shoot *core.Shoot) sets.Set[string]

GetAllZonesFromShoot returns the set of all availability zones defined in the worker pools of the Shoot specification.

func GetCondition

func GetCondition(conditions []core.Condition, conditionType core.ConditionType) *core.Condition

GetCondition returns the condition with the given <conditionType> out of the list of <conditions>. In case the required type could not be found, it returns nil.

func GetConditionIndex

func GetConditionIndex(conditions []core.Condition, conditionType core.ConditionType) int

GetConditionIndex returns the index of the condition with the given <conditionType> out of the list of <conditions>. In case the required type could not be found, it returns -1.

func GetEncryptionProviderType

func GetEncryptionProviderType(apiServerConfig *core.KubeAPIServerConfig) core.EncryptionProviderType

GetEncryptionProviderType returns the encryption provider type.

func GetEncryptionProviderTypeInStatus

func GetEncryptionProviderTypeInStatus(status core.ShootStatus) core.EncryptionProviderType

GetEncryptionProviderTypeInStatus returns the encryption provider from the shoot status.

func GetImageFlavorsWithAppliedDefaults

func GetImageFlavorsWithAppliedDefaults(imageFlavors []core.MachineImageFlavor, capabilityDefinitions []core.CapabilityDefinition) []core.MachineImageFlavor

GetImageFlavorsWithAppliedDefaults returns MachineImageFlavors sets with applied defaults from the capability definitions.

func GetRemovedVersions

func GetRemovedVersions(old, new []core.ExpirableVersion) map[string]int

GetRemovedVersions finds versions that have been removed in the old compared to the new version slice. returns a map associating the version with its index in the old version slice.

func GetResourceByName

func GetResourceByName(resources []core.NamedResourceReference, name string) *core.NamedResourceReference

GetResourceByName returns the NamedResourceReference with the given name in the given slice, or nil if not found.

func GetSecretBindingTypes

func GetSecretBindingTypes(secretBinding *core.SecretBinding) []string

GetSecretBindingTypes returns the SecretBinding provider types.

func GetShootAuditPolicyConfigMapName

func GetShootAuditPolicyConfigMapName(apiServerConfig *core.KubeAPIServerConfig) string

GetShootAuditPolicyConfigMapName returns the Shoot's ConfigMap reference name for the audit policy.

func GetShootAuditPolicyConfigMapRef

func GetShootAuditPolicyConfigMapRef(apiServerConfig *core.KubeAPIServerConfig) *corev1.ObjectReference

GetShootAuditPolicyConfigMapRef returns the Shoot's ConfigMap reference for the audit policy.

func GetShootAuthenticationConfigurationConfigMapName

func GetShootAuthenticationConfigurationConfigMapName(apiServerConfig *core.KubeAPIServerConfig) string

GetShootAuthenticationConfigurationConfigMapName returns the Shoot's ConfigMap reference name for the authentication configuration.

func GetShootAuthorizationConfigurationConfigMapName

func GetShootAuthorizationConfigurationConfigMapName(apiServerConfig *core.KubeAPIServerConfig) string

GetShootAuthorizationConfigurationConfigMapName returns the Shoot's ConfigMap reference name for the authorization configuration.

func GetShootCARotationPhase

func GetShootCARotationPhase(credentials *core.ShootCredentials) core.CredentialsRotationPhase

GetShootCARotationPhase returns the specified shoot CA rotation phase or an empty string

func GetShootETCDEncryptionKeyRotationPhase

func GetShootETCDEncryptionKeyRotationPhase(credentials *core.ShootCredentials) core.CredentialsRotationPhase

GetShootETCDEncryptionKeyRotationPhase returns the specified shoot ETCD encryption key rotation phase or an empty string.

func GetShootServiceAccountConfigAcceptedIssuers

func GetShootServiceAccountConfigAcceptedIssuers(apiServerConfig *core.KubeAPIServerConfig) []string

GetShootServiceAccountConfigAcceptedIssuers returns the Shoot's ServiceAccountConfig AcceptedIssuers.

func GetShootServiceAccountConfigIssuer

func GetShootServiceAccountConfigIssuer(apiServerConfig *core.KubeAPIServerConfig) *string

GetShootServiceAccountConfigIssuer returns the Shoot's ServiceAccountConfig Issuer.

func GetShootServiceAccountKeyRotationPhase

func GetShootServiceAccountKeyRotationPhase(credentials *core.ShootCredentials) core.CredentialsRotationPhase

GetShootServiceAccountKeyRotationPhase returns the specified shoot service account key rotation phase or an empty string.

func HasCapability

func HasCapability(capabilities []core.CapabilityDefinition, capabilityName string) bool

HasCapability returns true of the passed capabilities contain the capability with the given name.

func HasManagedIssuer

func HasManagedIssuer(shoot *core.Shoot) bool

HasManagedIssuer checks if the shoot has managed issuer enabled.

func HibernationIsEnabled

func HibernationIsEnabled(shoot *core.Shoot) bool

HibernationIsEnabled checks if the given shoot's desired state is hibernated.

func IsHAControlPlaneConfigured

func IsHAControlPlaneConfigured(shoot *core.Shoot) bool

IsHAControlPlaneConfigured returns true if HA configuration for the shoot control plane has been set.

func IsHAVPNEnabled

func IsHAVPNEnabled(shoot *core.Shoot) bool

IsHAVPNEnabled checks if the shoot has HA VPN enabled.

func IsKubeProxyIPVSMode

func IsKubeProxyIPVSMode(kubeProxyConfig *core.KubeProxyConfig) bool

IsKubeProxyIPVSMode checks if the shoot is running with kube-proxy in IPVS mode.

func IsLegacyAnonymousAuthenticationSet

func IsLegacyAnonymousAuthenticationSet(kubeAPIServerConfig *core.KubeAPIServerConfig) bool

IsLegacyAnonymousAuthenticationSet checks if the legacy anonymous authentication is set in the given kubeAPIServerConfig.

func IsMultiZonalShootControlPlane

func IsMultiZonalShootControlPlane(shoot *core.Shoot) bool

IsMultiZonalShootControlPlane checks if the shoot should have a multi-zonal control plane.

func IsShootInHibernation

func IsShootInHibernation(shoot *core.Shoot) bool

IsShootInHibernation checks if the given shoot is in hibernation or is waking up.

func IsShootSelfHosted

func IsShootSelfHosted(workers []core.Worker) bool

IsShootSelfHosted returns true if the shoot has a worker pool dedicated for running the control plane components.

func IsUpdateStrategyInPlace

func IsUpdateStrategyInPlace(updateStrategy *core.MachineUpdateStrategy) bool

IsUpdateStrategyInPlace returns true if the given machine update strategy is either AutoInPlaceUpdate or ManualInPlaceUpdate.

func IsWorkerless

func IsWorkerless(shoot *core.Shoot) bool

IsWorkerless checks if the shoot has zero workers.

func KubernetesDashboardEnabled

func KubernetesDashboardEnabled(addons *core.Addons) bool

KubernetesDashboardEnabled returns true if the kubernetes-dashboard addon is enabled in the Shoot manifest.

func NginxIngressEnabled

func NginxIngressEnabled(addons *core.Addons) bool

NginxIngressEnabled returns true if the nginx-ingress addon is enabled in the Shoot manifest.

func QuotaScope

func QuotaScope(scopeRef corev1.ObjectReference) (string, error)

QuotaScope returns the scope of a quota scope reference.

func SeedSettingSchedulingVisible

func SeedSettingSchedulingVisible(settings *core.SeedSettings) bool

SeedSettingSchedulingVisible returns true if the 'scheduling' setting is set to 'visible'.

func SeedSettingTopologyAwareRoutingEnabled

func SeedSettingTopologyAwareRoutingEnabled(settings *core.SeedSettings) bool

SeedSettingTopologyAwareRoutingEnabled returns true if the topology-aware routing is enabled.

func ShootEnablesSSHAccess

func ShootEnablesSSHAccess(shoot *core.Shoot) bool

ShootEnablesSSHAccess returns true if ssh access to worker nodes should be allowed for the given shoot.

func ShootNeedsForceDeletion

func ShootNeedsForceDeletion(shoot *core.Shoot) bool

ShootNeedsForceDeletion determines whether a Shoot should be force deleted or not.

func ShootUsesUnmanagedDNS

func ShootUsesUnmanagedDNS(shoot *core.Shoot) bool

ShootUsesUnmanagedDNS returns true if the shoot's DNS section is marked as 'unmanaged'.

func ShootWantsVerticalPodAutoscaler

func ShootWantsVerticalPodAutoscaler(shoot *core.Shoot) bool

ShootWantsVerticalPodAutoscaler checks if the given Shoot needs a VPA.

func ShouldETCDEncryptionKeyRotationBeAutoCompleteAfterPrepared deprecated

func ShouldETCDEncryptionKeyRotationBeAutoCompleteAfterPrepared(credentials *core.ShootCredentials) bool

ShouldETCDEncryptionKeyRotationBeAutoCompleteAfterPrepared returns whether the current ETCD encryption key rotation should be auto completed after the preparation phase has finished.

Deprecated: This function will be removed in a future release. The function will be no longer needed with the removal `rotate-etcd-encryption-key-start` & `rotate-etcd-encryption-key-complete` annotations. TODO(AleksandarSavchev): Remove this after support for Kubernetes v1.33 is dropped.

func SupportedLifecycleClassification

func SupportedLifecycleClassification(version core.ExpirableVersion) core.LifecycleStage

SupportedLifecycleClassification returns the lifecycle stage in which the version is classified as supported. It returns nil if no such stage exists.

func SystemComponentsAllowed

func SystemComponentsAllowed(worker *core.Worker) bool

SystemComponentsAllowed checks if the given worker allows system components to be scheduled onto it

func TaintsAreTolerated

func TaintsAreTolerated(taints []core.SeedTaint, tolerations []core.Toleration) bool

TaintsAreTolerated returns true when all the given taints are tolerated by the given tolerations.

func TaintsHave

func TaintsHave(taints []core.SeedTaint, key string) bool

TaintsHave returns true if the given key is part of the taints list.

func ToExpirableVersions

func ToExpirableVersions(versions []core.MachineImageVersion) []core.ExpirableVersion

ToExpirableVersions converts MachineImageVersion to ExpirableVersion

func VersionIsSupported

func VersionIsSupported(version core.ExpirableVersion) bool

VersionIsSupported reports whether the given version is supported.

Types

type MachineImageDiff

type MachineImageDiff struct {
	RemovedImages                 sets.Set[string]
	RemovedVersions               map[string]sets.Set[string]
	RemovedVersionClassifications map[string]map[string]sets.Set[core.VersionClassification]
	AddedImages                   sets.Set[string]
	AddedVersions                 map[string]sets.Set[string]
}

MachineImageDiff contains the diff of machine images and versions between two slices of machine images.

func GetMachineImageDiff

func GetMachineImageDiff(old, new []core.MachineImage) MachineImageDiff

GetMachineImageDiff returns the removed and added machine images and versions from the diff of two slices.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL