External destinations
About 974 words
Under the default deny, a pod reaches nothing outside the cluster until the catalog says where that something is. specht-labs.de/cilium-dst does that, on the API, Component or Resource that lives outside. This guide covers the forms it takes and where the plugin looks for it. The examples come from docs/examples/prod.
The forms
| Value | Renders to | Use it for |
|---|---|---|
fqdn:api.github.com | toFQDNs: [{matchName: api.github.com}] | a service with a stable name and changing addresses |
fqdn:*.cdn.example.com | toFQDNs: [{matchPattern: "*.cdn.example.com"}] | every name one label below a domain |
cidr:203.0.113.0/24 | toCIDR: [203.0.113.0/24] | fixed addresses: a data centre, a load balancer, an office; IPv6 ranges work too |
entity:kube-apiserver | toEntities: [kube-apiserver] | what Cilium already has a name for, such as the API server or world |
none | nothing | something that isn't reached over the network at all |
Several values are comma-separated, and each gets a rule of its own. Catalog references and * aren't accepted: cilium-dst says where something outside the cluster is, not who it is. Peer syntax has the exact grammar.
Where the plugin looks
| Flow | cilium-dst from | Ports from |
|---|---|---|
Component consumesApi API, no provider on the cluster | the API | the API's cilium-ports |
the same, and the API has no cilium-dst | each provider of the API | the API's cilium-ports, else the provider's |
endpoint dependsOn a Component or Resource without pods on the cluster | the dependency | the dependency's cilium-ports |
a rule entity names, in to, an entity without pods on the cluster | that entity | the rule's ports |
Pods on the cluster always win: an API whose provider runs on the cluster is reached at the provider's pods, whatever cilium-dst says.
A DNS name
payments-api is reached at one name, and its assets come from a CDN with many:
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: payments-api
annotations:
specht-labs.de/cilium-dst: fqdn:api.payments.example.com, fqdn:*.cdn.payments.example.com
specht-labs.de/cilium-ports: tcp:443
spec:
type: openapi
lifecycle: production
owner: group:shop
definition: '{}'The shop consumes it, so its policy gets two egress rules:
egress:
# to fqdn:api.payments.example.com
# component:shop consumes api:payments-api
- toFQDNs:
- matchName: api.payments.example.com
toPorts:
- ports:
- port: "443"
protocol: TCP
# to fqdn:*.cdn.payments.example.com
# component:shop consumes api:payments-api
- toFQDNs:
- matchPattern: "*.cdn.payments.example.com"
toPorts:
- ports:
- port: "443"
protocol: TCPCilium matches *.cdn.payments.example.com against exactly one label: img.cdn.payments.example.com, but neither cdn.payments.example.com nor a.b.cdn.payments.example.com. Cilium also knows a **. prefix for any depth, but the plugin doesn't accept it; list the levels you need instead. fqdn:* on its own matches every name, which is rarely what you want.
FQDN rules only work if Cilium sees the pod's DNS lookups. The default-deny policy sends every pod's DNS through Cilium's DNS proxy for that reason; FQDN rules and the DNS proxy explains how, and what to check if a name doesn't resolve to an allowed address.
An address range
component:billing runs in a data centre with fixed addresses. The shop consumes billing-api, which has no cilium-dst of its own, so the provider's counts:
egress:
# to cidr:203.0.113.0/24
# component:shop consumes api:billing-api
- toCIDR:
- 203.0.113.0/24
toPorts:
- ports:
- port: "8443"
protocol: TCPA load balancer address works the same way. Cluster API, in the example, reaches the API server of the cluster it manages through that cluster's control-plane load balancer; to Cilium that's just an address outside the cluster (world), so it's a cidr::
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: workload-cluster-api
title: The workload cluster's control-plane load balancer
annotations:
specht-labs.de/cilium-dst: cidr:198.51.100.10/32
specht-labs.de/cilium-ports: tcp:6443
spec:
type: load-balancer
owner: group:platformegress:
# to cidr:198.51.100.10/32
# component:cluster-api depends on resource:workload-cluster-api
- toCIDR:
- 198.51.100.10/32
toPorts:
- ports:
- port: "6443"
protocol: TCPA Cilium entity
The cluster's own API server isn't a pod you can select, and its addresses differ from cluster to cluster. Cilium calls it kube-apiserver. Model it as an API once, and let every operator and controller consume it:
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: kubernetes-api
annotations:
specht-labs.de/cilium-dst: entity:kube-apiserver
specht-labs.de/cilium-ports: tcp:6443
spec:
type: openapi
lifecycle: production
owner: group:platform
definition: '{}'egress:
# to entity:kube-apiserver
# component:cert-manager consumes api:kubernetes-api
- toEntities:
- kube-apiserver
toPorts:
- ports:
- port: "6443"
protocol: TCPThe port is the one the API server listens on, after the kubernetes Service's translation: 6443 on most clusters, not the Service's 443. Check yours with kubectl get endpointslices -l kubernetes.io/service-name=kubernetes.
Not a network destination
Some dependencies aren't reached over the network at all. external-dns depends on the DNS zone it manages, but it talks to the DNS provider's API, not to the zone:
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: shop-zone
title: shop.example.com
annotations:
specht-labs.de/cilium-dst: none
spec:
type: dns-zone
owner: group:platformnone gives no flow, and keeps the policy from noting that the dependency might be reached over the network. It must be the only value.
When something is missing
| Message | Meaning |
|---|---|
consumes api:…, which doesn't run on resource:… and has no specht-labs.de/cilium-dst: not allowed (warning) | Neither the API nor its providers say where they are. Add a cilium-dst. |
depends on …, outside resource:…: if it is reached over the network, give it specht-labs.de/cilium-dst (info) | A dependency without pods and without cilium-dst. Add one, or none. |
specht-labs.de/cilium-dst: …: only entity:, cidr: and fqdn: say where something outside the cluster is (error) | A catalog reference or * in cilium-dst. |
Diagnostics lists them all.
