Skip to content

Support cloud-agnostic K8s config variable names - #151

Merged
carillan81 merged 2 commits into
mainfrom
support-cloud-agnostic-k8s-vars
Sep 18, 2026
Merged

carillan81 merged 2 commits into
mainfrom
support-cloud-agnostic-k8s-vars

Conversation

@alexrashed

@alexrashed alexrashed commented Jun 30, 2026

Copy link
Copy Markdown
Member

Motivation

An upcoming LocalStack release renames the Kubernetes runtime configuration variables to cloud-agnostic names, effective from the 2026.07 release. The old names continue to work as deprecated fallbacks on newer versions, but the new names do not exist on older versions — so the chart must choose names based on the image version.

LocalStack now uses CalVer image tags (2026.06.0, 2026.05.4, …), so "higher than 2026.06" maps directly onto the tag's YYYY.MM.

Changes

  • _helpers.tpl: new localstack.useNewK8sVars helper that parses the image tag's leading year.month and returns truthy only when it is > 2026.06. Rolling / non-CalVer tags (latest, stable, dev, bare year) are treated as newest → new names, consistent with the chart's existing convention for unknown tags.

  • deployment.yaml: the three affected env vars now switch names based on version:

    Legacy (≤ 2026.06) New (> 2026.06)
    LOCALSTACK_K8S_NAMESPACE K8S_NAMESPACE
    LAMBDA_K8S_LABELS K8S_LABELS
    LAMBDA_K8S_SECURITY_CONTEXT K8S_CONTAINER_SECURITY_CONTEXT

    The other LOCALSTACK_K8S_* vars (SERVICE_NAME, POD_IP, POD_UID, POD_NAME, DEPLOYMENT_METHOD) are not part of the rename and are left untouched.

  • Chart.yaml: version bump 0.7.00.7.1.

Testing

  • helm template verified across 13 tag scenarios:
    • new names: latest, stable, dev, 2026, 2026.07.0, 2026.7, 2026.12.0, 2027.01.0
    • legacy names: 2026.06.0, 2026.06, 2026.6.0, 2025.12.0, 0.14.0, 1.4.0
  • helm lint passes (default and 2026.07.0).

Note (pre-existing, out of scope)

The security-context env var is gated on .Values.lambda.securityContext (camelCase) while values.yaml defines lambda.security_context (snake_case). This mismatch pre-dates this PR and means the var is not emitted when configured via the documented value; left unchanged here to keep the scope limited to the variable renaming.

🤖 Generated with Claude Code

@alexrashed
alexrashed marked this pull request as draft June 30, 2026 12:54
@alexrashed
alexrashed force-pushed the support-cloud-agnostic-k8s-vars branch from 3facf80 to 108a9b9 Compare June 30, 2026 12:56
@alexrashed alexrashed changed the title Support cloud-agnostic Kubernetes config variable names (LocalStack > 2026.06) Support cloud-agnostic K8s config variable names Jun 30, 2026
@alexrashed
alexrashed requested a review from a team June 30, 2026 13:09
@alexrashed
alexrashed marked this pull request as ready for review June 30, 2026 18:44
@alexrashed

alexrashed commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

@localstack/deployx The respective changes will be in the next release and the changes here are backwards compatible. WDYT, can we get this in?

Comment thread charts/localstack/templates/_helpers.tpl Outdated
@carillan81

carillan81 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Claude flagged this:
In the ECS Kubernetes task executor, the method that builds the LocalStack service FQDN reads LOCALSTACK_K8S_NAMESPACE directly from the environment instead of going through config. Once the chart emits K8S_NAMESPACE for newer tags, that lookup returns nothing and the function falls back to the bare service name. See localstack-pro-core/localstack/pro/core/services/ecs/task_executors/kubernetes.py#L585-L596 in localstack-pro. That is a fix for the Pro repo, not this PR, but Alex should know before merging.

alexrashed and others added 2 commits September 18, 2026 08:54
… 2026.06

An upcoming LocalStack release renames the Kubernetes runtime config
variables to cloud-agnostic names starting with the 2026.07 release:

  LOCALSTACK_K8S_NAMESPACE      -> K8S_NAMESPACE
  LAMBDA_K8S_LABELS             -> K8S_LABELS
  LAMBDA_K8S_SECURITY_CONTEXT   -> K8S_CONTAINER_SECURITY_CONTEXT

Add a localstack.useNewK8sVars helper that inspects the CalVer image tag and
emits the new names only when the version is > 2026.06, falling back to the
legacy names on older versions (where the new names do not exist). Rolling
and non-CalVer tags (latest, stable, dev, ...) are treated as newest,
consistent with the rest of the chart.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Helm's `int` is sprig's toInt, which routes to strconv.ParseInt(s, 0, 0).
Base 0 auto-detects the radix, so a zero-padded month is read as octal --
and 08/09 are not valid octal digits, so the parse fails and cast swallows
the error, yielding 0.

That made `2026.08.0` and `2026.09.0` evaluate to $ym = 202600, which is
<= 202606, so the helper fell back to the legacy variable names on exactly
the two releases right after the rename. Months 01-07 only worked by
coincidence, octal and decimal agree there.

atoi (strconv.Atoi) forces base 10 and parses the padded months correctly.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@alexrashed
alexrashed force-pushed the support-cloud-agnostic-k8s-vars branch from 108a9b9 to 3d3a478 Compare September 18, 2026 07:14
@carillan81
carillan81 merged commit b4b1836 into main Sep 18, 2026
2 checks passed
@carillan81
carillan81 deleted the support-cloud-agnostic-k8s-vars branch September 18, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants