Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,27 @@ jobs:
hack/service-api-bundle.sh ci dist
cd dist && sha256sum -c SHA256SUMS

# The opt-in Kustomize Components that must be listed in order fail their
# build when one is missing; tests/manifests renders each composition.
manifests:
name: Manifests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7

- uses: actions/setup-go@v7
with:
go-version: ${{ env.GO_VERSION }}

- uses: arduino/setup-task@v3.0.0
with:
version: ${{ env.TASK_VERSION }}
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Render the Component fixtures
run: task test:manifests

# Tier 2: Integration tests (every PR, main branch, and releases)
test-e2e:
name: E2E Tests
Expand Down
32 changes: 32 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ vars:
[ -n "$gobin" ] && echo "$gobin" || echo "$(go env GOPATH)/bin"
GOLANGCI_LINT: '{{.LOCALBIN}}/golangci-lint'
YAMLFMT: '{{.LOCALBIN}}/yamlfmt'
KUSTOMIZE: '{{.LOCALBIN}}/kustomize'
GO_LICENSES: '{{.LOCALBIN}}/go-licenses'
GOLANGCI_LINT_VERSION: v2.12.2
YAMLFMT_VERSION: v0.21.0
KUSTOMIZE_VERSION: v5.8.1
GO_LICENSES_VERSION: v1.6.0
PROMETHEUS_VERSION: v3.15.0
tasks:
Expand Down Expand Up @@ -203,6 +205,27 @@ tasks:
- mkdir -p {{.GOBGP_BIN}}
- CGO_ENABLED=0 GOBIN={{.GOBGP_BIN}} go install github.com/osrg/gobgp/v4/cmd/gobgpd@v4.10.0 github.com/osrg/gobgp/v4/cmd/gobgp@v4.10.0
- go run ./hack/fabric-api-loadtest --mrt {{.MRT}} --gobgp-bin {{.GOBGP_BIN}} {{.CLI_ARGS}}
test:manifests:
desc: Render the opt-in Component fixtures in tests/manifests
# Every fixture under tests/manifests/fabric-api composes Components the
# way a cell overlay does and must build; every fixture under
# tests/manifests/invalid omits a Component another requires and must
# fail to build.
deps: [kustomize]
cmds:
- |
status=0
for dir in tests/manifests/fabric-api/*/; do
if ! {{.KUSTOMIZE}} build "$dir" > /dev/null; then
echo "FAIL: $dir does not build"; status=1
fi
done
for dir in tests/manifests/invalid/*/; do
if {{.KUSTOMIZE}} build "$dir" > /dev/null 2>&1; then
echo "FAIL: $dir builds, but omits a required Component"; status=1
fi
done
exit $status
test:alerts:
desc: Unit-test the alert rules in config/monitoring/ with promtool
# promtool reads plain rule files, so the PrometheusRule's spec is
Expand Down Expand Up @@ -252,6 +275,15 @@ tasks:
TARGET: '{{.GOLANGCI_LINT}}'
PACKAGE: github.com/golangci/golangci-lint/v2/cmd/golangci-lint
VERSION: '{{.GOLANGCI_LINT_VERSION}}'
kustomize:
desc: Download kustomize if needed
run: once
cmds:
- task: install-tool
vars:
TARGET: '{{.KUSTOMIZE}}'
PACKAGE: sigs.k8s.io/kustomize/kustomize/v5
VERSION: '{{.KUSTOMIZE_VERSION}}'
yamlfmt:
desc: Download yamlfmt if needed
run: once
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- op: add
path: /spec/template/spec/containers/0/args/-
value: --aggregate-budgets
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Turns on the cell's aggregate admission and probe packet budgets in the
# fabric-api gateway (--aggregate-budgets). Include it from the per-cell
# gateway overlay of config/fabric-api/base:
#
# resources:
# - ../../config/fabric-api/base
# components:
# - ../../config/fabric-api/components/aggregate-budgets
#
# Apply it only once every node's sidecar verifies probe permits
# (config/fabric-router/components/fabric-api-permits): the gateway sends a
# probe to no other node. From then on every probe in the cell, operator,
# FabricQuery and Looking Glass, is charged to the cell's budgets, and each
# gateway start or failover refuses probes for 125 seconds while the leader
# serves its recovery hold. The limits are the contract's defaults; an
# overlay may lower any of them with the gateway's limit flags, never raise
# one. See docs/fabric-api/configuration.md#aggregate-probe-budgets.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
patches:
- path: deployment-patch.yaml
target:
kind: Deployment
name: fabric-api-gateway
12 changes: 12 additions & 0 deletions config/fabric-api/components/service/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# The Looking Glass service switch. Only the exact value "enabled" turns
# execution on; "disabled", a missing key or ConfigMap, an unreadable one or
# any other value keeps it off. Each gateway replica reads it every second.
apiVersion: v1
kind: ConfigMap
metadata:
name: fabric-api-service
namespace: galactic-system
annotations:
kustomize.toolkit.fluxcd.io/ssa: IfNotPresent
data:
service: disabled
12 changes: 12 additions & 0 deletions config/fabric-api/components/service/deployment-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Tests that components/aggregate-budgets came first: the service executes
# only under the cell's aggregate budgets, and the gateway refuses
# --service-config-map without them.
- op: test
path: /spec/template/spec/containers/0/args/1
value: --aggregate-budgets
- op: add
path: /spec/template/spec/containers/0/args/-
value: --service-config-map=fabric-api-service
- op: add
path: /spec/template/spec/containers/0/args/-
value: --service-identities=looking-glass
38 changes: 38 additions & 0 deletions config/fabric-api/components/service/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Wires the Looking Glass service into the fabric-api gateway: the service
# identities it accepts and the fabric-api-service ConfigMap whose key
# "service" turns execution on ("enabled") or off ("disabled") while the
# gateway runs, without a restart. List it after
# components/aggregate-budgets, which it requires; the build fails without
# it:
#
# resources:
# - ../../config/fabric-api/base
# components:
# - ../../config/fabric-api/components/aggregate-budgets
# - ../../config/fabric-api/components/service
#
# The ConfigMap ships with execution off. Flux creates it once and never
# overwrites it (kustomize.toolkit.fluxcd.io/ssa: IfNotPresent), so the
# value in the cluster is the switch an operator turns with kubectl, and a
# reconcile never turns the service back on after an emergency stop.
# Each replica reads it every second. Once the leader reads "disabled", it
# cancels running Looking Glass requests within 2 seconds and refuses new
# ones with ServiceDisabled; operator and FabricQuery work and the
# limiter's state are untouched. See
# docs/fabric-api/configuration.md#operating-the-looking-glass-service.
#
# Prerequisites: every node requires probe permits
# (config/fabric-router/components/fabric-api-require-permits), so direct
# operator probes are charged too, and the cell's fabric-api Issuer issues
# the service certificate. Replace looking-glass in --service-identities
# when the service's certificate names another service.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
resources:
- configmap.yaml
- rbac.yaml
patches:
- path: deployment-patch.yaml
target:
kind: Deployment
name: fabric-api-gateway
26 changes: 26 additions & 0 deletions config/fabric-api/components/service/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# The gateway reads the service switch, and nothing else among the
# namespace's ConfigMaps.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: fabric-api-gateway-service
namespace: galactic-system
rules:
- apiGroups: [""]
resources: ["configmaps"]
resourceNames: ["fabric-api-service"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: fabric-api-gateway-service
namespace: galactic-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: fabric-api-gateway-service
subjects:
- kind: ServiceAccount
name: fabric-api-gateway
namespace: galactic-system
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fabric-router
namespace: galactic-system
spec:
template:
spec:
containers:
- name: fabric-api
args:
- node
- --probe-permits
volumeMounts:
- name: kube-api-access
mountPath: /var/run/secrets/kubernetes.io/serviceaccount
readOnly: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Makes each node's fabric-api sidecar verify the cell gateway's probe
# permits (--probe-permits). List it after components/fabric-api, which it
# requires; the build fails without it:
#
# resources:
# - ../../config/fabric-router
# components:
# - ../../config/fabric-router/components/fabric-api
# - ../../config/fabric-router/components/fabric-api-permits
#
# The sidecar then reads the gateway's election Lease (fabric-api-gateway in
# galactic-system) to check each permit's epoch, so it gets the
# fabric-router ServiceAccount's token and a Role allowing get on that one
# Lease. It accepts a permit once, sends nothing past its packets or
# deadline, refuses every permit for 32 seconds after it starts and while
# its host's clock is unsynchronised, and reports probePermits in Info,
# which the gateway requires before it sends a node a probe under
# --aggregate-budgets. A probe without a permit still runs.
#
# Applying it changes the pod template, so every fabric-router pod restarts
# and FRR with it: roll it out as a routing change (one canary node, check
# underlay sessions and convergence, then paced expansion). See
# docs/fabric-api/configuration.md#enabling.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
resources:
- rbac.yaml
patches:
- path: daemonset-patch.yaml
# Fails the build unless components/fabric-api, which adds this
# DaemonSet, came first; it changes nothing.
- patch: |-
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fabric-api-certs
namespace: galactic-system
26 changes: 26 additions & 0 deletions config/fabric-router/components/fabric-api-permits/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# The sidecar reads the gateway's election Lease, uncached, to check each
# probe permit's epoch, and reads nothing else.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: fabric-api-node-lease
namespace: galactic-system
rules:
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
resourceNames: ["fabric-api-gateway"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: fabric-api-node-lease
namespace: galactic-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: fabric-api-node-lease
subjects:
- kind: ServiceAccount
name: fabric-router
namespace: galactic-system
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fabric-router
namespace: galactic-system
spec:
template:
spec:
containers:
- name: fabric-api
args:
- node
- --probe-permits
- --require-probe-permits
- --gateway-address=fabric-api-gateway.galactic-system.svc:9346
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Makes each node's fabric-api sidecar refuse a probe without a permit
# (--require-probe-permits). A probe an operator sends a node directly
# first obtains a permit from the cell gateway's Service, charged to that
# operator, so every probe in the cell counts against the aggregate budgets;
# the Looking Glass service must not be enabled before this. List it after
# components/fabric-api-permits, which it requires; the build fails without
# it:
#
# resources:
# - ../../config/fabric-router
# components:
# - ../../config/fabric-router/components/fabric-api
# - ../../config/fabric-router/components/fabric-api-permits
# - ../../config/fabric-router/components/fabric-api-require-permits
#
# Apply it only once the gateway runs with --aggregate-budgets
# (config/fabric-api/components/aggregate-budgets): without a gateway
# issuing permits, every probe on these nodes is refused. Like
# components/fabric-api-permits, applying it restarts FRR on every node: roll
# it out as a routing change. See docs/fabric-api/configuration.md#enabling.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
patches:
- path: daemonset-patch.yaml
# Fails the build unless components/fabric-api-permits, which adds this
# Role, came first; it changes nothing.
- patch: |-
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: fabric-api-node-lease
namespace: galactic-system
25 changes: 17 additions & 8 deletions docs/designs/looking-glass-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ schemas and result meanings. FabricQuery retains its existing persistence and
resume semantics; customer requests have no such persistence or replay.

Today, `api/fabric/v1/fabric.proto` exposes only unary methods. The gateway
authenticates service identities and validates their requests (#1043). With
`gateway.Service.Enabled` set, the leader streams a request as specified under
authenticates service identities and validates their requests (#1043). While
its `gateway.Service.Switch` is on, the leader streams a request as specified under
"Stream grammar and coverage": `Discoverer.Inventory` takes the unique-router
snapshot, `Runner.Stream` hands off each router's outcome as it finishes, and
the terminal coverage follows (#1044). With the gateway's `--aggregate-budgets`,
Expand All @@ -39,16 +39,24 @@ nodes run with `--probe-permits` verify each probe's permit (#1045). Execution
requires the gateway's admission, and capabilities advertise
`aggregate-probe-budgets` only while execution is enabled with it. Nodes
charge direct operator probes only with `--require-probe-permits`, so enabling
execution requires every node to run with it. No deployment sets `Enabled` or
these flags, so a valid `RunDiagnostic` is answered with `ServiceDisabled`.
execution requires every node to run with it. Opt-in Kustomize Components set
these flags, and the gateway's `--service-config-map` names the ConfigMap
whose `service` key switches execution on and off at run time (#1047); it
ships off, so a valid `RunDiagnostic` is answered with `ServiceDisabled` until
an operator switches it on.
The delivery and transport bounds under "Cancellation, delivery, and failure
assumptions" are enforced (#1046): one writer per stream, the 2 s write and
hand-off bound on the leader and on a forwarding follower, the per-outcome and
per-stream output caps, the per-replica call and service connection caps,
fixed 64 KiB windows and buffers, and keepalive on the gateway listener
(`internal/fabric/gateway/stream.go`). A shutdown signal stops the listener at
once. Service disable is a startup setting until #1047 adds its controls, and
the metrics and packaged configuration are #1047's. Operator and FabricQuery
once. Switching the service off cancels its running requests within the 2 s
bound without a restart. The limits are gateway flags that may only lower
the defaults below; the gateway refuses to start on any other value, and
the leader and nodes fail closed while the kernel clock is unsynchronised
within 500 ms. [operations.md](../fabric-api/operations.md#operating-the-looking-glass-service)
documents the switch, the limit flags, the metrics, the alerts and the
upgrade and rollback order. Operator and FabricQuery
discovery still return pod candidates, including duplicates.

## Service and identity
Expand Down Expand Up @@ -651,8 +659,9 @@ an operator explicitly returns to legacy policy. Removing permit enforcement
must not leave a service advertising aggregate guarantees.

No service endpoint is exposed publicly by this contract. Configure it alongside
the internal gateway listener with distinct method authorization. #1047 defines
validated configuration keys and operational commands from these semantics.
the internal gateway listener with distinct method authorization. Its
validated configuration keys and operational commands are in
[operations.md](../fabric-api/operations.md#operating-the-looking-glass-service).
Metrics use bounded labels (operation, reason, traffic class, limiter scope),
never project IDs, request IDs, destinations, node UIDs, or result contents.
Routine logs may contain sanitized attempt metadata but not diagnostic output,
Expand Down
Loading
Loading