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

feat(cli): add 'drain' CLI command to set /status/ready to 503 #13838

Merged
merged 14 commits into from
Nov 25, 2024
Merged

Conversation

tzssangglass
Copy link
Member

@tzssangglass tzssangglass commented Nov 6, 2024

Summary

This command updates the /status/ready endpoint to return a 503 Service Unavailable status code. This allows external tools, such as Kubernetes, to detect when Kong is not ready to receive traffic. Based on this response, Kubernetes can gracefully remove Kong from its load balancing pool according to its configured policies, facilitating a smooth shutdown process.

Checklist

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Issue reference

Fix: FTI-6276

This command updates the `/status/ready` endpoint to return a `503 Service Unavailable` status code.
This allows external tools, such as Kubernetes, to detect when Kong is not ready to receive traffic.
Based on this response, Kubernetes can gracefully remove Kong from its load balancing pool according
to its configured policies, facilitating a smooth shutdown process.

Fix: [FTI-6276](https://konghq.atlassian.net/browse/FTI-6276)
Signed-off-by: tzssangglass <[email protected]>
@github-actions github-actions bot added core/cli cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee labels Nov 6, 2024
Signed-off-by: tzssangglass <[email protected]>
Signed-off-by: tzssangglass <[email protected]>
Signed-off-by: tzssangglass <[email protected]>
Signed-off-by: tzssangglass <[email protected]>
Signed-off-by: tzssangglass <[email protected]>
Signed-off-by: tzssangglass <[email protected]>
Signed-off-by: tzssangglass <[email protected]>
@tzssangglass tzssangglass marked this pull request as ready for review November 8, 2024 08:53
kong/status/ready.lua Outdated Show resolved Hide resolved
kong/status/ready.lua Outdated Show resolved Hide resolved
kong/status/ready.lua Outdated Show resolved Hide resolved
Signed-off-by: tzssangglass <[email protected]>
Signed-off-by: tzssangglass <[email protected]>
@windmgc windmgc changed the title feat(cli): add 'unready' CLI command to set /status/ready to 503 feat(cli): add 'drain' CLI command to set /status/ready to 503 Nov 13, 2024
Copy link
Member

@windmgc windmgc left a comment

Choose a reason for hiding this comment

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

Approve with one minor suggestion

kong/status/ready.lua Outdated Show resolved Hide resolved
apply comments

Co-authored-by: Keery Nie <[email protected]>
@tzssangglass tzssangglass requested a review from mheap November 15, 2024 03:27
@tzssangglass
Copy link
Member Author

hi @mheap , PTAL this PR, it add a new command drain in Kong.

Copy link
Member

@gszr gszr left a comment

Choose a reason for hiding this comment

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

@tzssangglass Is there an internal spike doc with the alternatives we looked into for solving this issue? I am curious if adding yet another command isn't overcomplicating things -- maybe it's the best option, but I'm curious if this is the best interface we can provide among the options we researched. Adding new commands to the CLI increases complexity in a non-negligible way.

@gszr gszr requested review from dndx and fffonion November 18, 2024 21:59
Signed-off-by: tzssangglass <[email protected]>
@tzssangglass
Copy link
Member Author

Is there an internal spike doc with the alternatives we looked into for solving this issue?

We do not have an internal spike doc recording this or an alternative solution;

This was derived from discussions with members of the k8s team.

Signed-off-by: tzssangglass <[email protected]>
Signed-off-by: tzssangglass <[email protected]>
@mheap mheap self-requested a review November 22, 2024 12:24
@windmgc windmgc merged commit 11bc3b6 into master Nov 25, 2024
26 checks passed
@windmgc windmgc deleted the FTI-6276 branch November 25, 2024 02:49
@team-gateway-bot
Copy link
Collaborator

Cherry-pick failed for master, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally.

git remote add upstream https://github.com/kong/kong-ee
git fetch upstream master
git worktree add -d .worktree/cherry-pick-13838-to-master-to-upstream upstream/master
cd .worktree/cherry-pick-13838-to-master-to-upstream
git checkout -b cherry-pick-13838-to-master-to-upstream
ancref=$(git merge-base d4ab528fa2414d996861a43e58406c02b4978157 6640567c919125171d584ee2095125d0d233a093)
git cherry-pick -x $ancref..6640567c919125171d584ee2095125d0d233a093

@github-actions github-actions bot added the incomplete-cherry-pick A cherry-pick was incomplete and needs manual intervention label Nov 25, 2024
@kikito kikito removed the incomplete-cherry-pick A cherry-pick was incomplete and needs manual intervention label Nov 25, 2024
ProBrian pushed a commit that referenced this pull request Dec 13, 2024
* feat(cli): add 'unready' CLI command to set /status/ready to 503

This command updates the `/status/ready` endpoint to return a `503 Service Unavailable` status code.
This allows external tools, such as Kubernetes, to detect when Kong is not ready to receive traffic.
Based on this response, Kubernetes can gracefully remove Kong from its load balancing pool according
to its configured policies, facilitating a smooth shutdown process.

Fix: [FTI-6276](https://konghq.atlassian.net/browse/FTI-6276)
Signed-off-by: tzssangglass <[email protected]>

---------

Signed-off-by: tzssangglass <[email protected]>
lhanjian pushed a commit that referenced this pull request Dec 23, 2024
* feat(cli): add 'unready' CLI command to set /status/ready to 503

This command updates the `/status/ready` endpoint to return a `503 Service Unavailable` status code.
This allows external tools, such as Kubernetes, to detect when Kong is not ready to receive traffic.
Based on this response, Kubernetes can gracefully remove Kong from its load balancing pool according
to its configured policies, facilitating a smooth shutdown process.

Fix: [FTI-6276](https://konghq.atlassian.net/browse/FTI-6276)
Signed-off-by: tzssangglass <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee core/cli size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants