Skip to main content

More Info:

The kubelet-config.json file should be owned by root:root. Incorrect ownership lets unprivileged users alter kubelet runtime parameters such as authentication and authorization modes.

Risk Level

High

Address

Compliance, Security

Compliance Standards

  • CIS OKE

Triage and Remediation

Remediation

Using Console

You can’t change kubelet-config.json ownership purely with a “button” in the OCI Console, because the file lives on each worker node’s OS. However, you can use the Console to push a startup script (cloud‑init / user data) to your node pool so that every node enforces root:root on boot and on replacement.Below are step‑by‑step instructions to do this using only the OCI Console, without manually SSH’ing to each node.

1. Understand where kubelet-config.json lives

On OKE worker nodes (OCI‑supplied images), the kubelet config is typically under:
  • /etc/oci/kubelet/kubelet-config.json
    or
  • /var/lib/kubelet/config.yaml (for some newer versions)
Your security control specifically references kubelet-config.json, so assume path:
(If you know your cluster image path differs, substitute the correct one in the script below.)

2. Create a bootstrap script to fix ownership

You’ll store this as user data for the node pool via the Console.Prepare this script locally (you’ll paste it in step 3):
This will:
  • Set owner to root:root
  • Set permissions to 600
  • Ensure on every reboot the ownership is re‑applied.

3. Add the script as cloud‑init user data to your node pool

  1. In the OCI Console, go to:
    • Developer Services → Kubernetes Clusters (OKE).
  2. Click your cluster.
  3. Go to the Node Pools tab.
  4. Click the node pool you want to fix.
  5. Click Edit (or Update Node Pool).
  6. Find the Node configuration details / Cloud-init script / User data section:
    • If a script already exists, append the content above to the end of that script (do not remove existing logic).
    • If empty, paste the script from step 2 in full.
  7. Save / Update Node Pool.

4. Rotate / Recreate nodes so the script runs

The script only runs when nodes (re)boot with the new user data.From the same node pool page:
  1. Use Scale or Node Pool → Reboot / Terminate Nodes to cycle nodes:
    • Safest: cordon and drain nodes one by one from kubectl, then terminate them so the node pool recreates them with the new user data.
  2. As each node is recreated, the script runs and fixes ownership.

5. (Optional) Verify on a node

If you are allowed to SSH into worker nodes:
You should see:

If you tell me your exact OKE image version (Oracle Linux version / node shape) I can adjust the path or script for that specific environment.
You can’t change Unix file ownership directly with the OCI CLI alone (the CLI manages OCI resources, not in-guest files), but you can use it to run a command inside each OKE worker node to fix the ownership.Below are step‑by‑step instructions using Compute Instance Run Command via OCI CLI.

1. Prerequisites

  1. Oracle Cloud Agent enabled on worker nodes (OKE default worker images usually have this).
  2. Policy allowing you to use instance run command, e.g.:
  1. OCI CLI configured (oci setup config).

2. Find the worker nodes (instances) of your OKE cluster

  1. Get the node pools for your cluster:
  1. For each node pool, list nodes and map to instance OCIDs:
Note the instance-id values – these are the Compute instances you’ll run commands on.

3. Run chown root:root on each node instance

Assume path to kubelet config is /var/lib/kubelet/config.json or /etc/kubernetes/kubelet/kubelet-config.json. Use the path that applies in your environment.Example using /var/lib/kubelet/config.json:
Explanation:
  • The content is a base64‑encoded bash script:
  • --variables passes the target file path as argument "$1".
Repeat for each INSTANCE_ID from step 2.

4. Verify ownership

You can:
  • Either run another instance‑agent command to check:
The base64 script is:
  • Or SSH into a node and run:
You should see root root as the owner/group.

5. Make it persistent for new nodes

For new/recreated worker nodes in OKE:
  1. Add a cloud-init script in your custom node image or in the node pool config that runs on boot:
  1. Or bake the correct ownership directly into a custom image used by the node pool.

If you tell me your exact kubelet config path on OKE, I can give you a ready‑to‑run CLI command with the right file path only.
To remediate “OCI OKE kubelet-config.json File Ownership Should Be root:root” using Python, you essentially need to:
  1. Find the kubelet config path on OKE worker nodes.
  2. Change its owner to root:root (uid=0, gid=0).
  3. Do this on every worker node (manually via SSH or automatically via a DaemonSet).
Below are step‑by‑step instructions and a minimal Python script.

1. Identify kubelet-config.json path on OKE

On OKE worker nodes, the kubelet config is typically at one of these paths (depending on OKE version / image):
  • /etc/kubernetes/kubelet/kubelet-config.json
  • /var/lib/kubelet/config.json
  • /etc/oci-addons/kubelet/kubelet-config.json
SSH into a worker node and confirm:
Assume you find it at:
Use that path in the Python script.

2. Python script to set ownership to root:root

This script:
  • Verifies file exists.
  • Sets owner to root and group to root.
  • Optionally verifies after change.
Run on node:

3. Automate across all OKE nodes (DaemonSet approach)

If you want to avoid SSHing to each node, run the Python script in a privileged DaemonSet so it executes once on every node.

3.1. Build a small Python image

Dockerfile (example):
Build and push to OCIR (or any registry):
Adjust KUBELET_CONFIG in the script if your path is different.

3.2. DaemonSet YAML

Apply:
Logs from one pod:
Once confirmed, you can delete the DaemonSet:

4. Verify remediation

On a worker node:
This satisfies the requirement “kubelet-config.json File Ownership Should Be root:root” in OCI OKE.