Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document VPA behavior for sidecar containers and how to change it #7645

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

omerap12
Copy link
Member

What type of PR is this?

/kind documentation

What this PR does / why we need it:

Document VPA behavior for sidecar containers and how to change it

Which issue(s) this PR fixes:

Fixes #7641

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

NONE

@k8s-ci-robot k8s-ci-robot added kind/documentation Categorizes issue or PR as related to documentation. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 29, 2024
@k8s-ci-robot k8s-ci-robot added area/vertical-pod-autoscaler size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 29, 2024
@@ -0,0 +1,173 @@
# VPA Sidecar Container Management

The Vertical Pod Autoscaler (VPA) has specific behavior when dealing with sidecar containers that are injected into pods via admission webhooks. This document explains the default behavior and how to customize it for your needs.
Copy link
Member

Choose a reason for hiding this comment

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

Does "Sidecar" refer to "A container that isn't the main one", or to the formal Sidecar definition (ie: https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/)

I assume it's the former. It may be good to clarity this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in 3e4addd

Co-authored-by: Adrian Moisey <[email protected]>
@adrianmoisey
Copy link
Member

Documentation is hard, so thanks for doing this.

I'm wondering how this page fits into the broader layout of the documents. My best guess is that it's a "FAQ" (ie: https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/docs/faq.md).

I'm not entirely sold on that though. Having the document exist is a great first step, we can move it later if needed.

@omerap12
Copy link
Member Author

Documentation is hard, so thanks for doing this.

I'm wondering how this page fits into the broader layout of the documents. My best guess is that it's a "FAQ" (ie: https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/docs/faq.md).

I'm not entirely sold on that though. Having the document exist is a great first step, we can move it later if needed.

I was wondering about that as well. Perhaps @voelzmo might have some ideas on how the overall layout should be structured

@omerap12
Copy link
Member Author

/retest

Copy link
Contributor

@voelzmo voelzmo left a comment

Choose a reason for hiding this comment

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

Thanks, great summary. A few suggestions from me.

This default "manage everything" approach can cause problems with sidecars because:
- Sidecar containers often have their own resource requirements set by their injection webhooks
- VPA's automatic management may conflict with these requirements
- Without proper handling, this can lead to resource conflicts and pod instability
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Without proper handling, this can lead to resource conflicts and pod instability
- Without proper handling, this can lead to problems like endless eviction loops

Without proper handling of sidecar containers, the following problematic sequence could occur:

1. VPA admission controller sets resources for all containers
2. Sidecar webhook injects a new container with its own resource requirements
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
2. Sidecar webhook injects a new container with its own resource requirements
2. Sidecar webhook reconciles the injected sidecar container to the original resource requirements


### Option 1: Webhook Ordering

To have VPA manage sidecar resources, ensure your webhook names follow this pattern:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
To have VPA manage sidecar resources, ensure your webhook names follow this pattern:
If you know that you only use sidecar injecting webhooks which _don't_ reconcile Container resources, you can choose to have VPA manage sidecar resources. Ensure your webhook names follow this pattern, resulting in the VPA admission-controller webhook to be executed last:

@@ -0,0 +1,177 @@
# VPA Sidecar Container Management

In this document, "sidecar container" refers to any additional container that isn't the main application container in a pod. This is distinct from the formal [Kubernetes sidecar pattern](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/), which describes a specific design pattern where a container enhances or extends the main container's functionality. Our usage here applies to all additional containers, regardless of their architectural pattern or purpose.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In this document, "sidecar container" refers to any additional container that isn't the main application container in a pod. This is distinct from the formal [Kubernetes sidecar pattern](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/), which describes a specific design pattern where a container enhances or extends the main container's functionality. Our usage here applies to all additional containers, regardless of their architectural pattern or purpose.
In this document, "sidecar container" refers to any additional Container that isn't the main application Container in a Pod. This is distinct from the [native Kubernetes sidecar pattern](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/), which makes use of `initContainers`. Our usage here applies to all additional regular `containers` only, as VPA does not support `initContainers` yet.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/documentation Categorizes issue or PR as related to documentation. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document VPA behavior for sidecar containers and how to change it
4 participants