Skip to content
Install the CLI

How-to guide Package task guides

Install Cilium / network policy support

These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.

Use the cilium package to make Kix responsible for the Cilium CNI and the CiliumNetworkPolicy API.

This guide uses a new Kind cluster. Cilium must be the cluster’s CNI from the start, so create Kind without its default CNI before deploying the example.

Create this Kind configuration beside the kix-examples checkout:

kind-cilium.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
disableDefaultCNI: true
podSubnet: "10.244.0.0/16"

Create the cluster:

❱ kind create cluster --config kind-cilium.yaml

The control-plane node remains NotReady until Cilium is deployed. That is expected for a cluster with no CNI.

Tell Kix that the Kind environment is not providing a CNI, then enable network policy generation:

how-to/package-stacks/cilium-cluster.nix
# The Kind cluster for this example is created without kindnet, so the
# CNI role is available for a managed package.
cluster.roles.cni = {
binding = "absent";
provider = null;
};
networkPolicy.enable = true;

View source on GitHub ↗

The role setting must describe the cluster you actually created. Do not mark the role absent on a Kind cluster that is already running kindnet.

Install Cilium in kube-system:

how-to/package-stacks/cilium-cluster.nix
# Keeps Kind's kube-proxy; the IPAM pool is the kind flavour's
# cluster.network.podCidr, the podSubnet in kind-cilium.yaml.
instances.kube-system.cilium = {
package = packages.experimental.cilium;
};

View source on GitHub ↗

The instance needs no values. It keeps Kind’s kube-proxy (the chart default) and takes its IPAM pool from cluster.network.podCidr, which the kind flavour sets to Kind’s default podSubnet, 10.244.0.0/16. A Kind configuration with another podSubnet sets cluster.network.podCidr to match. With network policy on, the package sets Cilium’s policyEnforcementMode to always, so a pod without an allow rule loses all traffic except cluster DNS. The package also writes two CiliumClusterwideNetworkPolicies: cilium-cluster-dns-egress keeps cluster DNS open for every pod, and cilium-health-probes lets Cilium’s health probes reach the other nodes.

Evaluate the cluster before deploying it:

kix-examples/
❱ kix check how-to-package-cilium
 TOOL       RESULT  DETAILS                            
 eval       pass    34 manifests evaluated, 3 warnings 
 scorecard  pass    0 errors, 20 warnings, 4 info      

Warnings from the Kix library, 3:
  kube-system/cilium (experimental/cilium): DaemonSet/cilium uses hostNetwork, so network policy does not filter its traffic.
    Object: DaemonSet cilium
    Fix: Restrict access to its ports on the node's host network.
  kube-system/cilium (experimental/cilium): DaemonSet/cilium-envoy uses hostNetwork, so network policy does not filter its traffic.
    Object: DaemonSet cilium-envoy
    Fix: Restrict access to its ports on the node's host network.
  kube-system/cilium (experimental/cilium): Deployment/cilium-operator uses hostNetwork, so network policy does not filter its traffic.
    Object: Deployment cilium-operator
    Fix: Restrict access to its ports on the node's host network.

architecture.annotationDomainOwnership (warning), 1:
  kube-system/cilium: 'cilium' uses annotations under domain 'prometheus.io' (Service/cilium-envoy) but no package in this cluster declares that it handles them. Add the operator package that handles these annotations. If something outside Kix consumes this domain, declare it in `scorecard.knownAnnotationDomains`.

architecture.consistentPortNames (warning), 1:
  kube-system/cilium: port name "health" means more than one number in this instance: DaemonSet/cilium container cilium-agent = 9879, Deployment/cilium-operator container cilium-operator = 9234. A consumer that resolves the name without naming the workload picks one of them by accident. Give each component a name of its own.

architecture.selectorCoherence (warning), 1:
  kube-system/cilium/cilium-envoy: Service 'cilium-envoy' has selector labels that Kix cannot trace to a workload. Use `kix.service.fromWorkload` to derive the selector and track the dependency on the workload.

