Container privileges
Every container the Connectivity Gateway (CGW) chart renders gets the
capabilities its own work needs, and nothing beyond them. Where a container
needs more — an older image, a node that pre-loads nothing — or where a cluster
policy demands less, each container has an additionalSecurityContext value
that is merged over what the chart renders.
What the chart grants
The containers with no securityContext run on the capabilities the container
runtime grants by default. That set includes NET_BIND_SERVICE, which is why
charon can bind UDP/500 with NET_ADMIN alone, and NET_RAW, which is what
ping-prober pings with.
bird-config-watcher gets no capability, but runs with group 0. bird creates
its control socket as root:root with mode 0660, and connecting to a socket
needs write access to it. The group grants that access, while the container
keeps the image's non-root user.
ping-exporter, radvd and pcap state NET_RAW rather than relying on that
default, because the default is the runtime's to change and a cluster policy
can drop the capability from it. Each of them opens a socket that needs it: an
ICMP socket, an ICMPv6 socket, and the AF_PACKET socket of the capture, for
which no other capability substitutes. pcap is the clearest case — its
dumpcap carries cap_net_raw+eip as a file capability, and a file capability
only takes effect while the capability is in the container's bounding set.
debug is privileged on purpose — ip xfrm state and tcpdump on a
neighbour's traffic is the point of it. That also makes it a standing
escalation path in the pod, so keep debug.enabled: false outside of an
investigation.
init-script is privileged because the script is yours and the chart cannot
know what it does. A script that only configures interfaces runs with:
Overriding a container's securityContext
Every block that renders a container takes an additionalSecurityContext:
A key you set replaces the chart's, one level deeper for capabilities. So the
drop above keeps the NET_ADMIN the chart adds, while
states the whole set — the list is not appended to the chart's. The value is a
securityContext fragment; a bare list of capabilities is rejected with an
error naming the container.
The values are ipsec.additionalSecurityContext,
ipsec.initIp.additionalSecurityContext,
ipsec.initVti.additionalSecurityContext,
bird.additionalSecurityContext,
bird.birdConfigWatcher.additionalSecurityContext,
vrrp.additionalSecurityContext, pcap.additionalSecurityContext,
radvd.additionalSecurityContext, pingExporter.additionalSecurityContext,
gre.additionalSecurityContext, ipSetup.additionalSecurityContext,
iptables.additionalSecurityContext, initScript.additionalSecurityContext,
debug.additionalSecurityContext, vxlan.additionalSecurityContext and
vxlanController.additionalSecurityContext.
When init-vti needs more
init-vti creates the VTI interface with NET_ADMIN, but it also sets
net.ipv4.conf.<vti>.disable_policy=1 on it. Without that flag, packets that
have already been decapsulated match the IPsec policy a second time. /proc/sys
is mounted read-only in a container, so the write needs privileged: true
unless the value is set on the pod's network namespace from outside and
inherited by the interface, which requires one of:
-
pod
sysctls, if the node's kubelet allowsnet.ipv4.conf.default.disable_policyas an unsafe sysctl:yaml -
the CNI
tuningplugin in the network attachment the pod uses, which needs no node configuration:json
Either way default. applies to every interface created in that namespace
afterwards, not only the VTI.
Where neither is in place, or where ipsec.image.tag is a v1.5.x whose
entrypoint still runs modprobe ip_vti — that needs SYS_MODULE and the
/lib/modules mount — restore the previous behaviour with:
A VTI that was never created shows up as Cannot find device "vti<key>" in the
ipsec container, because the modprobe failure itself is silent.
Pod Security Standards
With debug and initScript disabled and init-vti reduced as above, the
pod's containers hold NET_ADMIN and nothing else. That is still above the
baseline standard, which forbids adding any capability except
NET_BIND_SERVICE, so a namespace enforcing baseline or restricted cannot
run the gateway: configuring links and installing XFRM policies is what the
gateway does.