|
| 1 | +# KEP-8905: Native Sidecar Support |
| 2 | + |
| 3 | +<!-- toc --> |
| 4 | +- [Summary](#summary) |
| 5 | + - [Goals](#goals) |
| 6 | + - [Non-Goals](#non-goals) |
| 7 | +- [Proposal](#proposal) |
| 8 | +- [Design Details](#design-details) |
| 9 | + - [Recommendations](#recommendations) |
| 10 | + - [Update / Admission](#update--admission) |
| 11 | + - [Test Plan](#test-plan) |
| 12 | + - [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy) |
| 13 | +- [Alternatives](#alternatives) |
| 14 | +<!-- /toc --> |
| 15 | + |
| 16 | +## Summary |
| 17 | + |
| 18 | +This proposal adds support for native sidecar containers (init containers with `restartPolicy: Always`) in Vertical Pod Autoscaler. |
| 19 | + |
| 20 | +Kubernetes 1.28 introduced native sidecar containers. These are init containers that start before the main containers and continue running during the lifecycle of the Pod. VPA currently supports standard containers and regular init containers, but it should also support recommending resources for these new native sidecar containers to ensure they are right-sized. |
| 21 | +Addresses [issue #7229](https://github.com/kubernetes/autoscaler/issues/7229) |
| 22 | + |
| 23 | +### Goals |
| 24 | + |
| 25 | +- Allow VPA Recommender to generate resource recommendations for native sidecar containers. |
| 26 | +- Ensure VPA Updater and Admission Controller can apply recommendations to native sidecar containers. |
| 27 | + |
| 28 | +### Non-Goals |
| 29 | + |
| 30 | +- Support for sidecar containers in Kubernetes versions older than 1.28. |
| 31 | + |
| 32 | +## Proposal |
| 33 | + |
| 34 | +The proposal is to introduce a new feature gate `NativeSidecar` in VPA. When enabled, VPA components will recognize and handle native sidecar containers. |
| 35 | + |
| 36 | +## Design Details |
| 37 | + |
| 38 | +### Recommendations |
| 39 | + |
| 40 | +The Recommender component identifies native sidecar containers by examining init containers with `restartPolicy: Always` in the `SpecClient`. These containers are assigned the `ContainerTypeInitSidecar` type. |
| 41 | + |
| 42 | +When the `NativeSidecar` feature gate is enabled, the `ClusterFeeder` processes native sidecars similarly to standard containers: |
| 43 | +- They are stored in a separate `InitSidecarsContainers` map in the pod state |
| 44 | +- Resource usage samples are collected and aggregated for recommendations |
| 45 | +- Recommendations are generated using the same logic as standard containers |
| 46 | + |
| 47 | +The VPA custom resource definition remains unchanged. Native sidecar recommendations are included in the `containerRecommendations` array alongside standard container recommendations, using the unique container name to identify them. |
| 48 | + |
| 49 | +### Update / Admission |
| 50 | + |
| 51 | +Both Updater and Admission Controller components retrieve recommendations for init containers (including native sidecars) separately from standard containers using `GetContainersResourcesForPod`. |
| 52 | +The patch generation logic is updated to target `/spec/initContainers` for native sidecar containers, while normal containers will continue to update `/spec/containers`. |
| 53 | + |
| 54 | +### Test Plan |
| 55 | + |
| 56 | +The following test scenarios will be added to e2e tests. |
| 57 | + |
| 58 | +- Admission applies recommendations to native sidecars. |
| 59 | +- Updater will update sidecar container resources in-place or evict. |
| 60 | +- Admission will patch sidecar container resources. |
| 61 | +- When the feature gate `NativeSidecar` is false VPA components will not modify native sidecars. |
| 62 | + |
| 63 | +### Upgrade / Downgrade Strategy |
| 64 | + |
| 65 | +#### Upgrade |
| 66 | + |
| 67 | +On upgrade of the VPA to 1.6.0 (tentative release version), nothing will change, |
| 68 | +VPAs will continue to work as before. |
| 69 | + |
| 70 | +Users can use the new `NativeSidecar` by enabling the alpha Feature Gate (which defaults to disabled) |
| 71 | +by passing `--feature-gates=NativeSidecar=true` to the VPA components. |
| 72 | + |
| 73 | +#### Downgrade |
| 74 | + |
| 75 | +On downgrade of VPA from 1.6.0 (tentative release version), nothing will change. |
| 76 | +VPAs will continue to work as previously. Checkpoints may contain sidecar resource information until updated, but updater and admission will modify sidecar resources. |
| 77 | + |
| 78 | +## Alternatives |
| 79 | + |
| 80 | +### Treat as Standard Containers |
| 81 | + |
| 82 | +We could treat them as standard containers, but they are technically init containers in the Pod spec, so the patch path would be incorrect (`/spec/containers` vs `/spec/initContainers`). |
0 commit comments