Skip to content

Cilium for BackstageYour cluster's network policy, rendered from the software catalog

The catalog already says which Component consumes which API and which Resources an app depends on. Backstage turns that into a default deny and one CiliumClusterwideNetworkPolicy per workload, each rule commented with the catalog fact behind it, and keeps a pull request open with the manifests.

What the plugins do

Four npm packages for the new backend and frontend systems of Backstage.

Hand-written network policies vs. the catalog

The same cluster, kept two ways.

A NetworkPolicy per app, by hand

Written once, rarely revisited

  • •
    Policies drift from the code
    A service starts calling a new API and nobody updates the policy, until the default deny drops the traffic
  • •
    Both ends must agree
    An egress on the client and an ingress on the server, often in two repositories owned by two teams
  • •
    No record of why
    A rule from 2023 allows port 8443 to a CIDR; nobody knows what for
  • •
    Default deny stays off
    Nobody is sure what would break

Cilium for Backstage

Rendered from entities, reviewed as a pull request

  • •
    Policies follow the catalog
    A new consumesApi is a new allow on both ends
  • •
    One fact, two rules
    The consumer's egress and the provider's ingress come from the same relation
  • •
    Every rule is explained
    Its comment names the relation, annotation or rule entity
  • •
    Problems are listed
    A relation the policy can't turn into a flow is a warning in the console and in the pull request

A flow, start to finish

A Component consumes an API. Another Component provides it, and both run on the cluster. Backstage allows the flow on both ends.

  1. Say where the pods are, and on which port the API is reached

    apiVersion: backstage.io/v1alpha1
    kind: Component
    metadata:
      name: shop
      annotations:
        backstage.io/kubernetes-namespace: shop
        backstage.io/kubernetes-label-selector: app=shop
    spec:
      type: service
      lifecycle: production
      owner: group:shop
      consumesApis: [orders-api]
      dependsOn: [resource:prod]
    ---
    apiVersion: backstage.io/v1alpha1
    kind: Component
    metadata:
      name: orders
      annotations:
        backstage.io/kubernetes-namespace: orders
        backstage.io/kubernetes-label-selector: app=orders
    spec:
      type: service
      lifecycle: production
      owner: group:orders
      providesApis: [orders-api]
      dependsOn: [resource:prod]
    ---
    apiVersion: backstage.io/v1alpha1
    kind: API
    metadata:
      name: orders-api
      annotations:
        specht-labs.de/cilium-ports: tcp:9000
    spec:
      type: grpc
      lifecycle: production
      owner: group:orders
      definition: 'syntax = "proto3";'
  2. Name the cluster in a policy entity

    apiVersion: specht-labs.de/v1alpha1
    kind: Cilium
    metadata:
      name: prod
    spec:
      type: policy
      owner: group:platform
      cluster: resource:prod
  3. Backstage renders the allow on the provider's side (and the matching egress on the consumer's)

    apiVersion: cilium.io/v2
    kind: CiliumClusterwideNetworkPolicy
    metadata:
      name: allow-component-orders
    # ...
    spec:
      endpointSelector:
        matchLabels:
          io.kubernetes.pod.namespace: orders
          app: orders
      enableDefaultDeny:
        ingress: false
        egress: false
      ingress:
        # from component:shop
        #   component:shop consumes api:orders-api
        - fromEndpoints:
            - matchLabels:
                io.kubernetes.pod.namespace: shop
                app: shop
          toPorts:
            - ports:
                - port: "9000"
                  protocol: TCP

Your first policy builds this example in full, and Flows from relations covers every relation the plugin reads.

Not affiliated with Isovalent or Cisco

This is a community plugin by SpechtLabs. It is not made, endorsed or supported by Isovalent or Cisco. "Cilium" is a trademark of its owners.

Contributors

Your contributions matter. Here's to everyone who's helped bring this to life.