reliability.boundedResources (warning), 8:
  kube-system/cilium/cilium: container 'cilium-agent' is missing resource settings: requests.cpu, requests.memory, limits.cpu, limits.memory. Set CPU and memory requests and limits. Without a memory limit, a workload can exhaust the node's memory.
  kube-system/cilium/cilium: container 'config' is missing resource settings: requests.cpu, requests.memory, limits.cpu, limits.memory. Set CPU and memory requests and limits. Without a memory limit, a workload can exhaust the node's memory.
  kube-system/cilium/cilium: container 'mount-cgroup' is missing resource settings: requests.cpu, requests.memory, limits.cpu, limits.memory. Set CPU and memory requests and limits. Without a memory limit, a workload can exhaust the node's memory.
  kube-system/cilium/cilium: container 'apply-sysctl-overwrites' is missing resource settings: requests.cpu, requests.memory, limits.cpu, limits.memory. Set CPU and memory requests and limits. Without a memory limit, a workload can exhaust the node's memory.
  kube-system/cilium/cilium: container 'mount-bpf-fs' is missing resource settings: requests.cpu, requests.memory, limits.cpu, limits.memory. Set CPU and memory requests and limits. Without a memory limit, a workload can exhaust the node's memory.
  kube-system/cilium/cilium: container 'clean-cilium-state' is missing resource settings: requests.cpu, requests.memory, limits.cpu, limits.memory. Set CPU and memory requests and limits. Without a memory limit, a workload can exhaust the node's memory.
  kube-system/cilium/cilium-envoy: container 'cilium-envoy' is missing resource settings: requests.cpu, requests.memory, limits.cpu, limits.memory. Set CPU and memory requests and limits. Without a memory limit, a workload can exhaust the node's memory.
  kube-system/cilium/cilium-operator: container 'cilium-operator' is missing resource settings: requests.cpu, requests.memory, limits.cpu, limits.memory. Set CPU and memory requests and limits. Without a memory limit, a workload can exhaust the node's memory.

security.readOnlyRootfs (warning), 9:
  kube-system/cilium/cilium: container 'cilium-agent' does not set readOnlyRootFilesystem
  kube-system/cilium/cilium: container 'config' does not set readOnlyRootFilesystem
  kube-system/cilium/cilium: container 'mount-cgroup' does not set readOnlyRootFilesystem
  kube-system/cilium/cilium: container 'apply-sysctl-overwrites' does not set readOnlyRootFilesystem
  kube-system/cilium/cilium: container 'mount-bpf-fs' does not set readOnlyRootFilesystem
  kube-system/cilium/cilium: container 'clean-cilium-state' does not set readOnlyRootFilesystem
  kube-system/cilium/cilium: container 'install-cni-binaries' does not set readOnlyRootFilesystem
  kube-system/cilium/cilium-envoy: container 'cilium-envoy' does not set readOnlyRootFilesystem
  kube-system/cilium/cilium-operator: container 'cilium-operator' does not set readOnlyRootFilesystem

4 info finding(s) not listed; run with -v to list them.

Inspect the main Cilium components and a generated default-deny policy:

