Add common wait conditions for Deployments, LoadBalancer Services, and Ingress#1710
Merged
clux merged 3 commits intokube-rs:mainfrom Mar 7, 2025
detjensrobert:extra-wait-conditions
Merged
Add common wait conditions for Deployments, LoadBalancer Services, and Ingress#1710clux merged 3 commits intokube-rs:mainfrom detjensrobert:extra-wait-conditions
clux merged 3 commits intokube-rs:mainfrom
detjensrobert:extra-wait-conditions
Conversation
clux
reviewed
Mar 4, 2025
Member
clux
left a comment
There was a problem hiding this comment.
These all look great. Thank you very much for these.
Small suggestion on how to unit test them would be appreciated, but otherwise vhappy to merge this.
Comment on lines
+274
to
+276
| if spec.type_ != Some("LoadBalancer".to_string()) { | ||
| return true; | ||
| } |
Member
There was a problem hiding this comment.
i guess this is the only questionable thing, and it's not really a fault of yours, but more about us conflating bools and options. i'll think a bit about #1498 after this pr.
Contributor
Author
There was a problem hiding this comment.
Yeah, I don't think there's any better way to handle this at the moment.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1710 +/- ##
=======================================
+ Coverage 75.8% 76.2% +0.4%
=======================================
Files 84 84
Lines 7743 7847 +104
=======================================
+ Hits 5866 5972 +106
+ Misses 1877 1875 -2
🚀 New features to boost your workflow:
|
These are common wait conditions for these resources, and are useful for waiting for exposed services to become available. Signed-off-by: Robert Detjens <github@detjens.dev>
Signed-off-by: Robert Detjens <github@detjens.dev>
These tests run the condition function against included yaml snippets of objects returned by the K8S API to check against known-state statuses. Signed-off-by: Robert Detjens <github@detjens.dev>
clux
approved these changes
Mar 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
I've been using this library to create a custom tool to deploy applications, and have been using these conditions via
await_conditionto wait for those applications to become ready or report failures back to the users.Since these are generally useful for waiting for these types of services to become available, I'm hoping to contribute these back upstream so that other client-esque applications have these ready to use.
Solution
This adds a few new wait conditions to
kube-runtime::wait::conditionsforDeployments,LoadBalancer-typeServices, andIngresss to complete or become ready.The
Deploymentcheck (is_deployment_completed()) matches K8S's definition of completed deployments.LoadBalancerandIngressresources don't have an associated status condition for 'ready', but they are updated with the LoadBalancer details the backing cloud/etc load balancer has been fully provisioned and is ready. The newis_ingress_provisioned()/is_service_loadbalancer_provisioned()checks wait for that update to set.status.loadBalancer.ingress.(ip|hostname). Non-loadbalancer services are ignored by always returning true i.e. immediately ready.I did not add tests for these since the existing condition checks do not have any.