Place in the stack
Krane runs in each Kubernetes cluster. It is the only service in this stack with direct Kubernetes API credentials, which keeps cluster access isolated to Krane.Service boundaries
Krane only talks to three systems.- Upstream: control plane streams desired state and receives status updates
- Downstream: Kubernetes API server for creating, updating, and watching resources
- Sidecar dependency: Vault for secrets decryption when enabled
Core responsibilities
Krane is built around these core responsibilities.- Reconcile user workloads as Kubernetes ReplicaSets
- Install a per-deployment Cilium network policy that admits Frontline ingress
- Report actual state for workloads upstream
- Decrypt workload secrets using Vault when enabled
Control plane interface
Krane connects upstream with a Connect RPC client that keeps long-running streams open. It injects theAuthorization: Bearer <token> header on every request and stamps a ClusterKey (cell ID, platform, and region) on every request proto message. h2c is supported for non-TLS URLs.
Reconciliation model
Control loops
Krane consumes a singleWatchDeploymentChanges stream from the control plane and dispatches each event to the deployment controller. The stream reconnects with jittered backoff between one and five seconds. A version cursor advances only after a state is applied successfully, which makes stream replay safe.
Deployment controller
The deployment controller manages user workloads as Kubernetes ReplicaSets. It runs three loops.- Desired state apply loop consumes deployment events from
WatchDeploymentChangesand applies or deletes ReplicaSets - Actual state report loop watches ReplicaSet events and reports status to the control plane
- Resync loop runs every minute and corrects drift by re-reading desired state
Kubernetes resource model
Krane uses server-side apply for all Kubernetes resources and labels everything it manages. Labels includeapp.kubernetes.io/managed-by=krane and a component label for selection.
Deployments
User workloads are represented as ReplicaSets with the following characteristics.- Namespaces are created on demand
- Pods run with
RuntimeClassName: gvisorfor isolation - Pods select and tolerate
node-class=untrustednodes - Topology spread keeps replicas balanced across zones
- Pod affinity prefers zones already running pods with the environment’s sentinel component label (
ComponentSentinel). This is a soft preference inherited from the sentinel proxy layer; since that layer merged into Frontline and no pods carry the label, the affinity currently matches nothing - Env vars include
PORT,UNKEY_DEPLOYMENT_ID,UNKEY_ENVIRONMENT_SLUG,UNKEY_REGION,UNKEY_INSTANCE_ID, and theUNKEY_GIT_*set (commit SHA, branch, repo, commit message) - A
commandoverride from the deployment spec replaces the image entrypoint when set; otherwise the image’sENTRYPOINT/CMDruns - Decrypted environment variables are mounted from a per-deployment K8s Secret via
envFrom.secretRef - Healthchecks map to HTTP probes, and POST uses an exec probe with
wget - Optional preStop hook sends non-SIGTERM shutdown signals
Cilium network policies
When the deployment controller applies a deployment, it also installs a<deployment>-frontline-ingress CiliumNetworkPolicy in the deployment’s namespace. Cilium default-deny applies to any endpoint a policy selects, so this policy is what admits ingress: it permits Frontline pods to reach the deployment’s pods on the container port, and nothing else. Krane builds the policy from the deployment spec and applies it with the dynamic client using server-side apply. The policy is owned by the ReplicaSet, so Kubernetes garbage-collects it when the deployment is deleted.