kix-examples/ output excerpt
❱ kix build how-to-package-cilium --output json
[
  {
    "apiVersion": "apps/v1",
    "kind": "DaemonSet",
    "metadata": {
      "name": "cilium",
      "namespace": "kube-system"
    },
    "containers": [
      {
        "name": "cilium-agent",
        "image": "quay.io/cilium/cilium:v1.20.5@sha256:aa72499f075ad729947ea91b026218aceba24f1a8e4534bf36b8368c7c561526"
      }
    ]
  },
  {
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "metadata": {
      "name": "cilium-operator",
      "namespace": "kube-system"
    },
    "containers": [
      {
        "name": "cilium-operator",
        "image": "quay.io/cilium/operator-generic:v1.20.5@sha256:c6e7de6665aa9701db86c4fe46828a75a0d167afe084a9ffb5bce34b2c4fa8c4"
      }
    ]
  },
  {
    "apiVersion": "cilium.io/v2",
    "kind": "CiliumNetworkPolicy",
    "metadata": {
      "name": "kube-system-default-deny",
      "namespace": "kube-system"
    },
    "spec": {
      "egress": [
        {}
      ],
      "endpointSelector": {},
      "ingress": [
        {}
      ]
    }
  }
]
Warnings from the Kix library, 3:
  kube-system/cilium (experimental/cilium): DaemonSet/cilium uses hostNetwork, so network policy does not filter its traffic.
    Object: DaemonSet cilium
    Fix: Restrict access to its ports on the node's host network.
  kube-system/cilium (experimental/cilium): DaemonSet/cilium-envoy uses hostNetwork, so network policy does not filter its traffic.
    Object: DaemonSet cilium-envoy
    Fix: Restrict access to its ports on the node's host network.
  kube-system/cilium (experimental/cilium): Deployment/cilium-operator uses hostNetwork, so network policy does not filter its traffic.
    Object: Deployment cilium-operator
    Fix: Restrict access to its ports on the node's host network.

Kix builds the Cilium DaemonSet and operator from the package, then connects generated policies to Cilium’s custom resource definitions in the deployment graph.

Deploy the cluster and wait for the Cilium pods to become ready:

kix-examples/
❱ kix deploy how-to-package-cilium
❱ kubectl rollout status -n kube-system daemonset/cilium
❱ kubectl get nodes

The Kind node should report Ready after the Cilium DaemonSet is running. Check the generated policies with:

❱ kubectl get ciliumnetworkpolicies --all-namespaces

If the node remains NotReady, compare the pod CIDR in the Kind configuration with cluster.network.podCidr, then inspect the Cilium pod logs in kube-system.

RKE2 installs its own Cilium chart when its server config sets cni: cilium. Tell Kix the same thing with the rke2 flavour, and declare the instance in kube-system:

cluster.flavor.rke2.cni = [ "cilium" ];
instances.kube-system.cilium.package = packages.experimental.cilium;

The flavour declares RKE2’s Cilium as the platform import kube-system/platform-cilium, and the instance takes it as a dependency. The instance does not install a second Cilium. It writes its values into the HelmChartConfig kube-system/rke2-cilium, which the import names and RKE2’s helm-controller merges into the bundled chart: policy enforcement, operator replicas, and rollouts. RKE2’s chart uses kubernetes IPAM, so the package sets no pool. A cluster that wants cluster-pool IPAM sets values.ipam.mode = "cluster-pool" and the pool together.

To replace kube-proxy on RKE2, set values.kubeProxyReplacement = true with values.k8sServiceHost and values.k8sServicePort, and configure every RKE2 server with cni: cilium and disable-kube-proxy: true. Kix cannot read the server config, so it cannot check that the two agree.

With network policy on, the rke2 flavour declares platform intents for the pods RKE2’s bundled charts run in kube-system (CoreDNS, metrics-server, the ingress controllers, the snapshot controller, and the chart install Jobs).

Kix then owns kube-system/rke2-cilium, which has two consequences:

  • RKE2 also applies any rke2-cilium HelmChartConfig in the server’s manifests directory (/var/lib/rancher/rke2/server/manifests). Remove that file, or RKE2 and Kix write the same object.
  • Removing the instance makes the next kix deploy --prune delete the HelmChartConfig, and helm-controller then reinstalls RKE2’s Cilium with its chart defaults.

Keep Cilium running if a Helm upgrade fails

Section titled “Keep Cilium running if a Helm upgrade fails”

On RKE2 releases before 4 August 2026 (earlier than 1.33.13, 1.34.10, 1.35.7, or 1.36.3), set failurePolicy to "abort":

instances.kube-system.cilium = {
package = packages.experimental.cilium;
config.failurePolicy = "abort";
};

When RKE2’s Helm job fails to install or upgrade Cilium, helm-controller follows a failure policy. When failurePolicy is unset, Kix omits spec.failurePolicy from kube-system/rke2-cilium and RKE2’s default applies:

