Declare platform intents for non-Kix-managed pods
Use a platform intent when pods installed outside Kix need explicit network access. An intent identifies those pods and describes their required ingress or egress without adding them to a Kix package.
This guide assumes generated network policy is enabled and the cluster has a network policy enforcer.
Find a stable pod selector
Section titled “Find a stable pod selector”Inspect the labels on the externally managed pods:
❱ kubectl get pods -n observability --show-labels Choose labels maintained by the system that installs the workload. Avoid pod names and rollout-specific labels.
Add the platform intent
Section titled “Add the platform intent”Add an entry under networkPolicy.platformIntents:
networkPolicy.platformIntents.metrics-agent = { scope = "clusterwide"; targetNamespace = "observability"; podSelector."app.kubernetes.io/name" = "metrics-agent"; egress = [ { to = "dns"; } { to = "world"; ports = [ { port = 443; protocol = "TCP"; } ]; } ]; };This intent selects Pods labelled app.kubernetes.io/name=metrics-agent in
the observability namespace. It allows DNS lookups and outbound HTTPS.
to and from accept fixed values rather than arbitrary selectors. to
accepts dns, world, and apiserver; from accepts all-pods and world.
Anything else fails evaluation with unknown egress intent target or
unknown ingress intent source.
scope = "clusterwide" creates a cluster-wide policy. The
targetNamespace label constraint keeps it scoped to the intended namespace.
Check the generated policy
Section titled “Check the generated policy”Evaluate the cluster:
❱ kix check how-to-platform-network-policy
TOOL RESULT DETAILS
eval pass 48 manifests evaluated
kubeconform pass skipped (this validation tool is not yet integrated with Kix)
pluto pass skipped (this validation tool is not yet integrated with Kix)
kyverno pass skipped (this validation tool is not yet integrated with Kix)
scorecard pass 0 errors, 45 warnings, 6 info Inspect the policy generated for the intent:
❱ kix build how-to-platform-network-policy --output json
{
"apiVersion": "cilium.io/v2",
"kind": "CiliumClusterwideNetworkPolicy",
"metadata": {
"name": "metrics-agent"
},
"spec": {
"egress": [
{
"toEndpoints": [
{
"matchLabels": {
"k8s-app": "kube-dns",
"k8s:io.kubernetes.pod.namespace": "kube-system"
}
}
],
"toPorts": [
{
"ports": [
{
"port": "53",
"protocol": "UDP"
},
{
"port": "53",
"protocol": "TCP"
}
]
}
]
},
{
"toEntities": [
"world"
],
"toPorts": [
{
"ports": [
{
"port": "443",
"protocol": "TCP"
}
]
}
]
}
],
"endpointSelector": {
"matchLabels": {
"app.kubernetes.io/name": "metrics-agent",
"k8s:io.kubernetes.pod.namespace": "observability"
}
}
}
} The generated endpoint selector contains both the workload label and the namespace. Its egress rules allow UDP and TCP DNS traffic, plus TCP port 443 to destinations outside the cluster.
Deploy the cluster and inspect the installed policy:
❱ kix deploy how-to-platform-network-policy❱ kubectl get ciliumclusterwidenetworkpolicy metrics-agent -o yaml If the policy does not select the expected pods, compare its
endpointSelector.matchLabels with the labels reported by kubectl. All
selector labels must match the same pod.