This is the multi-page printable view of this section. Click here to print.
2025
May
Fine-Tuning kube-proxy Readiness: Ensuring Accurate Health Checks During Node Scale-Down
Gardener has recently refined how it determines the readiness of kube-proxy
components within managed Kubernetes clusters. This adjustment leads to more accurate system health reporting, especially during node scale-down operations orchestrated by cluster-autoscaler
.
The Challenge: kube-proxy Readiness During Node Scale-Down
Previously, Gardener utilized kube-proxy
’s /healthz
endpoint for its readiness probe. While generally effective, this endpoint’s behavior changed in Kubernetes 1.28 (as part of KEP-3836 and implemented in kubernetes/kubernetes#116470). The /healthz
endpoint now reports kube-proxy
as unhealthy if its node is marked for deletion by cluster-autoscaler
(e.g., via a specific taint) or has a deletion timestamp.
This behavior is intended to help external load balancers (particularly those using externalTrafficPolicy: Cluster
on infrastructures like GCP) avoid sending new traffic to nodes that are about to be terminated. However, for Gardener’s internal system component health checks, this meant that kube-proxy
could appear unready for extended periods if node deletion was delayed due to PodDisruptionBudgets
or long terminationGracePeriodSeconds
. This could lead to misleading “unhealthy” states for the cluster’s system components.
The Solution: Aligning with Upstream kube-proxy Enhancements
To address this, Gardener now leverages the /livez
endpoint for kube-proxy
’s readiness probe in clusters running Kubernetes version 1.28 and newer. The /livez
endpoint, also introduced as part of the aforementioned kube-proxy
improvements, checks the actual liveness of the kube-proxy
process itself, without considering the node’s termination status.
For clusters running Kubernetes versions 1.27.x and older (where /livez
is not available), Gardener will continue to use the /healthz
endpoint for the readiness probe.
This change, detailed in gardener/gardener#12015, ensures that Gardener’s readiness check for kube-proxy
accurately reflects kube-proxy
’s operational status rather than the node’s lifecycle state. It’s important to note that this adjustment does not interfere with the goals of KEP-3836; cloud controller managers can still utilize the /healthz
endpoint for their load balancer health checks as intended.
Benefits for Gardener Operators
This enhancement brings a key benefit to Gardener operators:
- More Accurate System Health: The system components health check will no longer report
kube-proxy
as unhealthy simply because its node is being gracefully terminated bycluster-autoscaler
. This reduces false alarms and provides a clearer view of the cluster’s actual health. - Smoother Operations: Operations teams will experience fewer unnecessary alerts related to
kube-proxy
during routine scale-down events, allowing them to focus on genuine issues.
By adapting its kube-proxy
readiness checks, Gardener continues to refine its operational robustness, providing a more stable and predictable management experience.
Further Information
- GitHub Pull Request: gardener/gardener#12015
- Recording of the presentation segment: Watch on YouTube (starts at the relevant section)
- Upstream KEP: KEP-3836: Kube-proxy improved ingress connectivity reliability
- Upstream Kubernetes PR: kubernetes/kubernetes#116470
New in Gardener: Forceful Redeployment of gardenlets for Enhanced Operational Control
Gardener continues to enhance its operational capabilities, and a recent improvement introduces a much-requested feature for managing gardenlets: the ability to forcefully trigger their redeployment. This provides operators with greater control and a streamlined recovery path for specific scenarios.
The Standard gardenlet Lifecycle
gardenlets, crucial components in the Gardener architecture, are typically deployed into seed clusters. For setups utilizing the seedmanagement.gardener.cloud/v1alpha1.Gardenlet
resource, particularly in unmanaged seeds (those not backed by a shoot cluster and ManagedSeed
resource), the gardener-operator
handles the initial deployment of the gardenlet.
Once this initial deployment is complete, the gardenlet takes over its own lifecycle, leveraging a self-upgrade strategy to keep itself up-to-date. Under normal circumstances, the gardener-operator
does not intervene further after this initial phase.
When Things Go Awry: The Need for Intervention
While the self-upgrade mechanism is robust, certain situations can arise where a gardenlet might require a more direct intervention. For example:
- The gardenlet’s client certificate to the virtual garden cluster might have expired or become invalid.
- The gardenlet
Deployment
in the seed cluster might have been accidentally deleted or become corrupted.
In such cases, because the gardener-operator
’s responsibility typically ends after the initial deployment, the gardenlet might not be able to recover on its own, potentially leading to operational issues.
Empowering Operators: The Force-Redeploy Annotation
To address these challenges, Gardener now allows operators to instruct the gardener-operator
to forcefully redeploy a gardenlet. This is achieved by annotating the specific Gardenlet
resource with:
gardener.cloud/operation=force-redeploy
When this annotation is applied, it signals the gardener-operator
to re-initiate the deployment process for the targeted gardenlet, effectively overriding the usual hands-off approach after initial setup.
How It Works
The process for a forceful redeployment is straightforward:
- An operator identifies a gardenlet that requires redeployment due to issues like an expired certificate or a missing deployment.
- The operator applies the
gardener.cloud/operation=force-redeploy
annotation to the correspondingseedmanagement.gardener.cloud/v1alpha1.Gardenlet
resource in the virtual garden cluster. - Important: If the gardenlet is for a remote cluster and its kubeconfig
Secret
was previously removed (a standard cleanup step after initial deployment), thisSecret
must be recreated, and its reference (.spec.kubeconfigSecretRef
) must be re-added to theGardenlet
specification. - The
gardener-operator
detects the annotation and proceeds to redeploy the gardenlet, applying its configurations and charts anew. - Once the redeployment is successfully completed, the
gardener-operator
automatically removes thegardener.cloud/operation=force-redeploy
annotation from theGardenlet
resource. Similar to the initial deployment, it will also clean up the referenced kubeconfigSecret
and set.spec.kubeconfigSecretRef
tonil
if it was provided.
Benefits
This new feature offers significant advantages for Gardener operators:
- Enhanced Recovery: Provides a clear and reliable mechanism to recover gardenlets from specific critical failure states.
- Improved Operational Flexibility: Offers more direct control over the gardenlet lifecycle when exceptional circumstances demand it.
- Reduced Manual Effort: Streamlines the process of restoring a misbehaving gardenlet, minimizing potential downtime or complex manual recovery procedures.
This enhancement underscores Gardener’s commitment to operational excellence and responsiveness to the needs of its user community.
Dive Deeper
To learn more about this feature, you can explore the following resources:
- GitHub Pull Request: gardener/gardener#11972
- Official Documentation: Forceful Re-Deployment of gardenlets
- Community Meeting Recording (starts at the relevant segment): Gardener Review Meeting on YouTube
Streamlined Node Onboarding: Introducing `gardenadm token` and `gardenadm join`
Gardener continues to enhance its gardenadm
tool, simplifying the management of autonomous Shoot clusters. Recently, new functionalities have been introduced to streamline the process of adding worker nodes to these clusters: the gardenadm token
command suite and the corresponding gardenadm join
command. These additions offer a more convenient and Kubernetes-native experience for cluster expansion.
Managing Bootstrap Tokens with gardenadm token
A key aspect of securely joining nodes to a Kubernetes cluster is the use of bootstrap tokens. The new gardenadm token
command provides a set of subcommands to manage these tokens effectively within your autonomous Shoot cluster’s control plane node. This functionality is analogous to the familiar kubeadm token
commands.
The available subcommands include:
gardenadm token list
: Displays all current bootstrap tokens. You can also use the--with-token-secrets
flag to include the token secrets in the output for easier inspection.gardenadm token generate
: Generates a cryptographically random bootstrap token. This command only prints the token; it does not create it on the server.gardenadm token create [token]
: Creates a new bootstrap token on the server. If you provide a token (in the format[a-z0-9]{6}.[a-z0-9]{16}
), it will be used. If no token is supplied,gardenadm
will automatically generate a random one and create it.- A particularly helpful option for this command is
--print-join-command
. When used, instead of just outputting the token, it prints the completegardenadm join
command, ready to be copied and executed on the worker node you intend to join. You can also specify flags like--description
,--validity
, and--worker-pool-name
to customize the token and the generated join command.
- A particularly helpful option for this command is
gardenadm token delete <token-value...>
: Deletes one or more bootstrap tokens from the server. You can specify tokens by their ID, the full token string, or the name of the Kubernetes Secret storing the token (e.g.,bootstrap-token-<id>
).
These commands provide comprehensive control over the lifecycle of bootstrap tokens, enhancing security and operational ease.
Joining Worker Nodes with gardenadm join
Once a bootstrap token is created (ideally using gardenadm token create --print-join-command
on a control plane node), the new gardenadm join
command facilitates the process of adding a new worker node to the autonomous Shoot cluster.
The command is executed on the prospective worker machine and typically looks like this:
gardenadm join --bootstrap-token <token_id.token_secret> --ca-certificate <base64_encoded_ca_bundle> --gardener-node-agent-secret-name <os_config_secret_name> <control_plane_api_server_address>
Key parameters include:
--bootstrap-token
: The token obtained from thegardenadm token create
command.--ca-certificate
: The base64-encoded CA certificate bundle of the cluster’s API server.--gardener-node-agent-secret-name
: The name of the Secret in thekube-system
namespace of the control plane that contains the OperatingSystemConfig (OSC) for thegardener-node-agent
. This OSC dictates how the node should be configured.<control_plane_api_server_address>
: The address of the Kubernetes API server of the autonomous cluster.
Upon execution, gardenadm join
performs several actions:
- It discovers the Kubernetes version of the control plane using the provided bootstrap token and CA certificate.
- It checks if the
gardener-node-agent
has already been initialized on the machine. - If not already joined, it prepares the
gardener-node-init
configuration. This involves setting up a systemd service (gardener-node-init.service
) which, in turn, downloads and runs thegardener-node-agent
. - The
gardener-node-agent
then uses the bootstrap token to securely download its specific OperatingSystemConfig from the control plane. - Finally, it applies this configuration, setting up the kubelet and other necessary components, thereby officially joining the node to the cluster.
After the node has successfully joined, the bootstrap token used for the process will be automatically deleted by the kube-controller-manager
once it expires. However, it can also be manually deleted immediately using gardenadm token delete
on the control plane node for enhanced security.
These new gardenadm
commands significantly simplify the expansion of autonomous Shoot clusters, providing a robust and user-friendly mechanism for managing bootstrap tokens and joining worker nodes.
Further Information
Enhanced Network Flexibility: Gardener Now Supports CIDR Overlap for Non-HA Shoots
Gardener is continually evolving to offer greater flexibility and efficiency in managing Kubernetes clusters. A significant enhancement has been introduced that addresses a common networking challenge: the requirement for completely disjoint network CIDR blocks between a shoot cluster and its seed cluster. Now, Gardener allows for IPv4 network overlap in specific scenarios, providing users with more latitude in their network planning.
Addressing IP Address Constraints
Previously, all shoot cluster networks (pods, services, nodes) had to be distinct from the seed cluster’s networks. This could be challenging in environments with limited IP address space or complex network topologies. With this new feature, IPv4 or dual-stack shoot clusters can now define pod, service, and node networks that overlap with the IPv4 networks of their seed cluster.
How It Works: NAT for Seamless Connectivity
This capability is enabled through a double Network Address Translation (NAT) mechanism within the VPN connection established between the shoot and seed clusters. When IPv4 network overlap is configured, Gardener intelligently maps the overlapping shoot and seed networks to a dedicated set of newly reserved IPv4 ranges. These ranges are used exclusively within the VPN pods to ensure seamless communication, effectively resolving any conflicts that would arise from the overlapping IPs.
The reserved mapping ranges are:
241.0.0.0/8
: Seed Pod Mapping Range242.0.0.0/8
: Shoot Node Mapping Range243.0.0.0/8
: Shoot Service Mapping Range244.0.0.0/8
: Shoot Pod Mapping Range
Conditions for Utilizing Overlapping Networks
To leverage this new network flexibility, the following conditions must be met:
- Non-Highly-Available VPN: The shoot cluster must utilize a non-highly-available (non-HA) VPN. This is typically the configuration for shoots with a non-HA control plane.
- IPv4 or Dual-Stack Shoots: The shoot cluster must be configured as either single-stack IPv4 or dual-stack (IPv4/IPv6). The overlap feature specifically pertains to IPv4 networks.
- Non-Use of Reserved Ranges: The shoot cluster’s own defined networks (for pods, services, and nodes) must not utilize any of the Gardener-reserved IP ranges, including the newly introduced mapping ranges listed above, or the existing
240.0.0.0/8
range (Kube-ApiServer Mapping Range).
It’s important to note that Gardener will prevent the migration of a non-HA shoot to an HA setup if its network ranges currently overlap with the seed, as this feature is presently limited to non-HA VPN configurations. For single-stack IPv6 shoots, Gardener continues to enforce non-overlapping IPv6 networks to avoid any potential issues, although IPv6 address space exhaustion is less common.
Benefits for Gardener Users
This enhancement offers increased flexibility in IP address management, particularly beneficial for users operating numerous shoot clusters or those in environments with constrained IPv4 address availability. By relaxing the strict disjointedness requirement for non-HA shoots, Gardener simplifies network allocation and reduces the operational overhead associated with IP address planning.
Explore Further
To dive deeper into this feature, you can review the original pull request and the updated documentation:
- GitHub PR: feat: Allow CIDR overlap for non-HA VPN shoots (#11582)
- Gardener Documentation: Shoot Networking
- Developer Talk Recording: Gardener Development - Sprint Review #131
Enhanced Node Management: Introducing In-Place Updates in Gardener
Gardener is committed to providing efficient and flexible Kubernetes cluster management. Traditionally, updates to worker pool configurations, such as machine image or Kubernetes minor version changes, trigger a rolling update. This process involves replacing existing nodes with new ones, which is a robust approach for many scenarios. However, for environments with physical or bare-metal nodes, or stateful workloads sensitive to node replacement, or if the virtual machine type is scarce, this can introduce challenges like extended update times and potential disruptions.
To address these needs, Gardener now introduces In-Place Node Updates. This new capability allows certain updates to be applied directly to existing worker nodes without requiring their replacement, significantly reducing disruption and speeding up update processes for compatible changes.
New Update Strategies for Worker Pools
Gardener now supports three distinct update strategies for your worker pools, configurable via the updateStrategy
field in the Shoot
specification’s worker pool definition:
AutoRollingUpdate
: This is the classic and default strategy. When updates occur, nodes are cordoned, drained, terminated, and replaced with new nodes incorporating the changes.AutoInPlaceUpdate
: With this strategy, compatible updates are applied directly to the existing nodes. The MachineControllerManager (MCM) automatically selects nodes, cordons and drains them, and then signals the Gardener Node Agent (GNA) to perform the update. Once GNA confirms success, MCM uncordons the node.ManualInPlaceUpdate
: This strategy also applies updates directly to existing nodes but gives operators fine-grained control. After an update is specified, MCM marks all nodes in the pool as candidates. Operators must then manually label individual nodes to select them for the in-place update process, which then proceeds similarly to theAutoInPlaceUpdate
strategy.
The AutoInPlaceUpdate
and ManualInPlaceUpdate
strategies are available when the InPlaceNodeUpdates
feature gate is enabled in the gardener-apiserver
.
What Can Be Updated In-Place?
In-place updates are designed to handle a variety of common operational tasks more efficiently:
- Machine Image Updates: Newer versions of a machine image can be rolled out by executing an update command directly on the node, provided the image and cloud profile are configured to support this.
- Kubernetes Minor Version Updates: Updates to the Kubernetes minor version of worker nodes can be applied in-place.
- Kubelet Configuration Changes: Modifications to the Kubelet configuration can be applied directly.
- Credentials Rotation: Critical for security, rotation of Certificate Authorities (CAs) and ServiceAccount signing keys can now be performed on existing nodes without replacement.
However, some changes still necessitate a rolling update (node replacement):
- Changing the machine image name (e.g., switching from Ubuntu to Garden Linux).
- Modifying the machine type.
- Altering volume types or sizes.
- Changing the Container Runtime Interface (CRI) name (e.g., from Docker to containerd).
- Enabling or disabling node-local DNS.
Key API and Component Adaptations
Several Gardener components and APIs have been enhanced to support in-place updates:
- CloudProfile: The
CloudProfile
API now allows specifyinginPlaceUpdates
configuration withinmachineImage.versions
. This includes a booleansupported
field to indicate if a version supports in-place updates and an optionalminVersionForUpdate
string to define the minimum OS version from which an in-place update to the current version is permissible. - Shoot Specification: As mentioned, the
spec.provider.workers[].updateStrategy
field allows selection of the desired update strategy. Additionally,spec.provider.workers[].machineControllerManagerSettings
now includesmachineInPlaceUpdateTimeout
anddisableHealthTimeout
(which defaults totrue
for in-place strategies to prevent premature machine deletion during lengthy updates). ForManualInPlaceUpdate
,maxSurge
defaults to0
andmaxUnavailable
to1
. - OperatingSystemConfig (OSC): The OSC resource, managed by OS extensions, now includes
status.inPlaceUpdates.osUpdate
where extensions can specify thecommand
andargs
for the Gardener Node Agent to execute for machine image (Operating System) updates. Thespec.inPlaceUpdates
field in the OSC will carry information like the target Operating System version, Kubelet version, and credential rotation status to the node. - Gardener Node Agent (GNA): GNA is responsible for executing the in-place updates on the node. It watches for a specific node condition (
InPlaceUpdate
with reasonReadyForUpdate
) set by MCM, performs the OS update, Kubelet updates, or credentials rotation, restarts necessary pods (like DaemonSets), and then labels the node with the update outcome. - MachineControllerManager (MCM): MCM orchestrates the in-place update process. For in-place strategies, while new machine classes and machine sets are created to reflect the desired state, the actual machine objects are not deleted and recreated. Instead, their ownership is transferred to the new machine set. MCM handles cordoning, draining, and setting node conditions to coordinate with GNA.
- Shoot Status & Constraints: To provide visibility, the
status.inPlaceUpdates.pendingWorkerUpdates
field in theShoot
now lists worker pools pendingautoInPlaceUpdate
ormanualInPlaceUpdate
. A newShootManualInPlaceWorkersUpdated
constraint is added if any manual in-place updates are pending, ensuring users are aware. - Worker Status: The
Worker
extension resource now includesstatus.inPlaceUpdates.workerPoolToHashMap
to track the configuration hash of worker pools that have undergone in-place updates. This helps Gardener determine if a pool is up-to-date. - Forcing Updates: If an in-place update is stuck, the
gardener.cloud/operation=force-in-place-update
annotation can be added to the Shoot to allow subsequent changes or retries.
Benefits of In-Place Updates
- Reduced Disruption: Minimizes workload interruptions by avoiding full node replacements for compatible updates.
- Faster Updates: Applying changes directly can be quicker than provisioning new nodes, especially for OS patches or configuration changes.
- Bare-Metal Efficiency: Particularly beneficial for bare-metal environments where node provisioning is more time-consuming and complex.
- Stateful Workload Friendly: Lessens the impact on stateful applications that might be sensitive to node churn.
In-place node updates represent a significant step forward in Gardener’s operational flexibility, offering a more nuanced and efficient approach to managing node lifecycles, especially in demanding or specialized environments.
Dive Deeper
To explore the technical details and contributions that made this feature possible, refer to the following resources:
- Parent Issue for “[GEP-31] Support for In-Place Node Updates”: Issue #10219
- GEP-31: In-Place Node Updates of Shoot Clusters: GEP-31: In-Place Node Updates of Shoot Clusters
- Developer Talk Recording (starting at 39m37s): Youtube
Gardener Dashboard 1.80: Streamlined Credentials, Enhanced Cluster Views, and Real-Time Updates
Gardener Dashboard version 1.80 introduces several significant enhancements aimed at improving user experience, credentials management, and overall operational efficiency. These updates bring more clarity to credential handling, a smoother experience for managing large numbers of clusters, and a move towards a more reactive interface.
Unified and Enhanced Credentials Management
The management of secrets and credentials has been significantly revamped for better clarity and functionality:
- Introducing CredentialsBindings: The dashboard now fully supports
CredentialsBinding
resources alongside the existingSecretBinding
resources. This allows for referencing both Secrets and, in the future, Workload Identities more explicitly. WhileCredentialsBindings
referencing Workload Identity resources are visible for cluster creation, editing or deleting them via the dashboard is not yet supported. - “Credentials” Page: The former “Secrets” page has been renamed to “Credentials.” It features a new “Kind” column and distinct icons to clearly differentiate between
SecretBinding
andCredentialsBinding
types, especially useful when resources share names. The column showing the referenced credential resource name has been removed as this information is part of the binding’s details. - Contextual Information and Safeguards: When editing a secret, all its associated data is now displayed, providing better context. If an underlying secret is referenced by multiple bindings, a hint is shown to prevent unintended impacts. Deletion of a binding is prevented if the underlying secret is still in use by another binding.
- Simplified Creation and Editing: New secrets created via the dashboard will now automatically generate a
CredentialsBinding
. While existingSecretBindings
remain updatable, the creation of newSecretBindings
through the dashboard is no longer supported, encouraging the adoption of the more versatileCredentialsBinding
. The edit dialog for secrets now pre-fills current data, allowing for easier modification of specific fields. - Handling Missing Secrets: The UI now provides clear information and guidance if a
CredentialsBinding
orSecretBinding
references a secret that no longer exists.
Revamped Cluster List for Improved Scalability
Navigating and managing a large number of clusters is now more efficient:
- Virtual Scrolling: The cluster list has adopted virtual scrolling. Rows are rendered dynamically as you scroll, replacing the previous pagination system. This significantly improves performance and provides a smoother browsing experience, especially for environments with hundreds or thousands of clusters.
- Optimized Row Display: The height of individual rows in the cluster list has been reduced, allowing more clusters to be visible on the screen at once. Additionally, expandable content within a row (like worker details or ticket labels) now has a maximum height with internal scrolling, ensuring consistent row sizes and smooth virtual scrolling performance.
Real-Time Updates for Projects
The dashboard is becoming more dynamic with the introduction of real-time updates:
- Instant Project Changes: Modifications to projects, such as creation or deletion, are now reflected instantly in the project list and interface without requiring a page reload. This is achieved through WebSocket communication.
- Foundation for Future Reactivity: This enhancement for projects lays the groundwork for bringing real-time updates to other resources within the dashboard, such as Seeds and the Garden resource, in future releases.
Other Notable Enhancements
- Kubeconfig Update: The kubeconfig generated for garden cluster access via the “Account” page now uses the
--oidc-pkce-method
flag, replacing the deprecated--oidc-use-pkce
flag. Users encountering deprecation messages should redownload their kubeconfig. - Notification Behavior: Kubernetes warning notifications are now automatically dismissed after 5 seconds. However, all notifications will remain visible as long as the mouse cursor is hovering over them, giving users more time to read important messages.
- API Server URL Path: Support has been added for kubeconfigs that include a path in the API server URL.
These updates in Gardener Dashboard 1.80 collectively enhance usability, provide better control over credentials, and improve performance for large-scale operations.
For a comprehensive list of all features, bug fixes, and contributor acknowledgments, please refer to the official release notes. You can also view the segment of the community call discussing these dashboard updates here.
Gardener: Powering Enterprise Kubernetes at Scale and Europe's Sovereign Cloud Future
The Kubernetes ecosystem is dynamic, offering a wealth of tools to manage the complexities of modern cloud-native applications. For enterprises seeking to provision and manage Kubernetes clusters efficiently, securely, and at scale, a robust and comprehensive solution is paramount. Gardener, born from years of managing tens of thousands of clusters efficiently across diverse platforms and in demanding environments, stands out as a fully open-source choice for delivering fully managed Kubernetes Clusters as a Service. It already empowers organizations like SAP, STACKIT, T-Systems, and others (see adopters) and has become a core technology for NeoNephos, a project aimed at advancing digital autonomy in Europe (see KubeCon London 2025 Keynote and press announcement).
The Gardener Approach: An Architecture Forged by Experience
At the heart of Gardener’s architecture is the concept of “Kubeception” (see readme and architecture). This approach involves using Kubernetes to manage Kubernetes. Gardener runs on a Kubernetes cluster (called a runtime cluster), facilitates access through a self-managed node-less Kubernetes cluster (the garden cluster), manages Kubernetes control planes as pods within other self-managed Kubernetes clusters that provide high scalability (called seed clusters), and ultimately provisions end-user Kubernetes clusters (called shoot clusters).
This multi-layered architecture isn’t complexity for its own sake. Gardener’s design and extensive feature set are the product of over eight years of continuous development and refinement, directly shaped by the high-scale, security-sensitive, and enterprise-grade requirements of its users. Experience has shown that such a sophisticated structure is key to addressing significant challenges in scalability, security, and operational manageability. For instance:
- Scalability: Gardener achieves considerable scalability through its use of seed clusters, which it also manages. This allows for the distribution of control planes, preventing bottlenecks. The design even envisions leveraging Gardener to host its own management components (as an autonomous cluster), showcasing its resilience without risking circular dependencies.
- Security: A fundamental principle in Gardener is the strict isolation of control planes from data planes. This extends to Gardener itself, which runs in a dedicated management cluster but exposes its API to end-users through a workerless virtual cluster. This workerless cluster acts as an isolated access point, presenting no compute surface for potentially malicious pods, thereby significantly enhancing security.
- API Power & User Experience: Gardener utilizes the full capabilities of the Kubernetes API server. This enables advanced functionalities and sophisticated API change management. Crucially, for the end-user, interaction remains 100% Kubernetes-native. Users employ standard custom resources to instruct Gardener, meaning any tool, library, or language binding that supports Kubernetes CRDs inherently supports Gardener.
Delivering Fully Managed Kubernetes Clusters as a Service
Gardener provides a comprehensive “fully managed Kubernetes Clusters as a Service” offering. This means it handles much more than just spinning up a cluster; it manages the entire lifecycle and operational aspects. Here’s a glimpse into its capabilities:
Full Cluster Lifecycle Management:
- Infrastructure Provisioning: Gardener takes on the provisioning and management of underlying cloud infrastructure, including VPCs, subnets, NAT gateways, security groups, IAM roles, and virtual machines across a wide range of providers like AWS, Azure, GCP, OpenStack, and more.
- Worker Node Management: It meticulously manages worker pools, covering OS images, machine types, autoscaling configurations (min/max/surge), update strategies, volume management, CRI configuration, and provider-specific settings.
Enterprise Platform Governance:
- Cloud Profiles: Gardener is designed with the comprehensive needs of enterprise platform operators in mind. Managing a fleet of clusters for an organization requires more than just provisioning; it demands clear governance over available resources, versions, and their lifecycle. Gardener addresses this through its declarative API, allowing platform administrators to define and enforce policies such as which Kubernetes versions are “supported,” “preview,” or “deprecated,” along with their expiration dates. Similarly, it allows control over available machine images, their versions, and lifecycle status. This level of granular control and lifecycle management for the underlying components of a Kubernetes service is crucial for enterprise adoption and stable operations. This is a key consideration often left as an additional implementation burden for platform teams using other cluster provisioning tools, where such governance features must be built on top. Gardener, by contrast, integrates these concerns directly into its API and operational model, simplifying the task for platform operators.
Advanced Networking:
- CNI Plugin Management: Gardener manages the deployment and configuration of CNI plugins such as Calico or Cilium.
- Dual-Stack Networking: It offers comprehensive support for IPv4, IPv6, and dual-stack configurations for pods, services, and nodes.
- NodeLocal DNS Cache: To enhance DNS performance and reliability, Gardener can deploy and manage NodeLocal DNS.
Comprehensive Autoscaling:
- Cluster Autoscaler: Gardener manages the Cluster Autoscaler for worker nodes, enabling dynamic scaling based on pod scheduling demands.
- Horizontal and Vertical Pod Autoscaler (VPA): It manages HPA/VPA for workloads and applies it to control plane components, optimizing resource utilization (see blog).
Operational Excellence & Maintenance:
- Automated Kubernetes Upgrades: Gardener handles automated Kubernetes version upgrades for both control plane and worker nodes, with configurable maintenance windows.
- Automated OS Image Updates: It manages automated machine image updates for worker nodes.
- Cluster Hibernation: To optimize costs, Gardener supports hibernating clusters, scaling down components during inactivity.
- Scheduled Maintenance: It allows defining specific maintenance windows for predictability.
- Robust Credentials Rotation: Gardener features automated mechanisms for rotating all credentials. It provisions fine-grained, dedicated, and individual CAs, certificates, credentials, and secrets for each component — whether Kubernetes-related (such as service account keys or etcd encryption keys) or Gardener-specific (such as opt-in SSH keys or observability credentials). The Gardener installation, the seeds, and all shoots have their own distinct sets of credentials — amounting to more than 150 per shoot cluster control plane and hundreds of thousands for larger Gardener installations overall. All these credentials are rotated automatically and without downtime — most continuously, while some (like the API server CA) require user initiation to ensure operational awareness. For a deeper dive into Gardener’s credential rotation, see our Cloud Native Rejekts talk). This granular approach effectively prevents lateral movement, significantly strengthening the security posture.
Enhanced Security & Access Control:
- OIDC Integration: Gardener supports OIDC configuration for the
kube-apiserver
for secure user authentication. - Customizable Audit Policies: It allows specifying custom audit policies for detailed logging.
- Managed Service Account Issuers: Gardener can manage service account issuers, enhancing workload identity security.
- SSH Access Control: It provides mechanisms to manage SSH access to worker nodes securely if opted in (Gardener itself doesn’t require SSH access to worker nodes).
- Workload Identity: Gardener supports workload identity features, allowing pods to securely authenticate to cloud provider services.
- OIDC Integration: Gardener supports OIDC configuration for the
Powerful Extensibility:
- Extension Framework and Ecosystem: Gardener features a robust extension mechanism for deep integration of cloud providers, operating systems, container runtimes, or services like DNS management, certificate management, registry caches, network filtering, image signature verification, and more.
- Catered to Platform Builders: This extensibility also allows platform builders to deploy custom extensions into the self-managed seed cluster infrastructure that hosts shoot cluster control planes. This offers robust isolation for these custom components from the user’s shoot cluster worker nodes, enhancing both security and operational stability.
Integrated DNS and Certificate Management:
- External DNS Management: Gardener can manage DNS records for the cluster’s API server and services via its
shoot-dns-service
extension. - Automated Certificate Management: Through extensions like
shoot-cert-service
, it manages TLS certificates, including ACME integration. Gardener also provides its own robust DNS (dns-management
) and certificate (cert-management
) solutions designed for enterprise scale. These custom solutions were developed because, at the scale Gardener operates, many deep optimizations were necessary, e.g., to avoid being rate-limited by upstream providers.
- External DNS Management: Gardener can manage DNS records for the cluster’s API server and services via its
A Kubernetes-Native Foundation for Sovereign Cloud
The modern IT landscape is rapidly evolving away from primitive virtual machines towards distributed systems. Kubernetes has emerged as the de facto standard for deploying and managing these modern, cloud-native applications and services at scale. Gardener is squarely positioned at the forefront of this shift, offering a Kubernetes-native approach to managing Kubernetes clusters themselves. It possesses a mature, declarative, Kubernetes-native API for full cluster lifecycle management. Unlike services that might expose proprietary APIs, Gardener’s approach is inherently Kubernetes-native and multi-cloud. This unified API is comprehensive, offering a consistent way to manage diverse cluster landscapes.
Its nature as a fully open-source project is particularly relevant for initiatives like NeoNephos, which aim to build sovereign cloud solutions. All core features, stable releases, and essential operational components are available to the community. This inherent cloud-native, Kubernetes-centric design, coupled with its open-source nature and ability to run on diverse infrastructures (including on-premise and local cloud providers), provides the transparency, control, and technological independence crucial for digital sovereignty. Gardener delivers full sovereign control today, enabling organizations to run all modern applications and services at scale with complete authority over their infrastructure and data. This is a significant reason why many cloud providers and enterprises that champion sovereignty are choosing Gardener as their foundation and actively contributing to its ecosystem.
Operational Depth Reflecting Real-World Scale
Gardener’s operational maturity is a direct reflection of its long evolution, shaped by the demands of enterprise users and real-world, large-scale deployments. This maturity translates into statistical evidence and track records of uptime for end-users and their critical services. For instance, Gardener includes fully automated, incremental etcd backups with a recovery point objective (RPO) of five minutes and supports autonomous, hands-off restoration workflows via etcd-druid
. Features like Vertical Pod Autoscalers (VPAs), PodDisruptionBudgets (PDBs), NetworkPolicies, PriorityClasses, and sophisticated pod placement strategies are integral to Gardener’s offering, ensuring high availability and fault tolerance. Gardener’s automation deals with many of the usual exceptions and does not require human DevOps intervention for most operational tasks. Gardener’s commitment to robust security is evident in Gardener’s proactive security posture, which has proven effective in real-world scenarios. This depth of experience and automation ultimately translates into first-class Service Level Agreements (SLAs) that businesses can trust and rely on. As a testament to this, SAP entrusts Gardener with its Systems of Record. This level of operational excellence enables Gardener to meet the expectations of today’s most demanding Kubernetes use cases.
Conclusion: A Solid Foundation for Your Kubernetes Strategy
For enterprises and organizations seeking a comprehensive, truly open-source solution for managing the full lifecycle of Kubernetes clusters at scale, Gardener offers a compelling proposition. Its mature architecture, rich feature set, operational robustness, built-in enterprise governance capabilities, and commitment to the open-source community provide a solid foundation for running demanding Kubernetes workloads with confidence. This makes it a suitable technical underpinning for ambitious projects like NeoNephos, contributing to a future of greater digital autonomy.
We invite you to explore Gardener and discover how it can empower your enterprise-grade and -scale Kubernetes journey.
April
Leaner Clusters, Lower Bills: How Gardener Optimized Kubernetes Compute Costs
As organizations embrace Kubernetes for managing containerized applications at scale, the underlying infrastructure costs, particularly for compute resources, become a critical factor. Gardener, the open-source Kubernetes management platform, empowers organizations like SAP, STACKIT, T-Systems, and others (see adopters) to operate tens of thousands of Kubernetes clusters efficiently across diverse environments. Gardener’s role as a core technology in initiatives like NeoNephos, aimed at advancing digital autonomy in Europe (see KubeCon London 2025 Keynote and press announcement), further underscores the need for cost-effective and sustainable operations.
At the heart of Gardener’s architecture is the concept of “Kubeception” (see readme and architecture): Gardener runs on Kubernetes (called a runtime cluster), facilitates access through a self-managed node-less Kubernetes cluster (called the garden cluster), manages Kubernetes control planes as pods within self-managed Kubernetes clusters that provide high scalability to Gardener (called seed clusters), and provisions end-user Kubernetes clusters (called shoot clusters). Therefore, optimizing Gardener’s own Kubernetes-related resource consumption directly translates into cost savings across all these layers, benefiting both Gardener service providers and the end-users consuming the managed clusters.
While infrastructure costs span compute, storage, and networking, compute resources (the virtual machines running Kubernetes nodes) typically represent the largest share of the bill. Over the past years, the Gardener team has undertaken a significant effort to optimize these costs. This blog post details our journey, focusing heavily on the compute optimizations that go beyond standard autoscaling practices, ultimately delivering substantial savings that benefit the entire Gardener ecosystem.
We’ll build upon the foundations laid out in our Pod Autoscaling Best Practices Guide. You may want to check it out beforehand, as we’ll only touch upon a few key recommendations from it in this blog post, not delving into the full depth required for effective pod autoscaling – a prerequisite for the compute optimizations discussed here.
Visibility and Initial Measures
Know Your Spending: Leveraging Observability and IaaS Cost Tools
You can’t optimize what you can’t measure. Our first step was to gain deep visibility into our spending patterns. We leveraged:
- IaaS Cost Reports & Alerts: Regularly analyzing detailed cost breakdowns from cloud providers (AWS Cost Explorer, Azure Cost Management, GCP Billing Reports) helped us identify major cost drivers across compute, storage, and network usage. Setting up alerts for cost anomalies makes us aware of regressions and unexpected budget overruns.
- Cloud Provider Recommendation Tools: Tools like AWS Trusted Advisor, Azure Advisor’s Cost recommendations, and Google Cloud’s machine type rightsizing recommendations provided initial, manual pointers towards obvious inefficiencies like underutilized virtual machines or suboptimal instance types.
- Internal Usage Reports: We generated custom reports detailing our own resource consumption. This helped identify and drive down the number and uptime of development and other non-production clusters. Automating the configuration of Gardener’s cluster hibernation feature or reporting on clusters with poor hibernation schedules further curbed unnecessary spending. These insights are now integrated into the Gardener Dashboard (our GUI).
The Reserved Instance / Savings Plan Imperative: Planning for Discounts
Cloud providers offer significant discounts for commitment: Reserved Instances (RIs) on AWS/Azure, Savings Plans (SPs) on AWS/Azure, and Committed Use Discounts (CUDs) on GCP. However, maximizing their benefit requires careful planning, which is not the primary subject of this blog post. Companies typically have tools that generate recommendations from cost reports, suggesting the purchase of new RIs, SPs, or CUDs if on-demand usage consistently increases. Two key learnings emerged in this context, though:
- Coordination between Operations and Controlling: We discovered that technical optimizations and discount commitment purchases must go hand-in-hand. A significant 20% utilization improvement can be completely negated if the remaining workload runs on expensive on-demand instances because the RI/SP/CUD purchase didn’t account for the change. On-demand pricing can easily be twice or more expensive than committed pricing.
- Commitments vs. Spot Pricing: While Spot Instances/Preemptible virtual machines offer deep discounts, their ephemeral nature makes them unsuitable for critical control plane components. For predictable baseline workloads, well-planned RIs/SPs/CUDs provide substantial, reliable savings and are often more beneficial overall. Spot Instance/Preemptible VM discounts are generally not higher than, and often less than, RI/SP/CUD discounts for comparable commitment levels.
Early Wins: Finding and Eliminating Resource Waste
We also actively looked for waste, specifically orphaned resources. Development and experimentation inevitably lead to forgotten resources (virtual machines, disks, load balancers, etc.). We implemented processes like requiring all resources to include a personal identifier in the name or as a label/tag to facilitate later cleanup. Initially, we generated simple reports, but it became clear that this task required a more professional approach. Unaccounted-for resources aren’t just costly; they can also pose security risks or indicate security incidents. Therefore, we developed the gardener/inventory
tool. This tool understands Gardener installations and cross-references expected cloud provider resources (based on Gardener’s desired state and implementation) against actually existing resources. It acts as an additional safety net, alerting on discrepancies (e.g., unexpected load balancers for a seed, unmanaged virtual machines in a VPC) which could indicate either cost leakage or a potential security issue, complementing Gardener’s existing security measures like high-frequency credentials rotation, image signing and admission, network policies, Falco, etc.
Consolidation: Avoiding a Fragmented Seed Landscape
If possible, avoid operating too many small seeds unless required by regulations or driven by end-user demand. As Gardener supports control plane migration, you can consolidate your control planes into fewer, larger seeds where reasonable. Since starting Gardener in production in 2017, we’ve encountered technological advancements (e.g., Azure Availability Sets to Zones) and corrected initial misconfigurations (e.g., too-small CIDR ranges limiting pod/node counts) that necessitated recreating seeds. While hard conflicts (like seed/shoot cluster IP address overlaps) can sometimes block migration to differently configured seeds, you can often at least merge multiple seeds into one or fewer. The key takeaway is that a less fragmented seed landscape generally leads to better efficiency.
However, there is a critical caveat: Gardener allows control planes to reside in different regions (or even different cloud providers) than their worker nodes. This flexibility comes at the cost of inter-regional or internet network traffic. These additional network-related costs can easily negate efficiency gains from seed consolidation. Therefore, consolidate thoughtfully, being mindful that excessive consolidation across regions can significantly increase network costs (intra-region traffic is cheaper than inter-region traffic, and internet traffic is usually the most expensive).
Quick Wins in Networking and Storage
While compute was our main focus, we also addressed significant cost drivers in networking and storage early on.
Centralized Ingress & Caching
- Centralized Ingress: In Gardener’s early days, each shoot control plane had its own Load Balancer (LB), plus another for the reverse tunnel connection to worker nodes (to reach webhooks, scrape metrics, stream logs,
exec
into pods, etc.). This proliferation of LBs was expensive. We transitioned to a model using a central Istio ingress-gateway per seed cluster with a single LB, leveraging SNI (Server Name Indication) routing to direct traffic to the correct control plane API servers. We also reversed the connection direction: shoots now connect to seed clusters, and seeds connect to the garden cluster. This reduced the need for LBs exposing seed components and enabled private shoots or even private seeds behind firewalls. - Registry Cache: Pulling container images for essential components (like CNI, CSI drivers, kube-proxy) on every new node startup generated significant network traffic and costs. We implemented a registry cache extension, drastically reducing external image pulls (see blog post).
Smarter Networking Habits
- Efficient API Usage: Well-implemented controllers use
watch
requests rather than frequentlist
requests to minimize API server load and improve responsiveness. Leveraging server-side filtering via label selectors and field selectors reduces the amount of data transferred. - Reducing Cross-Zonal Traffic: Data transfer between availability zones, necessary for highly available control planes, is generally more expensive than within a single zone. We enabled Kubernetes’ Topology Aware Routing to help route API server traffic within the same zone where possible, reducing cross-zonal traffic and therefore costs (see Gardener Issue #6718).
- Avoiding Large Resources: Storing large amounts of data directly in Kubernetes resources (ConfigMaps, Secrets) is inefficient and strains etcd and the network. We utilize blob stores for large payloads, such as control plane etcd or state backups used for automated restoration or control plane migration (with data compressed and encrypted in transit and at rest).
- Regression Monitoring: Implementing regression monitoring for network traffic helped catch seemingly innocent code changes that could inadvertently cause massive spikes in data transfer costs.
Conscious Storage Consumption
Storage costs were addressed by being mindful of Persistent Volume Claim (PVC) size and performance tiers (e.g., standard HDD vs. premium SSD). Choosing the right storage class based on actual workload needs prevents overspending on unused capacity or unnecessary IOPS.
Deep Dive into Compute Cost Optimization
This is where the most significant savings were realized. Optimizing compute utilization in Kubernetes is a multi-faceted challenge involving the interplay of several components.
Understanding Utilization: The Interplay of Scheduler, Cluster Autoscaler, HPA, and VPA
We think of utilization optimization in two stages:
- Packing Pods onto Nodes (Requests vs. Allocatable): How efficiently are the resource requests of your pods filling up the allocatable capacity of your nodes? This is primarily influenced by the Kube-Scheduler and the Cluster Autoscaler (CA).
- Right-Sizing Pods (Usage vs. Requests): How closely does the actual resource usage of your pods match their requests? This is where Horizontal Pod Autoscaler (HPA) and Vertical Pod Autoscaler (VPA) come in.
You need to optimize both stages for maximum efficiency.
Optimizing Scheduling: Bin-Packing and Pod Priorities with Kube-Scheduler
- Bin-Packing: By default, Kube-Scheduler tries to spread pods across nodes (using the
LeastAllocated
strategy). For cost optimization, packing pods tightly onto fewer nodes (using theMostAllocated
strategy, often called bin-packing) is more effective. Gardener runs Kubernetes control planes as pods on seed clusters. Switching the Kube-Scheduler profile in our seed clusters to prioritize bin-packing yielded over 20% reduction in machine costs for these clusters simply by requiring fewer nodes. We also made this scheduling profile available for shoot clusters (see Gardener PR #6251). - Pod Priorities: Assigning proper Pod Priorities is important not just for stability but also for cost. High-priority pods (like control plane components) can preempt lower-priority pods if necessary, reducing the need to maintain excess capacity just in case a critical pod needs scheduling space. This avoids unnecessary over-provisioning.
Voluntary Disruptions: Pod Disruption Budgets
- Pod Disruption Budgets: Defining proper Pod Disruption Budgets (PDBs) helps manage and steer voluntary disruptions safely. We define them consistently for all Gardener components. This provides the necessary control to rebalance, compact, or generally replace underlying machines as needed by us or our automation, contributing to cost efficiency by enabling node consolidation.
Enabling Higher Pod Density per Node
- Node Configuration: To effectively utilize larger instance types and enable better bin-packing, nodes must be configured to handle more pods. We observed nodes becoming pod-bound (unable to schedule more pods despite available CPU/memory). To prevent this, ensure you provide:
- A large enough
--node-cidr-mask-size
(e.g.,/22
for ~1024 IPs, though assume ~80% effective due to IP reuse; see kube-controller-manager docs) to allocate sufficient IPs per node. - Sufficient
--kube-reserved
resources (see kubelet docs) to account for system overhead. - An increased
--max-pods
value (again, see kubelet docs) to inform the kubelet and scheduler of the node’s actual pod capacity.
- A large enough
Fine-Tuning the Cluster Autoscaler: Scaling Nodes Efficiently
The cluster autoscaler (CA) adds or removes nodes based on pending pods and node utilization. We tuned its behavior for better cost efficiency:
--scale-down-unneeded-time=15m
: Time a node must be underutilized before CA considers it for removal, allowing removal of persistently unneeded capacity.--scale-down-delay-after-add=30m
: Prevents CA from removing a node too soon after adding one, reducing potential node thrashing during fluctuating load.--scale-down-utilization-threshold=0.9
: We significantly increased this threshold (default is 0.5). It instructs CA to attempt removing any node running below 90% utilization if it can safely reschedule the existing pods onto other available nodes; otherwise, it does nothing. We have run with this setting successfully for a long time, supported by properly tuned pod priorities, PDBs managing voluntary disruptions, highly available control planes, and Kubernetes’ level-triggered, asynchronous nature.
Mastering Pod Autoscaling: HPA, VPA, and Best Practices
Right-sizing pods dynamically is key. Kubernetes offers HPA and VPA:
- Horizontal Pod Autoscaling (HPA): Scales the number of pod replicas based on metrics (CPU/memory utilization, custom metrics). Ideal for stateless applications handling variable request loads.
- Vertical Pod Autoscaler (VPA): Adjusts the CPU/memory requests of existing pods. Ideal for stateless and also stateful applications or workloads with fluctuating resource needs over time, without changing replica count.
Our Best Practices & Learnings:
- Combine HPA and VPA for API Servers Safely: You can use HPA and VPA together, even on the same metric (like CPU), but careful configuration is essential. The key is to configure HPA to scale based on the average value (
target.type: AverageValue
) rather than utilization percentage (target.type: Utilization
). This prevents conflicts where VPA changes the requests, which would otherwise immediately invalidate HPA’s utilization calculation.- Example HPA targeting average CPU/Memory values:
spec: minReplicas: 3 maxReplicas: 12 metrics: - resource: name: cpu target: averageValue: 6 # Target 6 cores average usage per pod (Note: String value often required) type: AverageValue type: Resource - resource: name: memory target: averageValue: 24Gi # Target 24Gi average usage per pod type: AverageValue type: Resource behavior: # Fine-tune scaling behavior scaleDown: policies: - periodSeconds: 300 type: Pods value: 1 selectPolicy: Max stabilizationWindowSeconds: 1800 scaleUp: policies: - periodSeconds: 60 type: Percent value: 100 selectPolicy: Max stabilizationWindowSeconds: 60 scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: kube-apiserver
- Example HPA targeting average CPU/Memory values:
- Tune VPA Configuration:
- We adjusted VPA parameters like
--target-cpu-percentile
/--target-memory-percentile
(determining the percentile of historical usage data to include in target recommendations, ignoring spikes above) and margin/bound parameters to make VPA less sensitive to tiny spikes and react faster and more accurately to sustained changes. - We also tuned parameters like
--cpu-histogram-decay-half-life
(from 24h to 15m) and--recommendation-lower-bound-cpu-percentile
(from 0.5 to 0.7) to follow changes in CPU utilization more closely (work on memory is ongoing). - VPA
minAllowed
: We setminAllowed
(per VPA resource) based on observed usage patterns and historical outage data related to VPA scaling down too aggressively. - VPA
maxAllowed
: We setmaxAllowed
(per VPA controller) to prevent request recommendations from exceeding node capacity. We foundmaxAllowed
couldn’t be configured centrally in the VPA controller, so we contributed this feature upstream (see Kubernetes Autoscaler Issue #7147 and corresponding PR).
- We adjusted VPA parameters like
- Set Pod Requests: We always set CPU and memory requests for our containers or let VPA manage those.
- Tune Pod Requests: We systematically processed hundreds of components:
- Some deployments were placed under VPA management. Others (very small, below VPA’s resolution of ~10m cores / 10Mi memory) were removed from VPA and given static requests.
- “Initial” Requests: For pods managed by VPA, we set initial requests to the observed P5 (5th percentile) of historical usage. This provides a reasonable starting point for VPA.
- “Static” Requests: For pods not managed by VPA, we set requests to the P95 (95th percentile). This ensures they generally have enough resources; only exceptional spikes might cause issues, where VPA wouldn’t typically help either.
- Quality of Service (QoS): Prefer the
Burstable
QoS class (requests set, ideally no limits) for most workloads. AvoidBestEffort
(no requests/limits), as these pods are the first to be evicted under pressure. AvoidGuaranteed
(requests match limits), as limits often cause more harm than good. See our Pod Autoscaling Best Practices Guide. Pods in theGuaranteed
QoS class, or generally those with limits, will be actively CPU-throttled and can be OOMKilled even if the node has ample spare capacity. Worse, if containers in the pod are under VPA, their CPU requests/limits often won’t scale up appropriately because CPU throttling goes unnoticed by VPA.- Avoid Limits: In Gardener’s context (and often also elsewhere), setting CPU limits offers few advantages and significant disadvantages, primarily unnecessary throttling. Setting memory limits can prevent runaway processes but may also prematurely kill pods. We generally avoid setting limits unless the theoretical maximum resource consumption of a component is well understood. When unsure, let VPA manage requests and rely on monitoring/alerting for excessive usage.
Data-Driven Machine Type Selection
Continuous Monitoring: Understanding How Well Our Machines are Utilized
Before optimizing machine type selection, we established comprehensive machine utilization monitoring. This was important during individual improvement steps to validate their effectiveness. We collect key metrics per Gardener installation, cloud provider, seed, and worker pool, and created dashboards to visualize and monitor our machine costs. These dashboards include:
- Total CPU [in thousand cores], Total Memory [in TB], Total Number of Control Planes [count]
- Used Capacity CPU [%], Used Capacity Memory [%], Unused vs. Capacity Cost [Currency]
- Requested Allocatable CPU [%], Requested Allocatable Memory [%], Unrequested vs. Allocatable Cost [Currency]
- Used Requested CPU [%], Used Requested Memory [%], Unused vs. Requested Cost [Currency]
- Used Reserved CPU [%, can exceed 100%], Used Reserved Memory [%, can exceed 100%], Unused vs. Reserved Cost [Currency]
- Nodes with >99% filling levels, broken down by CPU, memory, volumes, and pods (to identify the most critical resource blocking further usage)
- Effective CPU:memory ratio of the workload (more on that later)
Why Machine Types Matter: Size, Ratios, Generations, and Hidden Constraints
Selecting the right machine type is critical for cost efficiency. Several factors come into play:
- Size: Larger machines generally lead to less fragmentation (less wasted CPU/memory remainder per node) and better overhead efficiency (system components like kubelet/containerd consume a smaller percentage of total resources). However, smaller machines can be better for low-load scenarios while meeting high-availability constraints (e.g., needing to spread critical pods across 3 zones requires at least 3 nodes).
- CPU:Memory Ratio: Cloud providers offer instance families with different CPU:memory ratios (e.g., high-cpu 1:2, standard 1:4, high-memory 1:8). Matching the instance ratio to your workload’s aggregate CPU:memory request ratio minimizes waste.
- Generations: Newer instance generations usually offer better performance and, crucially, better price-performance. This can also shift the effective CPU:memory ratio required by the workload due to performance differences.
- Hidden Constraints: Volume Limits: This proved to be a major factor, especially on AWS and Azure. Each instance type has a maximum number of network-attached volumes it can support. Gardener control planes, each with its own etcd cluster requiring persistent volumes for each replica, are heavily impacted. We often found ourselves limited by volume attachments long before hitting CPU or memory limits. Interestingly, ARM-based instance types on Azure support a slightly higher volume limit.
The Case for Dedicated Pools: Isolating Workloads
While mixing diverse workloads seems efficient at first glance, dedicated node pools for specific workload types proved beneficial for several reasons:
- Handling
safe-to-evict: false
: Some pods (like single-replica stateful components for non-HA clusters) cannot be safely evicted by the Cluster Autoscaler. Mixing these with evictable pods on the same node can prevent the CA from scaling down that node, even if it’s underutilized, negating cost savings. Placing these non-evictable pods in a dedicated pool (where scale-down might be disabled or carefully managed) isolates this behavior. - Volume Concentration: Our “etcd” worker pools host primarily etcd pods (high volume count) and daemonsets, while “standard” pools host API servers, controllers, etc. (lower volume concentration). This difference influences the optimal machine type due to volume attachment limits.
- Preventing Scheduling Traps: Ensure critical, long-running pods (like Istio gateways) have node affinities/selectors to land only on their preferred, optimized node pools. Avoid them landing on temporary, large nodes spun up for short-lived bulky pods; if such a pod prevents the large node from scaling down (e.g., because the pool is at its minimum node count), the CA won’t automatically replace the underutilized large node with a smaller one. That’s a concept called “workload consolidation”, today only supported by Karpenter, which isn’t supporting as many cloud providers as CA.
Analyzing Workload Profiles: Finding the Optimal Instance Size and Family
Early on, we used a guide for operators to estimate a reasonable machine size for a seed cluster based on the number of hosted control planes, e.g.:
Optimal Worker Pool (CPUxMem+Vols) | Very Low Seed Utilization 0 <= |control planes| < 15 | Low Seed Utilization 5 <= |control planes| < 30 | Medium Seed Utilization 10 <= |control planes| < 70 | High Seed Utilization 30 <= |control planes| < 180 | Very High Seed Utilization 120 <= |control planes| < ∞ |
---|---|---|---|---|---|
AWS | m5.large (2x8+26) | r7i.large (2x16+32) | r7i.xlarge (4x32+32) | r7i.2xlarge (8x64+32) | r7i.2xlarge (8x64+32) |
Azure | Standard_D2s_v5 (2x8+4) | Standard_D4s_v5 (4x16+8) | Standard_D8s_v5 (8x32+16) | Standard_D16s_v5 (16x64+32) | Standard_D16s_v5 (16x64+32) |
GCP | n1-standard-2 (2x8+127) | n1-standard-4 (4x15+127) | n1-standard-8 (8x30+127) | n1-standard-16 (16x60+127) | n1-standard-16 (16x60+127) |
This guide also recommended specific instance families. Choosing the right family requires calculating the workload’s aggregate CPU:memory ratio (total requested CPU : total requested memory across similar workloads). For example, 1000 cores and 6000 GB memory yields a 1:6 ratio.
Next, one must calculate the cost per core and per GB for different instance families and determine the break-even CPU:memory ratio – the point where the resource waste of two families is equal. The cluster autoscaler doesn’t perform this cost-aware analysis; it always weights CPU and memory equally (1:1).
To find the optimal family manually, we followed these steps when adding new generations/families:
- Cost per Resource Unit: Determine the effective cost per core and per GB. Example:
- Instance A (2 cores, 4 GB) costs €48/month.
- Instance B (2 cores, 8 GB) costs €64/month.
- Difference: 4 GB and €16 -> €4 per GB.
- Cost of 2 cores = €48 - (4 GB * €4/GB) = €32 -> €16 per core.
- Break-Even Analysis: Using the unit costs, calculate the break-even CPU:memory ratio where the cost of waste balances out between two families for your specific workload ratio.
For instance, if the break-even ratio between standard (1:4) and high-memory (1:8) families is 1:5.7, and your workload runs at 1:6, the high-memory family is likely more cost-effective.
Automating the Choice: A Machine Type Recommender
This manual process was tedious, error-prone, and infrequently performed, leading to suboptimal machine types running in many seeds. To address this, we developed an automated pool recommender based on the following principles:
Comprehensive Data Collection: The recommender gathers metrics across the entire Gardener installation for specific seed sets (groups of seeds with similar configurations like provider and region). For every relevant seed, it collects:
- Node Metadata & Specs: Instance type, pool, zone, capacity, allocatable resources.
- CSI Node Info: Maximum attachable volume counts per node.
- Pod Specs: Resource requests (CPU, memory) for all pods, distinguishing daemonset pods.
- Actual Node Usage: Detailed usage statistics obtained directly from the kubelet summary API (
/api/v1/nodes/NODENAME/proxy/stats/summary
). This provides actual cgroup-level data on CPU and memory consumption for kubelet, container runtime, system overhead, and individual pods. Especially for memory, this was the only reliable method we found to get accurate working set bytes overall (simply summing pod metrics is inaccurate due to page cache/sharing; see kernel docs for cgroup-v1 and cgroup-v2).
Analyzing the Data: Before recommending new types, the recommender calculates key metrics that act as predictors and provide context:
- Workload Ratios: Requested Core : Requested GB, Attached Volume : Requested GB, Scheduled Pod : Requested GB.
- Measured Overhead Ratios: Measured Reserved Core : Pod Count, Measured Reserved GB : Pod Count.
- Aggregation: Machines are grouped by pool within a seed set.
- Performance Normalization: CPU metrics (usage) are normalized based on relative performance indicators of the analyzed machine type.
Simulating Workload on Candidate Machines: This is the core recommendation logic:
- Candidate Iteration: The system iterates through all potential machine types available for the specific provider and region(s).
- Resource Calculation per Candidate: For each candidate machine type:
- Calculate
kube-reserved
: Estimates CPU/memory needed for kubelet/runtime using our measurement-based model, tailored to the candidate’s capacity (more on that later). - Account for DaemonSets: Subtracts the average CPU/memory requests of DaemonSet pods (derived from current aggregated pool data).
- Performance Adjustment: Adjusts CPU calculations (reserved, daemonset, workload requests) based on the candidate’s performance factor relative to a baseline.
- Calculate Allocatable Resources: Determines CPU/memory available for workload pods after subtracting reserved and DaemonSet resources.
- Unschedulable Buffer: Reduces allocatable resources slightly (e.g., by the equivalent of an “average pod”) to account for resource fragmentation and imperfect bin-packing, slightly favoring larger nodes.
- Calculate
- Constraint Checking & Usable Resources: Projects how much of the aggregated current workload (total requests) could fit onto the candidate. It considers multiple dimensions, converting them to a common unit (GB-equivalent) using the measured workload ratios:
- Performance-adjusted Allocatable CPU (converted to GB-equivalent)
- Allocatable Memory (GB)
- Attachable Volumes (converted to GB-equivalent)
- Schedulable Pods (converted to GB-equivalent) The minimum of these values determines the actual usable resources for that candidate machine type under the given workload profile – identifying the true bottleneck, i.e. whether a candidate is CPU-, memory-, volume-, pod-, or load-bound and thus potentially suboptimal.
- Cost & Waste Analysis:
- Calculates the base
machine_costs
(Cores * Cost per Core + GBs * Cost per GB
) for the candidate. - Estimates
excess_costs
(waste) per machine due to factors like:- Imperfect Packing: Assumes the “last” node in a zone is only half-utilized on average.
- Scale-Down Disabled: Increases estimated waste if scale-down is disabled.
- Volume Packing: Adds potential waste if the workload is heavily volume-constrained, assuming not all nodes can be packed efficiently with volumes.
- Calculates the base
- Efficiency Score Calculation: Computes a relative efficiency score for each candidate:
Efficiency = (Cost_of_Usable_Resources) / (Base_Machine_Cost + Estimated_Excess_Cost)
This score reflects how cost-effectively the candidate machine type can serve the workload, factoring in estimated waste.
Ranking & Selection:
- Sorting: Candidates are ranked primarily by
Efficiency / Cost per Core
. Dividing by cost per core helps prioritize newer/cheaper instance generations or those with better RI/SP coverage, while still heavily favoring the calculated efficiency. - Preferred Type & Hysteresis: The top-ranked type is marked as
preferred
and receives the highest CA expander priority. A threshold (e.g., >5% efficiency improvement) prevents switching the preferred type too frequently, avoiding churn (flapping). - Priority Assignment: Priorities are assigned for the cluster autoscaler expander, favoring the preferred type and then ranking others based on the sort order.
- Handling Existing/Legacy Pools: Ensures that pools with currently running nodes, even if suboptimal or using non-standard names, are preserved to avoid disruption. Legacy pools are tainted with a
NoSchedule
taint to allow workload to slowely migrate away from them.
- Sorting: Candidates are ranked primarily by
This data-driven, simulation-based approach allowed us to abandon guides like above and manual operations and consistently select machine types that offer the best balance of performance and cost for the specific workloads running on our Gardener seeds.
Reserving Capacity for Kubelet and Container Runtime: Tailoring kube-reserved
Beyond Workload-Naive Formulas
As pod packing density increases, accurately accounting for resources needed by the system itself (kubelet, container runtime, OS) becomes critical. Standard cloud provider formulas for kube-reserved
(see kubelet options) are often workload-naive, based only on total node CPU/memory capacity (see summary blog post). They can either over-reserve (wasting resources) or under-reserve (risking node stability). Our experience showed that formulas considering only node capacity and potentially maxPods
were often significantly inaccurate, leading to either waste or instability.
Therefore, instead of relying on static formulas, we adopted a measurement-based approach combined with predictive modeling:
Measure Actual Overhead: We utilize the data already retrieved via the kubelet summary API. By querying this endpoint across thousands of nodes for all our seeds, we collect the actual CPU (
usageNanoCores
) and memory (workingSetBytes
) consumed by thekubelet
andruntime
system containers under various conditions (different machine types, workload profiles like ETCD pools, varying pod densities).Derive Workload-Aware Ratios: We then calculate key ratios that correlate overhead with workload characteristics, specifically pod density:
ratio_1_used_reserved_core_to_pods
: Average number of pods running per actually used reserved core (performance-normalized across machine types).ratio_1_used_reserved_gi_to_pods
: Average number of pods running per actually used reserved GB of memory.
These ratios capture how much system overhead is typically generated per pod on average within a specific pool type for a given seed set. We explored other potential predictors (containers, probes) but found pod count to be the most useful predictor with acceptable standard deviation.
Predict Expected
kube-reserved
: We use these measured ratios to predict the necessarykube-reserved
for any candidate machine type considered by the Pool Recommender. The model works as follows:- Base Load: We observed a consistent base memory overhead even on lightly loaded nodes (e.g., ~200MiB with Garden Linux, Gardener’s own Debian-based container-optimized OS) and negligible base CPU overhead.
- Estimate Pod-Driven Overhead: Using the predicted pod density for a candidate machine type (based on its capacity and the workload profile), we multiply this density by the measured
ratio_1_used_reserved_core_to_pods
andratio_1_used_reserved_gi_to_pods
to estimate the requiredkube-reserved
CPU and memory, respectively. This tailors the reservation to the candidate’s specific capacity and performance characteristics.
Apply Thresholds for Stability: To prevent minor fluctuations in calculated recommendations from causing constant configuration changes (increasing
kube-reserved
can trigger pod evictions), we apply thresholds (hysteresis).
This tailored, data-driven approach to kube-reserved
provides better cost optimization and enhanced stability compared to generic, workload-naive formulas.
Note on system-reserved
: You might wonder why we only discussed kube-reserved
and not system-reserved
. Similar to our reasoning against resource limits, configuring system-reserved
can lead to unexpected CPU throttling or OOM kills for critical system processes outside Kubernetes’ direct management. Therefore, Gardener focuses on configuring kube-reserved
and relies on the kubelet’s eviction mechanisms to manage overall node pressure. See also Reserve Compute Resources for System Daemons.
Looking Ahead: Continuous Improvement and Future Optimizations
Cost optimization is an ongoing process, not a one-time fix. We’re actively exploring further improvements:
- Addressing Load Imbalances: VPA assigns the same request to all pods in a managed group (Deployment/StatefulSet/DaemonSet). This is inefficient for workloads with inherent imbalances (e.g., controller leaders vs. followers, etcd leader vs. followers, uneven load distribution across DaemonSet pods).
- Request-Based Load Balancing: For components like the
kube-apiserver
, default connection-based load balancing can lead to uneven load distribution that VPA handles poorly (resulting in over-provisioning for some pods, under-provisioning for others). We have implemented request-based load balancing to distribute load more evenly, allowing VPA to set more accurate requests (see related work). - In-place pod resource updates (a Kubernetes enhancement) would be particularly beneficial in the future, allowing VPA to adjust resources without requiring pod restarts, further improving efficiency and stability.
- Request-Based Load Balancing: For components like the
- Exploring Cilium / Replacing kube-proxy: Initial tests suggest switching the CNI from Calico to Cilium could yield 5-10% CPU savings on worker nodes, partly because Cilium can replace kube-proxy, reducing overhead. Memory usage appears similar and Gardener has supported Cilium for years. Alternatively, to eliminate kube-proxy without changing CNIs, we could evaluate Calico’s eBPF data plane, which can also replace kube-proxy.
- ARM Architecture: We are evaluating ARM-based CPUs (AWS Graviton, Azure Cobalt, GCP Axion). They are generally cheaper per core. Even if slightly slower per core (but often with a better price-performance), they offer additional instance family options, potentially allowing a better match to the workload’s CPU:memory ratio (e.g., a 1:6 workload x86 ratio might turn into a performance-adjusted 1:5 ARM ratio and thereby result in less waste than x86 instance families of either a 1:4 or 1:8 ratio). Additionally, Azure’s ARM instances sometimes offer slightly higher volume attachment limits.
Conclusion: Sustainable Savings and Key Takeaways
Optimizing Kubernetes compute costs at scale is a complex but rewarding endeavor. Our journey with Gardener involved a multi-pronged approach:
- Establish Visibility: Use cloud cost tools and internal monitoring to understand spending.
- Strategic Purchasing: Tightly align RI/SP/CUD purchases with technical optimizations and workload forecasts.
- Clean Up Waste: Eliminate orphaned resources and leverage features like cluster hibernation.
- Tune Kubernetes Core Components: Utilize scheduler bin-packing, fine-tune cluster autoscaler parameters, and master HPA/VPA configurations, including safe combined usage.
- Data-Driven Machine Selection: Analyze workload profiles, use dedicated pools strategically, consider all constraints (especially non-obvious ones like volume limits), and automate machine type recommendations based on real data and simulation.
- Accurate Overheads: Measure and tailor
kube-reserved
based on actual system usage patterns rather than static formulas.
These efforts have yielded substantial cost reductions for operating Gardener itself and, by extension, for all Gardener adopters running managed Kubernetes clusters. We hope sharing our journey provides valuable insights for your own optimization efforts, whether you’re just starting or looking to refine your existing strategies.
March
Gardener at KubeCon + CloudNativeCon Europe, London 2025
Gardener at KubeCon + CloudNativeCon Europe, London 2025
The open-source project Gardener is set to showcase its cutting-edge Kubernetes-as-a-Service (KaaS) capabilities at KubeCon + CloudNativeCon Europe 2025 in London.
Gardener has been pioneering hosted control planes long before they became mainstream and is now the default choice within SAP and other organizations for provisioning Kubernetes clusters. Organizations looking to transform their Infrastructure-as-a-Service (IaaS) into a Kubernetes-as-a-Service (KaaS) platform can experience Gardener’s powerful automation, security, and multi-cloud extensibility firsthand at the event or directly in the browser.
Revolutionizing Kubernetes Management with Gardener
Gardener provides a fully managed Kubernetes cluster solution that is:
- Infinitely Extensible: Gardener offers limitless extensibility, supporting AWS, Azure, Alicloud, GCP, OpenStack, and other infrastructures. Run nodes with Garden Linux, SuSE, Ubuntu, or Flatcar OS while utilizing runc or gVisor for container runtime flexibility and Calico or Cilium for CNI. Explore the Gardener Extensions Library for even more customization options.
- Automated Lifecycle Management: Simplified provisioning, scaling, and updates with built-in automation.
- Security & Compliance: Enforced policies and strict isolation to meet regulatory and enterprise security requirements, with support for automated credential rotation.
- Multi-Tenancy & Cost Efficiency: Designed for organizations running at scale, optimizing resources without sacrificing performance.
Also, explore our other open-source projects:
etcd-druid – Our in-house operator responsible for managing etcd instances in Gardener’s hosted control planes, ensuring the stability and performance of Kubernetes clusters.
openMCP – Our latest open-source offering that enables organizations to streamline application development using control plane methodology, making it easy to roll out, upgrade, and replicate cloud environments securely and seamlessly.
As Kubernetes adoption continues to accelerate, Gardener remains the go-to choice for managing Kubernetes at scale across multi-cloud and hybrid environments. Stop by our booth S561 at KubeCon + CloudNativeCon Europe 2025 to experience Gardener firsthand and meet the team to see how Gardener empowers organizations to run secure, scalable, and efficient Kubernetes clusters with ease.