Reserve Resources for Kubelet and Operating System Daemons on Oracle Cloud Infrastructure Kubernetes Engine Nodes

Introduction

When running Kubernetes workloads on Oracle Cloud Infrastructure Kubernetes Engine (OKE), it is essential to ensure that worker nodes have reserved resources for Kubernetes control components and operating system (OS) daemons. Proper reservation prevents resource contention, reduces memory pressure, and enhances cluster stability. This is especially important in multi-tenant environments, high-density workloads, or when troubleshooting node pressure issues. In this tutorial, you will learn how to configure these reservations using a custom cloud-init script applied at node pool creation. By leveraging cloud-init, you can standardize these configurations across your cluster nodes with minimal effort.

Kubelet Resource Configuration

Kubelet, the primary node agent in Kubernetes, supports resource management through configuration flags or files. You can define:

Objectives

Prerequisites

Step 1: Write the cloud-init Script

The following cloud-init script creates a Kubelet configuration file that reserves CPU, memory, and ephemeral storage, and sets eviction thresholds.

#!/bin/bash
curl --fail -H "Authorization: Bearer Oracle" -L0 http://169.254.169.254/opc/v2/instance/metadata/oke_init_script | base64 --decode >/var/run/oke-init.sh
bash /var/run/oke-init.sh --kubelet-extra-args "--kube-reserved=cpu=500m,memory=1Gi --system-reserved=cpu=100m,memory=100Mi"

Step 2: Create a Node Pool With the cloud-init Script

  1. Go to the OCI Console and navigate to your OKE cluster.

  2. Select Node pools, then click Add node pool to create a new one, or click Edit to modify an existing Node Pool.

  3. Set your node pool with your preferences for Name, Compartment, Node placement, Shape, and Networking.

  4. Under Show advanced options, click Paste Cloud-init Script and paste your custom script.

  5. Complete the rest of the node pool settings and click Add.

Add node pool

Once the nodes are provisioned, the script runs at boot and applies your resource constraints automatically.

Note: If you are automating the setup with Terraform, you can pass the script in the node_config_details.cloud_init_script block when creating the node pool resource.

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.