How-to guide / Platform capabilities
Declare platform intents for non-Kix-managed pods
These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.
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:
36 networkPolicy.platformIntents.metrics-agent = {37 scope = "clusterwide";38 targetNamespace = "observability";39 podSelector."app.kubernetes.io/name" = "metrics-agent";40 egress = [41 { to = "dns"; }42 {43 to = "world";44 ports = [45 {46 port = 443;47 protocol = "TCP";48 }49 ];50 }51 ];52 };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, apiserver, pods (all pods, excluding nodes and the API server), and all-pods (pods, nodes, and the API server). from accepts
all-pods, world, and apiserver, which admits the Kubernetes API server calling an admission
webhook or an aggregated API in the selected Pods. 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.
Example: ACME HTTP-01 solver pods
Section titled “Example: ACME HTTP-01 solver pods”cert-manager’s controller launches an HTTP-01 solver pod in the namespace of
each Certificate that an HTTP-01 issuer handles. For an Ingress that
kix.expose builds, Kix already admits the ingress controller to those pods.
A Certificate created another way gets no policy, so the namespace’s default
deny drops the ingress controller’s requests to its solver pods and the
challenge never validates. This intent admits them in every namespace:
1networkPolicy.platformIntents.acme-http01-solvers = {2 scope = "clusterwide";3 podSelector."acme.cert-manager.io/http01-solver" = "true";4 ingress = [5 {6 from = "all-pods";7 ports = [8 {9 port = 8089;10 protocol = "TCP";11 }12 ];13 }14 ];15};The selector is the label cert-manager sets on every solver pod, which the
cert-manager instance also publishes as out.operandSelectors.acmesolver.
Port 8089 is the port the solver listens on. The intent sets no
targetNamespace, because solver pods run wherever a certificate is
requested. The ingress controller must also be allowed to send traffic to the
solver pods; the ingress-nginx package declares egress to all pods for its
backends.
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, 3 warnings
scorecard pass 0 errors, 26 warnings, 5 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.
governance.hasOwner (warning), 1:
apps/client: package 'client' has no meta.owner
reliability.boundedResources (warning), 9:
apps/client/client: container 'client' 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 '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.
reliability.hasProbes (warning), 2:
apps/client/client: container 'client' has no livenessProbe
apps/client/client: container 'client' has no readinessProbe
security.nonRoot (warning), 1:
apps/client/client: container 'client' may run as root: neither it nor the pod sets securityContext.runAsNonRoot, and no non-zero runAsUser resolves for it
security.readOnlyRootfs (warning), 10:
apps/client/client: container 'client' does not set readOnlyRootFilesystem
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
5 info finding(s) not listed; run with -v to list them. 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"
}
}
}
}
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. 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.