Registry Mirror
Skip to content

Conversation

@titaneric

@titaneric titaneric commented Nov 27, 2026 •

Copy link
Copy Markdown

Changes

  • Allow init-container restartPolicy: Always and optional startup probes under the existing kubernetes.podspec-init-containers flag. Kubernetes owns startup ordering; no queue-proxy or Pod-builder behavior is changed.
  • Keep ordinary init-container probe restrictions and regular-container restart-policy restrictions. Add admission/defaulting/resource-preservation coverage.
  • Extend the existing readiness test image with a controlled startup-health gate and add live success/failure tests. Vendor the pinned client-go forwarding dependency closure for those tests.

This is a draft PoC for #16833. A long-running helper can initialize before the application and continue running afterward. A startup probe gates subsequent initialization and regular containers; a regular sidecar's readiness/startup probe does not provide that ordering.

Please review the choice to reuse the existing init-container flag rather than add a separate flag. Readiness/liveness probes and lifecycle hooks on init containers remain out of scope. Related serving-container restart-policy work in #16750/#16751 explicitly leaves native sidecars separate.

The added github.com/moby/spdystream and k8s.io/streaming requirements come from the e2e test's client-go port-forwarding path, not the production admission fix. No existing dependency versions were upgraded. Direct Pod-subresource forwarding is used because the Pod can remain Pending while its helper's startup probe is blocked.

Validation

Local checks passed:

go test ./pkg/apis/serving/... ./pkg/reconciler/service/resources ./pkg/reconciler/configuration/resources ./pkg/reconciler/revision/resources
go test -race ./test/test_images/readiness
go test -tags=e2e -run '^$' ./test/e2e/initcontainers

Targeted go vet and go mod verify also passed. This does not claim a full repository presubmit run.

Kind results

Tested on 2026-11-27–28 in a dedicated kind v0.33.0 / Kubernetes v1.35.8 / linux-arm64 cluster with one control-plane/worker node, containerd 2.3.4, and Kourier. Serving and fixture images were built locally and imported; no external image publication was needed.

Node image: kindest/node:v1.35.8@sha256:07b2536e30b803ed61d1677a79df6115f798ce64c80f9e22f6ed45afd09323c0.

Check Result
TestNativeSidecarStartup, -race -count=3 PASS, 3/3: helper endpoint failed while application/queue-proxy stayed unstarted; release led to a routed successful request; helper stayed running without a restart.
TestNativeSidecarStartupFailure, -race -count=3 PASS, 3/3: kubelet restarted the helper after startup-probe failure; regular containers remained unstarted.
Native-sidecar field preservation PASS across live Configuration, Revision, Deployment, and Pod.
Existing TestInitContainers regression PASS with a digest-qualified local volumes image; existing digest assertions were retained.
Serial admission-only flag-disable check PASS: dry-run and real new-Service creation were rejected after disablement; the existing Revision/Pod kept serving.
Pod replacement with flag disabled PASS: graceful UID-preconditioned deletion produced a new Pod under the same Revision; fields and startup gate were preserved; release restored routed HTTP success.
Cleanup/restoration PASS: tracked test Pods were removed within bounded waits; original flag setting restored; final test namespace had no Pods or Knative Services.

The six race-enabled native-sidecar executions completed in 139.931s, with no race reports. Success cases took 38.16s / 37.20s / 38.18s; failure cases took 8.11s / 8.11s / 8.10s, including cleanup.

GATEWAY_OVERRIDE=kourier GATEWAY_NAMESPACE_OVERRIDE=kourier-system \
go test -v -race -tags=e2e -run '^TestNativeSidecar' -count=3 -timeout=10m \
  ./test/e2e/initcontainers --kubeconfig "$KUBECONFIG" \
  --cluster kind-native-sidecar-poc --dockerrepo local.invalid/native-sidecar-poc \
  --tag poc --ingressendpoint 127.0.0.1 --disable-logstream

The local gateway listener matched its HTTP NodePort. For the offline setup, tag resolution was skipped only for the local image registry name; the ordinary init-container regression ran separately with a digest-qualified image. An initial run using host:port as the ingress override was stopped and corrected to host-only. Editing feature example comments also required regenerating the ConfigMap example checksum, included here.

