Skip to content

feat(apisix): add opt-in read-only runtime support - #1041

Open
NiuBlibing wants to merge 5 commits into
apache:masterfrom
NiuBlibing:feature/security-context-defaults
Open

NiuBlibing wants to merge 5 commits into
apache:masterfrom
NiuBlibing:feature/security-context-defaults

Conversation

@NiuBlibing

@NiuBlibing NiuBlibing commented Nov 13, 2026 •

Copy link
Copy Markdown

Existing read-only APISIX deployments use custom writable mounts and copy init containers (for example #805). Automatic mounts must not duplicate those paths or change the security and ServiceAccount behavior of existing releases.

This PR adds opt-in runtimeVolumes.enabled support for the eight packaged writable directories. Explicit extraVolumeMounts take precedence; prepare-runtime copies only chart-managed config/log directories. Existing Pod, container and wait-etcd security contexts remain empty by default. Token automount defaults to null, preserving Kubernetes/admission and existing ServiceAccount behavior; explicit true/false overrides remain available. Missing new values are safe when upgrading with --reuse-values.

The chart package version increment is tracked separately in #1067, proposed as the final PR after this coordinated topic series and its integration checks. appVersion remains 3.21.0, unchanged from the current base. The coordinated version approach is subject to maintainer agreement. The README documents the upgrade behavior and provides a complete optional security profile for the official APISIX image. Applying that profile changes Pod permissions and requires a tested rollout; it is not applied to existing releases automatically.

Validation:

  • Helm 3.22.1 and Helm 4.3.0 render regression checks, including default/legacy/partial custom mounts, Deployment/DaemonSet, bundled/external etcd and token inheritance/overrides.
  • Eight pre-existing configurations produce exactly the same Pod specs as the current upstream base chart under both Helm versions.
  • Real Kubernetes 1.31 install/upgrade checks pass under both Helm versions: deploy the upstream base chart with the Running Apisix with securityContext does not work #805-style workaround, upgrade without duplicate mounts, retain Service UID/ClusterIP/ports and working routes; upgrade a normal deployment with --reuse-values and preserve an external ServiceAccount's disabled token automount; install the optional profile and verify actual writable paths, read-only root filesystem, UID, init exits, token absence and working traffic.
  • These render and Kubernetes checks are wired into the existing Helm 3/4 CI job, with the actual PR base chart checked out for upgrade tests. The Docker-only developer smoke test remains supplementary.
  • The complete PR-series integration passes its 25-test suite; security combinations are also checked with traditional, decoupled and individual plane deployments.

@NiuBlibing

Copy link
Copy Markdown
Author

Recommended merge order to reduce overlapping changes while keeping each PR single-topic:

#1039 → #1040 → #1041 → #1042 → #1043 → #1044 → #1045 → #1046 → #1047

The PRs are intentionally all based on master so their review diffs contain one topic. If upstream merges another overlapping change, only the affected topic branch needs a rebase.

@NiuBlibing

Copy link
Copy Markdown
Author

Updated recommended merge order after separating Admin API access policy from Ingress wiring:

#1039 → #1040 → #1041 → #1042 → #1043 → #1048 → #1044 → #1045 → #1046 → #1047

Each PR remains based on master and contains one topic. The sequence only reduces merge conflicts between templates and values; it is not a runtime dependency for every topic.

@NiuBlibing

Copy link
Copy Markdown
Author

Updated at d8afa60. The actual APISIX image was inspected and runs as numeric UID/GID 636. Defaults now set numeric IDs for Pod and wait-etcd, preserve writable config/log/temp paths under read-only root, and were validated by Docker startup, /status/ready=200 and nginx -t. ServiceAccount token automount remains false by default.

@NiuBlibing
NiuBlibing force-pushed the feature/security-context-defaults branch from d33ea48 to e4bbd05 Compare November 20, 2026 08:23

@moonming moonming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the substantial work here, @NiuBlibing, and for validating the actual image UID/GID and runtime paths. The writable-directory layout looks useful, but there is an upgrade blocker to address first.

The existing #805 workaround uses extraVolumeMounts for /usr/local/apisix/conf, /usr/local/apisix/logs, /tmp, and the nginx temporary directories. With this PR's automatic mounts, those paths are mounted twice. I rendered that configuration and confirmed eight duplicate mountPaths, which Kubernetes rejects.

Could you add a compatibility strategy, such as an opt-in runtime-volume switch, deduplication, or another explicit migration mechanism, together with a regression test?

This PR also changes several defaults: non-root execution, read-only root filesystem, seccomp, dropped capabilities, and ServiceAccount token automount. That needs an explicit versioning and migration decision; the PR currently leaves the chart at 3.1.0. One possible path is to separate optional read-only support from enabling secure defaults in a major release.

Please also wire the render test into CI. The standalone Docker smoke test is useful, but it does not exercise the Helm/Kubernetes volume and ServiceAccount behavior. Thanks again for the detailed validation so far!

@NiuBlibing NiuBlibing changed the title feat(apisix): add secure workload defaults feat(apisix): add opt-in read-only runtime support Nov 23, 2026

@moonming moonming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, @NiuBlibing! The previous head's kind E2E was green, and this head's render checks still pass locally.

I noticed that 95ab816 reverts charts/apisix/Chart.yaml from 3.2.0 back to 3.1.0. The chart requires a version increment whenever its templates change, so this head cannot be released as-is.

If the intent is to let #1053 go first, could you keep that ordering in the PR and then rebase and restore the appropriate next minor version? Please don't drop the version increment altogether. Once the final version and the rebased CI are in place, we can proceed with the review. Thanks!

@NiuBlibing

Copy link
Copy Markdown
Author

@moonming Thanks for pointing out the release-version requirement. I have opened #1067 as a separate, final chart package version PR for my improvement series, rather than assigning release versions to each intermediate topic PR. It currently contains only version: 3.1.0 → 3.2.0.

For clarity, #1041 has no Chart.yaml diff against its current base. appVersion remains 3.21.0; this PR does not upgrade APISIX itself.

My proposed merge order is:

  1. feat(apisix): deploy decoupled planes from one release #1039 → fix(apisix): pin verified APISIX and etcd images #1040 → feat(apisix): add opt-in read-only runtime support #1041: workload composition, image pinning and optional read-only runtime support.
  2. fix(apisix): expose status health probes for every deployment role #1042 → feat(apisix): budget graceful shutdown independently of probes #1054 → fix(apisix): bound bundled etcd connection attempts #1065: probes, graceful shutdown and the bounded etcd wait loop.
  3. fix(ingress): publish the current release Gateway Service #1043 → fix(apisix): avoid ServiceAccount name collisions #1063: release-local Gateway publishing and ServiceAccount naming.
  4. feat(apisix): trust etcd CA independently from APISIX TLS #1045 → fix(apisix): restrict default Admin API access #1048 → feat(apisix): accept literal or external runtime configuration #1057 → feat(apisix): expose common runtime flags #1064: etcd CA trust, Admin access and runtime configuration.
  5. feat(apisix): make metrics Service type configurable #1061 → fix(apisix): discover metrics Services across monitoring namespaces #1046 → feat(apisix): validate HPA utilization and expose custom metrics #1059 → fix(apisix): preserve zero disruption budgets and reject ambiguity #1058: metrics Service, ServiceMonitor, HPA and PDB.
  6. feat(apisix): provide opt-in APISIX network policy rules #1044 → feat(apisix): control bundled etcd ingress and egress independently #1055 → feat(apisix): control ingress controller network isolation #1056: the three NetworkPolicy topics.
  7. docs(ingress): define platform ownership for CRD install and upgrade #1047 → test(apisix): check strict YAML and rendered workload contracts #1060: CRD ownership and integration checks.
  8. chore(apisix): bump chart version after feature series #1067: the chart package version increment, after all intended topics and final integration validation.

All 21 topic PRs target master and retain one theme per diff. The order mainly reduces template conflicts; it is not a strict runtime dependency chain, and the NetworkPolicy topics are independent. I will rebase affected branches as the series lands and rerun the integration checks before the final version PR is merged. The proposed release boundary is #1067, not any intermediate topic head.

This makes the version increment explicit while keeping it separate from the feature diffs. I understand that this coordinated merge/version approach needs maintainer agreement with the repository's per-PR version rule; I am proposing that approach here rather than treating it as already accepted.

This branch has not been deployed

No deployments
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