-
Notifications
You must be signed in to change notification settings - Fork 765
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
add_enhanced_livenessProbe_webhook #1467
add_enhanced_livenessProbe_webhook #1467
Conversation
utilfeature "github.com/openkruise/kruise/pkg/util/feature" | ||
) | ||
|
||
const ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving the api to the common package like ./pkg/util
or apis
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
func (h *PodCreateHandler) enhancedLivenessProbeWhenPodCreate(req admission.Request, pod *v1.Pod) (skip bool, err error) { | ||
|
||
if len(req.AdmissionRequest.SubResource) > 0 || | ||
req.AdmissionRequest.Operation != admissionv1.Create || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if users modify LivenessProbe
when updating pods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v1 version, the native version just supports the creation process.
return true, nil | ||
} | ||
|
||
if !util.IsPodOwnedByKruise(pod) && !utilfeature.DefaultFeatureGate.Enabled(features.EnhancedLivenessProbe) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition utilfeature.DefaultFeatureGate.Enabled(features.EnhancedLivenessProbe)
seems to be duplicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the determinacy of configuration, a feature gate EnhancedLivenessProbe will be set in our project.
|
||
const ( | ||
AnnotationUsingEnhancedLiveness = "apps.kruise.io/using-enhanced-liveness" | ||
AnnotationNativeLivenessContext = "apps.kruise.io/livenessprobe-context" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apps.kruise.io/container-probe-context
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
0b69996
to
12178e2
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1467 +/- ##
==========================================
+ Coverage 47.89% 47.92% +0.02%
==========================================
Files 161 162 +1
Lines 23425 23482 +57
==========================================
+ Hits 11220 11254 +34
- Misses 10990 11009 +19
- Partials 1215 1219 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
12178e2
to
b5316f8
Compare
} | ||
|
||
func removeAndBackUpPodContainerLivenessProbe(pod *v1.Pod) (string, error) { | ||
if len(pod.Spec.Containers) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
b5316f8
to
e19bee7
Compare
return false, err | ||
} | ||
if context == "" { | ||
klog.Warningf("No found the native container livenessProbe config for pod: %s/%s", pod.Namespace, pod.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the warning seems unnecessary, consider remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
c03fc48
to
797df4b
Compare
Signed-off-by: jicheng.sk <jicheng.sk@alibaba-inc.com>
797df4b
to
26efbda
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: zmberg 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 |
Co-authored-by: jicheng.sk <jicheng.sk@alibaba-inc.com>
Ⅰ. Describe what this PR does
Q1: How to convert the standard livenessProbe configuration to this schema?
A webhook can convert the standard livenssProbe to the special field in pod annotations. The detail key is "apps.kruise.io/livenessprobe-context".
Ⅱ. Does this pull request fix one issue?
Ⅲ. Describe how to verify it?
Pod within "annotation: apps.kruise.io/using-enhanced-liveness = true" is created in Kubernetes apiServer. The livenessProbe configuration will be cleaned and backuped in Pod "annotation: apps.kruise.io/livenessprobe-context".
Ⅳ. Special notes for reviews