The manual flag-disable check used the API server Pod proxy to release its helper; automated tests independently verified direct client-go forwarding during initialization. Original and replacement Pod UIDs differed, while the Revision UID stayed unchanged.

Remaining limits

  • This validates startup ordering and bounded graceful cleanup, not in-flight request draining under load, higher scale, or other Kubernetes minors.
  • During the short startup-failure test, helper restart status was visible on the Pod while Revision health remained Unknown/Deploying; helper-specific diagnostics are not added here.
  • Helper requests/limits were preserved. Queue-proxy percentage-based resource calculations still use serving-container resources; helper-aware autoscaling/accounting is not established by these tests.
  • Disabling the flag restricts new admission; it does not remove helpers from existing Revisions or establish binary-downgrade safety.

/kind enhancement

Fixes #16833

Release Note

When kubernetes.podspec-init-containers is enabled, init containers can set restartPolicy: Always and an optional startupProbe. Kubernetes waits for that probe to succeed before continuing initialization and starting regular containers. Readiness/liveness probes and lifecycle hooks on init containers remain unsupported.

Docs

- [Feature Track]: https://github.com/knative/serving/issues/16833
- [Usage]: https://github.com/titaneric/serving/blob/ae7d4082d9c5d3c772e222ddd853d3c864310eff/test/e2e/initcontainers/README.md

A separate knative/docs change has not been opened; the operator-facing flag documentation should follow agreement on this draft's scope.

Gate init container restart policies and startup probes with existing init-container support.

Co-authored-by: OpenCode
Retain pinned versions and add the streaming dependency closure required by e2e tests.

Co-authored-by: OpenCode
Add controlled success and failure cases plus isolated-cluster verification instructions. Live execution remains pending.

Co-authored-by: OpenCode
@knative-prow knative-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/enhancement labels Nov 27, 2026
@knative-prow

knative-prow Bot commented Nov 27, 2026

Copy link
Copy Markdown

@titaneric: The label(s) kind/<kind> cannot be applied, because the repository doesn't have them.

Details

In response to this:

Changes

  • Allow init-container restartPolicy: Always and optional startup probes under the existing kubernetes.podspec-init-containers flag. Kubernetes owns startup ordering; no queue-proxy or Pod-builder behavior is changed.
  • Keep ordinary init-container probe restrictions and regular-container restart-policy restrictions. Add admission/defaulting/resource-preservation coverage.
  • Extend the existing readiness test image with a controlled startup-health gate and add live success/failure tests. Vendor the pinned client-go forwarding dependency closure for those tests.

This is a draft PoC for #16833. A long-running helper can initialize before the application and continue running afterward. A startup probe gates subsequent initialization and regular containers; a regular sidecar's readiness/startup probe does not provide that ordering.

Please review the choice to reuse the existing init-container flag rather than add a separate flag. Readiness/liveness probes and lifecycle hooks on init containers remain out of scope. Related serving-container restart-policy work in #16750/#16751 explicitly leaves native sidecars separate.

The added github.com/moby/spdystream and k8s.io/streaming requirements come from the e2e test's client-go port-forwarding path, not the production admission fix. No existing dependency versions were upgraded. Direct Pod-subresource forwarding is used because the Pod can remain Pending while its helper's startup probe is blocked.

Validation

Local checks passed:

go test ./pkg/apis/serving/... ./pkg/reconciler/service/resources ./pkg/reconciler/configuration/resources ./pkg/reconciler/revision/resources
go test -race ./test/test_images/readiness
go test -tags=e2e -run '^$' ./test/e2e/initcontainers

Targeted go vet and go mod verify also passed. This does not claim a full repository presubmit run.

Kind results

Tested on 2026-11-27–28 in a dedicated kind v0.33.0 / Kubernetes v1.35.8 / linux-arm64 cluster with one control-plane/worker node, containerd 2.3.4, and Kourier. Serving and fixture images were built locally and imported; no external image publication was needed.

Node image: kindest/node:v1.35.8@sha256:07b2536e30b803ed61d1677a79df6115f798ce64c80f9e22f6ed45afd09323c0.

