Standard K8s NetworkPolicy ipBlock rules don't work under Cilium for the API server — the except clause on 192.168.1.0/24 blocks the post-DNAT destination even when a separate rule re-allows the subnet. Cilium's native kube-apiserver entity tracks API server endpoints regardless of ClusterIP vs node-IP routing. Replaces: ipBlock 192.168.1.0/24:6443 (broken under Cilium) With: CiliumNetworkPolicy toEntities: kube-apiserver (works)
26 lines
807 B
YAML
26 lines
807 B
YAML
# CiliumNetworkPolicy for kube-apiserver access.
|
|
#
|
|
# Standard K8s NetworkPolicy ipBlock rules don't work for the API server
|
|
# under Cilium — the except clause on 192.168.1.0/24 blocks the post-DNAT
|
|
# destination even when a separate rule re-allows a /32 or subnet.
|
|
#
|
|
# Cilium's native `kube-apiserver` entity resolves this correctly: it
|
|
# tracks the API server endpoints regardless of ClusterIP vs node-IP
|
|
# routing, so the policy stays valid across node changes and NAT paths.
|
|
apiVersion: cilium.io/v2
|
|
kind: CiliumNetworkPolicy
|
|
metadata:
|
|
name: {{ .Release.Name }}-apiserver
|
|
namespace: {{ .Release.Namespace }}
|
|
spec:
|
|
endpointSelector:
|
|
matchLabels:
|
|
app: {{ .Release.Name }}
|
|
egress:
|
|
- toEntities:
|
|
- kube-apiserver
|
|
toPorts:
|
|
- ports:
|
|
- port: "6443"
|
|
protocol: TCP
|