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

[SidecarContainer] provide sidecar best practices hints about exit code #48228

Merged
merged 1 commit into from
Nov 2, 2024

Conversation

pegasas
Copy link
Contributor

@pegasas pegasas commented Oct 6, 2024

Description

This is a follow up from kubernetes/enhancements#753 (comment)

We need to improve the page https://kubernetes.io/docs/tutorials/configuration/pod-sidecar-containers/ with the best practices on how to implement sidecar containers. Things like exiting with 0 on SIGTERM

Issue

Closes: #47823

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language labels Oct 6, 2024
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 6, 2024
@pegasas pegasas changed the title [SidecarContainer] provide sidecar implementation best practices hints [SidecarContainer] provide sidecar best practices hints about exit code Oct 6, 2024
Copy link

netlify bot commented Oct 6, 2024

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit 7195f5f
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-io-main-staging/deploys/6725c1e2201a0b0008cdc0be
😎 Deploy Preview https://deploy-preview-48228--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sftim
Copy link
Contributor

sftim commented Oct 6, 2024

If we want to document good practice, I'd put that elsewhere (not inside a tutorial page).

@pegasas
Copy link
Contributor Author

pegasas commented Oct 7, 2024

If we want to document good practice, I'd put that elsewhere (not inside a tutorial page).

Any suggestions?
For me, I think this is a good place because it is near place which mentioned SIGTERM/SIGKILL fact.

@SergeyKanzhelev
Copy link
Member

Let's add it to this page: https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/#differences-from-application-containers

And link the differences section from where you put this node to originally

@pegasas
Copy link
Contributor Author

pegasas commented Oct 30, 2024

Let's add it to this page: https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/#differences-from-application-containers

And link the differences section from where you put this node to originally

Thanks @SergeyKanzhelev .
Done.

@@ -115,6 +115,9 @@ Init containers stop before the main containers start up, so init containers can
exchange messages with the app container in a Pod. Any data passing is one-way
(for example, an init container can put information inside an `emptyDir` volume).

From kubernetes perspective, sidecars will receive the `SIGTERM` following with `SIGKILL`,
Copy link
Member

Choose a reason for hiding this comment

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

I think this belongs to the previous section - Differences from application containers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense.

Comment on lines 118 to 119
From kubernetes perspective, sidecars will receive the `SIGTERM` following with `SIGKILL`,
so exit codes != 0 for sidecar containers are normal on main container exit and should be ignored.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
From kubernetes perspective, sidecars will receive the `SIGTERM` following with `SIGKILL`,
so exit codes != 0 for sidecar containers are normal on main container exit and should be ignored.
From Kubernetes perspective, sidecars graceful termination is less important. When other containers took all alloted graceful termination time, sidecar containers will receive the `SIGTERM` following with `SIGKILL` faster than may be expected. So exit codes different from `0` (`0` indicates successful exit), for sidecar containers are normal on Pod termination and should be generally ignored by the external tooling.

Update content/en/docs/concepts/workloads/pods/sidecar-containers.md

Co-authored-by: Sergey Kanzhelev <S.Kanzhelev@live.com>

Update content/en/docs/tutorials/configuration/pod-sidecar-containers.md

Co-authored-by: Sergey Kanzhelev <S.Kanzhelev@live.com>
Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 2, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: c6fe3401a5d3beab9aa00a44c4ebf2f585057d08

Copy link
Contributor

@sftim sftim left a comment

Choose a reason for hiding this comment

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

This change improves our documentation.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SergeyKanzhelev, sftim

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 2, 2024
@k8s-ci-robot k8s-ci-robot merged commit f9fc6b4 into kubernetes:main Nov 2, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SidecarContainer] Need to provide sidecar implementation best practices
4 participants