Check Result
TestNativeSidecarStartup, -race -count=3 PASS, 3/3: helper endpoint failed while application/queue-proxy stayed unstarted; release led to a routed successful request; helper stayed running without a restart.
TestNativeSidecarStartupFailure, -race -count=3 PASS, 3/3: kubelet restarted the helper after startup-probe failure; regular containers remained unstarted.
Native-sidecar field preservation PASS across live Configuration, Revision, Deployment, and Pod.
Existing TestInitContainers regression PASS with a digest-qualified local volumes image; existing digest assertions were retained.
Serial admission-only flag-disable check PASS: dry-run and real new-Service creation were rejected after disablement; the existing Revision/Pod kept serving.
Pod replacement with flag disabled PASS: graceful UID-preconditioned deletion produced a new Pod under the same Revision; fields and startup gate were preserved; release restored routed HTTP success.
Cleanup/restoration PASS: tracked test Pods were removed within bounded waits; original flag setting restored; final test namespace had no Pods or Knative Services.

The six race-enabled native-sidecar executions completed in 139.931s, with no race reports. Success cases took 38.16s / 37.20s / 38.18s; failure cases took 8.11s / 8.11s / 8.10s, including cleanup.

GATEWAY_OVERRIDE=kourier GATEWAY_NAMESPACE_OVERRIDE=kourier-system \
go test -v -race -tags=e2e -run '^TestNativeSidecar' -count=3 -timeout=10m \
 ./test/e2e/initcontainers --kubeconfig "$KUBECONFIG" \
 --cluster kind-native-sidecar-poc --dockerrepo local.invalid/native-sidecar-poc \
 --tag poc --ingressendpoint 127.0.0.1 --disable-logstream

The local gateway listener matched its HTTP NodePort. For the offline setup, tag resolution was skipped only for the local image registry name; the ordinary init-container regression ran separately with a digest-qualified image. An initial run using host:port as the ingress override was stopped and corrected to host-only. Editing feature example comments also required regenerating the ConfigMap example checksum, included here.

The manual flag-disable check used the API server Pod proxy to release its helper; automated tests independently verified direct client-go forwarding during initialization. Original and replacement Pod UIDs differed, while the Revision UID stayed unchanged.

Remaining limits

  • This validates startup ordering and bounded graceful cleanup, not in-flight request draining under load, higher scale, or other Kubernetes minors.
  • During the short startup-failure test, helper restart status was visible on the Pod while Revision health remained Unknown/Deploying; helper-specific diagnostics are not added here.
  • Helper requests/limits were preserved. Queue-proxy percentage-based resource calculations still use serving-container resources; helper-aware autoscaling/accounting is not established by these tests.
  • Disabling the flag restricts new admission; it does not remove helpers from existing Revisions or establish binary-downgrade safety.
Template command syntax (reference only)

The template's literal syntax is retained here for template validation. The
populated classification and issue reference follow below.

/kind <kind>
Fixes #

/kind enhancement

Fixes #16833

Release Note

When kubernetes.podspec-init-containers is enabled, init containers can set restartPolicy: Always and an optional startupProbe. Kubernetes waits for that probe to succeed before continuing initialization and starting regular containers. Readiness/liveness probes and lifecycle hooks on init containers remain unsupported.

Docs

- [Feature Track]: https://github.com/knative/serving/issues/16833
- [Usage]: https://github.com/titaneric/serving/blob/ae7d4082d9c5d3c772e222ddd853d3c864310eff/test/e2e/initcontainers/README.md

A separate knative/docs change has not been opened; the operator-facing flag documentation should follow agreement on this draft's scope.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow

knative-prow Bot commented Nov 27, 2026

Copy link
Copy Markdown

Welcome @titaneric! It looks like this is your first PR to knative/serving 🎉

@knative-prow knative-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 27, 2026
@knative-prow

knative-prow Bot commented Nov 27, 2026

Copy link
Copy Markdown

Hi @titaneric. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow

knative-prow Bot commented Nov 27, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: titaneric
Once this PR has been reviewed and has the lgtm label, please assign matzew for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow
knative-prow Bot requested review from dsimansk and skonto November 27, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/enhancement needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support native sidecars in initContainers with startup probes

1 participant