feat(helm): tonin.toml [env] tables and per-dependency egress ports#108
Merged
Conversation
…ports
Two gaps found auditing a real tonin consumer (ZVectorLabs monorepo):
- [env] / [env.<env>] tables declare plain (non-secret) runtime env vars in
tonin.toml, rendered into the generated values files' env: map (which the
deployment template already injects). Base entries merge under per-env
overlays, {env} substitutes in values, and keys colliding with tonin-emitted
stateful/secret env names fail generation.
- [depends_on] table form accepts port = <p>; the generated
CiliumNetworkPolicy egress rule uses the per-dependency port instead of a
hardcoded 50051. Bare-string entries keep defaulting to 50051, so existing
charts render identically. The policy also allows kube-dns egress, which
default-deny was silently blocking.
RECOMMENDED_CLI_MIN bumps to 0.14.0 since older CLIs silently ignore [env].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two
tonin helm generategaps, both found while auditing a real tonin consumer (the ZVectorLabs monorepo, where every service's chart is rendered fromtonin.toml):1.
[env]tables → chartenv:mapThere was no way to declare plain (non-secret) runtime env vars in
tonin.toml. The generatedvalues.yamlshipsextraEnv: []/env: {}and regeneration clobbers hand-edits, so a service that needs e.g.IDENTITY_GRPC_URLsimply crashes when chart-deployed. The existing mechanisms are narrow:[database]/[cache]→statefulEnvliterals,[secrets]→secretKeyRefenv.New optional
[env]table, with per-env overlays and{env}substitution (consistent withnamespace = "zvectorlabs-{env}"):Resolution: base string entries + the
[env.<env>]overlay for the rendered env (overlay wins),{env}substituted in values, sorted for deterministic output. Rendered intovalues.yamland eachvalues-<env>.yamlas theenv:map — the deployment template already injects.Values.envinto the server container, so no chart-template changes were needed.Guards (hard errors, matching the planner's no-silent-fallback philosophy):
DATABASE_URL/REDIS_URLstateful literals, secret-sourced keys) — duplicate container env names are last-one-wins in Kubernetes, which would silently override the resolved URLs2. Per-dependency egress port in the generated network policy
chart/templates/networkpolicy.yamlhardcoded thedependsOnegress port:- { port: "50051", protocol: TCP }— correct only when the dependency is a gRPC service on 50051. Real dependency graphs (ui→api:7001, api→zradar:4317/8081) get their traffic blocked under Cilium.The
[depends_on]table form now acceptsport(validated 1–65535), alongside the existingnamespace/ per-env override /envskeys:values*.yamlnetworkPolicy.dependsOnentries now carryport:, and the egress rule renders{{ .port | default 50051 }}— so even hand-supplied values withoutportkeep today's behavior.Also fixed while there (few lines, same template): the generated CiliumNetworkPolicy had no kube-dns egress. Any egress rule makes the policy default-deny for the pod, so DNS — and with it all service discovery — was silently blocked for every cilium-mesh service. Added a
kube-dns53/UDP+TCP egress allow.Backward compatibility
tonin.tomladditions are optional with defaults preserving today's output: no[env]→env: {}exactly as before; bare-stringdepends_on→port: 50051, same egress rule as the old hardcode.v1(additive only).RECOMMENDED_CLI_MINbumped to0.14.0per its doc comment, since older CLIs silently ignore[env].tonin-pluginAPI:Plan.depends_onis nowVec<DependencyRef>(name,namespace,port) instead ofVec<ServiceRef>— a dependency is a service ref plus a port, andServiceRefkeeps meaning "service in a namespace" forcallers. Pre-1.0 minor-version API change;DependencyRefdeserializesportwith a 50051 serde default.Known follow-ups (not in scope)
[env]values render into values files in plain text by design (non-secret); anything sensitive belongs in[secrets].Test plan
just ci(fmt-check + clippy-D warnings+ nextest + doc + version-sync) green.tonin-pluginplan tests:[env]base + overlay merge,{env}substitution, brace passthrough, non-string errors (active and inactive overlays), reserved-key collisions (stateful + secret);depends_onbare-string default port, table port (with env overrides), missing port default, non-integer / out-of-range port errors.toninhelm generate tests:[env]rendered intovalues-dev/prod.yamlwith overlay +{env}resolution and into the basevalues.yaml;env: {}preserved when[env]absent;dependsOnentries carryport:for both forms; networkpolicy template uses{{ .port | default 50051 }}, no hardcoded dependency port, kube-dns egress present.just gen-example(greeter chart re-render + build).🤖 Generated with Claude Code