RKE2 releaseDefault policyWhat happens on failure
1.33.13, 1.34.10, 1.35.7, 1.36.3 (4 August 2026) and laterretryhelm-controller retries the install or upgrade. Cilium stays installed.
Earlier releasesreinstallhelm-controller uninstalls Cilium and installs it again.

Under reinstall, no node runs Cilium until the reinstall succeeds. Open connections keep working, while new pods get no networking. During an RKE2 minor upgrade, the reinstall can fail too. With "abort", helm-controller leaves the failed Helm release for you to fix and keeps the running Cilium installation unchanged.

failurePolicy accepts "abort", "reinstall", or "retry" and writes that value to spec.failurePolicy on the HelmChartConfig. RKE2 releases before 4 August 2026 do not recognize "retry", and their API server rejects the HelmChartConfig.

Only an instance that writes a HelmChartConfig accepts failurePolicy. If the cilium instance installs the Helm chart directly, or if its platform-cilium import sets out.helmChartConfig = null, setting failurePolicy fails evaluation.

Control when Cilium pods restart after a values change

Section titled “Control when Cilium pods restart after a values change”

The Cilium agent reads most settings, such as loadBalancer.algorithm, only at startup. By default, the cilium package sets rollOutCiliumPods = true and operator.rollOutPods = true, so any change to values that updates Cilium’s ConfigMap restarts the Cilium agent on every node and restarts the operator. This applies whether RKE2 or Kix installs the Cilium chart.

Restarting the agent on a node that holds an L2 announcement moves that IP address to another node. To control when the agents restart, set values.rollOutCiliumPods = false. kix deploy then finishes while the agents keep running with their previous settings. Restart them when you are ready:

❱ kubectl -n kube-system rollout restart ds/cilium

The Cilium operator still restarts during kix deploy unless you also set values.operator.rollOutPods = false.

If your cluster already has a kube-system/rke2-cilium HelmChartConfig, Kix replaces all of spec.valuesContent on the first deploy. Any setting you do not copy into values is removed. Read the live settings first:

❱ kubectl -n kube-system get helmchartconfig rke2-cilium -o jsonpath='{.spec.valuesContent}'

Copy each setting into the instance’s values. If the live HelmChartConfig also sets spec.failurePolicy, set failurePolicy to the same value. Run kix plan before your first deploy. The plan shows valuesContent as changed even when your settings match, because Kix writes JSON and includes the package’s defaults: policyEnforcementMode, policyAuditMode, operator.replicas, operator.rollOutPods, and rollOutCiliumPods. Check the diff to confirm that none of your existing settings were dropped.

If another field manager owns fields on rke2-cilium, kix plan reports a field ownership conflict and names that owner. Stop that tool from writing the object again first. On RKE2, remove any rke2-cilium manifest from /var/lib/rancher/rke2/server/manifests, because RKE2 reapplies files in that directory each time it starts. Then run kix deploy --force-conflicts once to transfer field ownership to Kix. Because the package enables rollOutCiliumPods by default, expect the first deploy to restart the Cilium agents once unless you set values.rollOutCiliumPods = false.

Where something outside Kix installed and configures Cilium, declare that the environment provides it, as a platform import the cilium instance depends on, and leave its configuration alone:

cluster.roles.cni.binding = "shadowable";
instances.cilium-policy = {
cilium.package = packages.experimental.cilium;
platform-cilium.package = kix.mkImport {
roles = [ "cni" ];
out.helmChartConfig = null;
};
};

out.helmChartConfig = null says the environment merges no HelmChartConfig into its Cilium. Set it to { name; namespace; } when it does, and the instance writes its values there, as on RKE2.

Declare the instance in a namespace of its own, not in kube-system. With network policy on, every namespace Kix manages gets a default-deny policy. Nothing here declares platform intents for the environment’s kube-system pods, so a default deny there would cut off CoreDNS, and with it DNS for every pod.

The instance then emits only the CRD references that generated policies wait on, and the evaluation fails if it is given values.