Extra sources
About 728 words
Relations say who uses what inside the catalog. Some traffic comes from outside it: the internet reaching a gateway, the API server calling an admission webhook. specht-labs.de/cilium-allow on the destination names those sources. The examples come from docs/examples/prod.
Where it goes
| On | Lets the sources reach | On the ports |
|---|---|---|
| a Component or Resource with pods on the cluster | its pods | its cilium-ports |
| an API whose providers run on the cluster | each provider's pods | the API's cilium-ports, else each provider's |
On an API without providers on the cluster, cilium-allow does nothing: there are no pods to let anyone into. Like the relations, it only counts while the policy's spec.catalogRules is true.
The sources
| Value | Means |
|---|---|
entity:world | anything outside the cluster |
entity:kube-apiserver, entity:remote-node, entity:host, … | a Cilium entity |
cidr:192.0.2.0/24 | addresses |
component:tailscale-operator, resource:… | that entity's pods, if it has pods on the cluster |
api:… | the pods of that API's providers on the cluster |
* | every endpoint of the policy |
Several values are comma-separated. A catalog reference needs its kind (component:x, not x); without a namespace it takes the annotated entity's. fqdn: isn't accepted, since a DNS name can only be a destination. A catalog entity without pods on the cluster gives no flow, with a warning.
The internet into a gateway
The edge gateway is where outside traffic enters the cluster:
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: edge
title: Edge gateway
annotations:
backstage.io/kubernetes-namespace: gateways
backstage.io/kubernetes-label-selector: gateway.networking.k8s.io/gateway-name=edge
specht-labs.de/cilium-ports: tcp:10443
specht-labs.de/cilium-allow: entity:world
spec:
type: gateway
owner: group:platform
dependsOn: [resource:prod, component:envoy-gateway]ingress:
# from entity:world
# allowed by resource:edge (specht-labs.de/cilium-allow)
- fromEntities:
- world
toPorts:
- ports:
- port: "10443"
protocol: TCPThe port is the one the gateway's pods listen on, which is often not the 443 the load balancer shows the world. A cloud load balancer that keeps the client's address delivers the traffic as world; one that doesn't may deliver it from a node, as remote-node or host. Look at a dropped or audited flow to find out which.
The API server into a webhook
The API server calls admission webhooks, and cert-manager runs one. You'd expect the call to come from kube-apiserver, but on many clusters it comes from the node's address and Cilium identifies it as remote-node. Allow both:
metadata:
name: cert-manager
annotations:
backstage.io/kubernetes-namespace: cert-manager
specht-labs.de/cilium-selector: '*'
specht-labs.de/cilium-ports: tcp:10250
specht-labs.de/cilium-allow: entity:kube-apiserver, entity:remote-nodeingress:
# from entity:kube-apiserver
# allowed by component:cert-manager (specht-labs.de/cilium-allow)
- fromEntities:
- kube-apiserver
toPorts:
- ports:
- port: "10250"
protocol: TCP
# from entity:remote-node
# allowed by component:cert-manager (specht-labs.de/cilium-allow)
- fromEntities:
- remote-node
toPorts:
- ports:
- port: "10250"
protocol: TCPCilium identities you'll meet explains why.
The ports here are cert-manager's cilium-ports, which apply to every flow into it. If one port should be open to the API server and another to an in-cluster client, put each on an API that cert-manager provides, with its own cilium-ports and cilium-allow: an API's ports win over its provider's.
The internet into anything else
A TURN relay takes calls directly from clients on the internet, without a gateway in front:
metadata:
name: turn
title: TURN relay
annotations:
backstage.io/kubernetes-namespace: turn
backstage.io/kubernetes-label-selector: app=coturn
specht-labs.de/cilium-ports: tcp:3478, udp:*
specht-labs.de/cilium-allow: entity:worldingress:
# from entity:world
# allowed by component:turn (specht-labs.de/cilium-allow)
- fromEntities:
- world
toPorts:
- ports:
- port: "0"
protocol: UDP
- port: "3478"
protocol: TCPudp:* is every UDP port; Ports and metrics has the syntax.
When to use a rule entity instead
cilium-allow lives on the destination, so whoever owns the destination decides who reaches it. That fits sources the destination's owner knows about. When the source decides, such as a probe that checks many services, or an operator that manages instances in other namespaces, write a rule entity: it names both ends, and it lives with the policy.
