mira-operator¶
The controller that scales a Mira tier on free disk, and drains a replica's blocks to cold storage before its volume is deleted. Install it, then apply a MiraCluster.
This is the only chart Mira publishes. There used to be a second one that
installed a StatefulSet directly, and it was removed rather than kept beside
this: two charts is two answers to "how do I run Mira on Kubernetes", and the
one that cannot scale, cannot drain and cannot be told a ceiling is the wrong
answer to ship as the default. A tier is a MiraCluster now.
Why not an HPA¶
Mira has no metric that moves when it needs another replica.
Section 11 measures
2.23 of twelve cores at 1,537,875 records/s — a CPU-target HPA reads
single-digit utilisation at saturation, and a memory-target one reads page
cache, which is the mmap working as designed. The quantity that actually runs
out is disk, and an HPA has never been able to scale a StatefulSet on its
own volumes filling.
So the trigger is free_fraction from /api/v1/stats, and something has to
read it. That something also has to sequence a scale-in, which an HPA could
never do safely: the volume about to be deleted holds blocks no other replica
has, because nothing replicates and nothing rebalances.
Does this break "no coordination state"?¶
No, and the distinction is worth being precise about. Principle 4 says Mira holds no coordination state — no Raft, no membership, no external metadata store, the block directory is the manifest. A controller is not Mira.
The test is what happens when you delete this Deployment: every Mira pod keeps ingesting, keeps serving queries and keeps its blocks readable, because none of them ever asked the operator anything. Only the scaling stops. That is the line between a coordinator and coordination state — and it is the same delegation the engine already makes to the platform for pod identity and volume lifecycle.
Install¶
helm install mira-operator oci://ghcr.io/trianalab/charts/mira-operator \
--version 0.3.0 \
--namespace mira-system --create-namespace
The CRD ships in crds/, so Helm installs it on first install and never
upgrades or deletes it. That is Helm's rule, not this chart's. This matters
more here than it usually does: the API server prunes a field the CRD does
not declare rather than rejecting it, so a MiraCluster written against a newer
schema than the cluster holds loses those fields silently, with no error
anywhere. On a chart upgrade that changes the schema, apply the CRD yourself
first, or pull it out of the chart you are about to install:
helm pull oci://ghcr.io/trianalab/charts/mira-operator \
--version 0.3.0 --untar
kubectl apply -f mira-operator/crds/miraclusters.yaml
Not a raw.githubusercontent.com URL at a tag, which is the obvious thing to
write and would 404: the chart is versioned independently of the engine and
there is no v0.3.0 tag on the repository. helm
pull also gets you the CRD from the exact artifact you are installing rather
than from whatever the branch says today.
Then create a tier:
apiVersion: mira.miradb.dev/v1alpha1
kind: MiraCluster
metadata:
name: telemetry
spec:
image: ghcr.io/trianalab/mira:0.4.5
replicas: 1 # floor
maxReplicas: 5 # ceiling; there is no "unbounded"
storage:
size: 50Gi
className: gp3
# Unset is BestEffort. The drain Job inherits this: same binary, same volume.
resources:
requests:
cpu: 2500m
memory: 2048Mi
scaling:
upWhenFreeBelow: 0.15
downWhenFreeAbove: 0.60
cooldownSeconds: 600
offload: "file:///cold/${node}"
coldStorageClaim: mira-cold
proxy:
replicas: 2
How scaling decides¶
Read from every replica each reconcile, then:
- Out when the fullest replica drops below
upWhenFreeBelow. The fullest, not the mean:routesends a resource tohash(resource) % nand resources are not the same size, so a mean of 0.4 across ten replicas is compatible with one at 0.02 — and it is the one at 0.02 that stops accepting writes. - In when every replica is above
downWhenFreeAbove. Every, not the mean, because the drained replica's share lands on whoever is left. - Neither if any replica is unreachable, or answered
nullforfree_fraction— which is Mira saying it could notstatfsits own volume. Read as 0 that means "scale out"; read as 1 it means "delete a volume". It must mean neither.
The two thresholds must not meet. Adjacent thresholds oscillate, each action
creating the condition for its opposite, and every cycle moves a whole
replica's dataset through offload push. The operator refuses such a spec and
reports Degraded rather than acting on it.
What a scale-in actually does¶
spec.offload is required before the operator will ever shrink a tier, and
unset it never does. The cost of not shrinking is a bill; the cost of
shrinking without an archive is the data.
It never travels alone. file:// is the only scheme Mira's offload target
parses, so the archive is a mount and spec.coldStorageClaim names the claim to
put there — an existing ReadWriteMany claim, or ReadWriteOnce on a
single-node cluster. Without it the drain Job writes the archive inside its own
container, exits 0, and the claim is deleted anyway, so the operator refuses the
pair rather than documenting it.
status.drainingis written first, so a controller that restarts mid-sequence resumes instead of orphaning a volume.- The StatefulSet scales down. The pod goes; the claim stays.
- A Job runs
mira offload pushagainst the released claim. This is why the pod has to go first — the claim isReadWriteOnceand a Job cannot attach it while the pod holds it. - Only on success, the claim is deleted.
A failed drain stops at step 3 with the claim intact and the phase Degraded:
the tier is one replica smaller and every block is still on disk.
It does not re-home the blocks¶
offload push copies to the cold store and the blocks stay there, queryable
again only after a deliberate mira offload restore. That is
section 12.4's
"No rebalancing, ever" rather than an omission — and the same ReadWriteOnce
constraint that forced the order above forbids the reverse: a restore has to
mount a surviving replica's volume, which its running pod holds. Automating it
would mean taking a healthy replica down to grow it.
Permissions¶
One ClusterRole, no wildcards, and delete on exactly three kinds — the claim
a drained replica leaves behind, the Job that drained it, and the HTTPRoute
that has to close when spec.route is removed. There is deliberately no
delete on pods, statefulsets or deployments: a tier is resized through
statefulsets/scale, and a bug that reached for delete should get a 403.
gateway.networking.k8s.io is granted whether or not the cluster has the
Gateway API installed, because a rule naming a resource that does not exist
authorises nothing. The switch is spec.route on the MiraCluster rather than
a chart value.
Set rbac.namespaces to a list to get a Role in each instead of one
ClusterRole; the operator then watches only those namespaces, because a Role
can authorise nothing wider. The CRD is still cluster-scoped to install, and the
Lease keeps a Role of its own in the release namespace either way — claiming
it is the operator's first call, before the controller starts.
Replicas¶
Exactly one operator reconciles at a time, held by a coordination.k8s.io
Lease in the release namespace. kube-rs ships no election
(kube-rs/kube#485, open since
2021), so the operator holds its own: extra replicas stand by and take over
when the holder stops renewing. Two controllers acting on the same reading
would move two replicas for one decision.
It is soft, in two ways worth knowing. A holder whose renewal is stuck can
still be inside a reconcile when a standby's clock says the lease expired —
there is no fencing token to prevent that, so the window is seconds after a
failure rather than never. And the Lease is per-release while the watch is
cluster-wide by default, so two installs in two namespaces hold two leases and
both reconcile everything. Install the operator once, or give each one its own
rbac.namespaces.
Recreate rather than a rolling update, so an upgrade does not pay the standby
wait every time. A moment with no controller is safe; Mira keeps serving either
way.
Verifying the chart¶
cosign verify \
--new-bundle-format=false \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--certificate-identity-regexp 'github.com/TrianaLab/mira/.github/workflows/release.yml' \
ghcr.io/trianalab/charts/mira-operator:0.3.0
Values¶
| Key | Type | Default | Description |
|---|---|---|---|
| affinity | object | {} |
Affinity. |
| clusterEvents.endpoint | string | "" |
Ship Kubernetes Events and container state changes to a Mira as OTLP logs, so an agent writing an RCA can see an OOMKilled or a FailedScheduling on the same timeline as the telemetry. An OTLP/HTTP base URL — http://my-mira-proxy.mira.svc:4318 — and empty is off. This one value is the whole switch: it sets the operator's endpoint and creates the read-only Role below. Two switches would mean an endpoint without the Role, which is an operator taking 403s in a loop. Note what the Role grants: get/list/watch on pods cluster-wide, which includes spec.containers[].env and so any secret inlined there. The exporter reads only status and never emits a spec field, but the permission is wider than the use — scope it with rbac.namespaces if that matters in your cluster. |
| fullnameOverride | string | "" |
Overrides the full generated resource name. |
| image.pullPolicy | string | "IfNotPresent" |
Pull policy. |
| image.repository | string | "ghcr.io/trianalab/mira-operator" |
Operator image repository. |
| image.tag | string | "" |
Overrides the image tag. Defaults to the chart's appVersion. |
| imagePullSecrets | list | [] |
Image pull secrets for a private registry. |
| logLevel | string | "info,kube=warn" |
Log filter, in tracing-subscriber EnvFilter syntax. kube=warn keeps the client's per-request lines out of a log that should be one line per decision. |
| nameOverride | string | "" |
Overrides the chart name in resource names. |
| nodeSelector | object | {} |
Node selector. |
| podAnnotations | object | {} |
Pod annotations. |
| podLabels | object | {} |
Pod labels. |
| podSecurityContext | object | {"fsGroup":65532,"runAsGroup":65532,"runAsNonRoot":true,"runAsUser":65532,"seccompProfile":{"type":"RuntimeDefault"}} |
Pod-level security context. The operator writes nothing and needs no identity beyond its token. |
| rbac.create | bool | true |
Create the ClusterRole and binding the operator needs. |
| rbac.namespaces | list | [] |
Restrict the operator to a list of namespaces: a Role in each instead of one ClusterRole, and a watch scoped to match, since a Role can authorise nothing wider. Empty means cluster-wide. |
| replicaCount | int | 1 |
Replicas. Extras are warm standbys, not extra capacity: a coordination.k8s.io Lease means exactly one reconciles and the rest wait. Raise it to shorten the gap after a node failure, not to go faster. The Deployment's Recreate strategy is the other half — the lease makes an overlap survivable, Recreate makes upgrades not pay for one. |
| resources | object | {"limits":{"memory":"128Mi"},"requests":{"cpu":"10m","memory":"64Mi"}} |
Resource requests and limits. The controller is idle between reconciles; the ceiling exists to make it evictable rather than because it is reached. |
| securityContext | object | {"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true} |
Container security context. |
| serviceAccount.annotations | object | {} |
Annotations for the ServiceAccount (IRSA, Workload Identity). |
| serviceAccount.create | bool | true |
Create a ServiceAccount. |
| serviceAccount.name | string | "" |
Name to use. Generated from the fullname when empty. |
| tolerations | list | [] |
Tolerations. |
Maintainers¶
| Name | Url | |
|---|---|---|
| edu-diaz | edudiazasencio@gmail.com | https://edudiaz.dev |