-
Notifications
You must be signed in to change notification settings - Fork 130
Add readiness probe for NGINX on pod startup #3629
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
base: main
Are you sure you want to change the base?
Conversation
7cb82dc
to
1b718a5
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3629 +/- ##
==========================================
+ Coverage 86.89% 86.91% +0.01%
==========================================
Files 127 127
Lines 15287 15333 +46
Branches 62 62
==========================================
+ Hits 13284 13326 +42
- Misses 1849 1853 +4
Partials 154 154 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fad90d4
to
a48dbf0
Compare
// Container defines container fields for the NGINX container. | ||
// | ||
// +optional | ||
Container ContainerSpec `json:"container"` | ||
|
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.
Looks like some unnecessary changes to the DeploymentSpec and DaemonSetSpec?
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.
weird it comes out as a separate addition, i just re-arranged fields for the linter
// Deployment is the configuration for the NGINX Deployment.
type DeploymentSpec struct {
// Container defines container fields for the NGINX container.
//
// +optional
Container ContainerSpec `json:"container"`
// Number of desired Pods.
//
// +optional
Replicas *int32 `json:"replicas,omitempty"`
// Pod defines Pod-specific fields.
//
// +optional
Pod PodSpec `json:"pod"`
}
// DaemonSet is the configuration for the NGINX DaemonSet.
type DaemonSetSpec struct {
// Container defines container fields for the NGINX container.
//
// +optional
Container ContainerSpec `json:"container"`
// Pod defines Pod-specific fields.
//
// +optional
Pod PodSpec `json:"pod"`
}
just have all the original fields re-arranged
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.
Wonder why the linter would care now? It's been in this order for awhile with no issue.
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.
Not a huge deal if it's blocking you from using the old order.
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.
Maybe because the containerSpec had additions and its space bytes changed, I'm assuming.
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.
Ah, good point.
apis/v1alpha2/nginxproxy_types.go
Outdated
// If not specified, the default port is 8081. | ||
// | ||
// +optional | ||
// +kubebuilder:default:=8081 |
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.
Part of me thinks we don't actually set this default in the CRD, and just set it internally. Otherwise our default NginxProxy resource is going to render this, which I don't think it needs to since it's a niche field that people probably aren't going to update very often.
## Defines the settings for the data plane readiness probe. This probe returns Ready when the NGINX data plane is ready to serve traffic. | ||
readinessProbe: {} | ||
# @schema | ||
# type: integer | ||
# minimum: 1 | ||
# maximum: 65535 | ||
# @schema | ||
# -- Port in which the readiness endpoint is exposed. | ||
# port: 8081 | ||
|
||
# The Kubernetes probe can also be configured by modifying the NginxProxy resource. | ||
|
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.
Let's just put this under the container spec as well, it doesn't need to be at top level field. Then in the yaml, you shouldn't need to add it since it'll be added automatically in the container spec.
apis/v1alpha2/nginxproxy_types.go
Outdated
// Probe describes the Kubernetes Probe configuration. | ||
// | ||
// +optional | ||
*corev1.Probe `json:",inline"` |
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.
I'm actually reconsidering this now....because I'm not sure we want to allow a user to configure the entire probe. Mainly because then it would require updates to the nginx endpoint that we expose. And what if they set a GRPCAction instead of HTTPAction? We can't act on that.
I think until we get user feedback on the need for full probe configuration, we keep things limited. Let's just expose port and initialdelayseconds for now, like we did before. Sorry for the back and forth.
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.
No worries, but just to clarify. They wouldn't be able to set GRPCAction
in our NGINX deployment spec, because we only copy over specific fields from the probe
probe.InitialDelaySeconds = probeSpec.InitialDelaySeconds
probe.TimeoutSeconds = probeSpec.TimeoutSeconds
probe.PeriodSeconds = probeSpec.PeriodSeconds
probe.SuccessThreshold = probeSpec.SuccessThreshold
probe.FailureThreshold = probeSpec.FailureThreshold
probe.TerminationGracePeriodSeconds = probeSpec.TerminationGracePeriodSeconds
So. even if the set the field ProbeHandler
to GRPCAction
, it wouldn't get copied over. Maybe I should mention that in the comment for Probe instead of making changes?
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.
Good to know, though it would be odd for a user to be able to set a bunch of fields and then none of them get propagated (that's a weird and non-deterministic API). My original idea was just take all of their fields and then set them. I think we just keep the simple case for now.
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.
I agree, but what my original thinking was that we set the ProbeHandler
specific to our needs that being at the endpoint /readyz
and configurable port. Along with that we carry over other probe settings.
So, to ensure I got all the details right
- Add readiness probe under
container
in values.yaml - Expose two fields
port
andinitialDelaySeconds
only with defaults only set in the code and not at API spec level
Would we also run into these issues for when we allow custom patches for Deployment, Service and ocntainer or K8s API will handle it during the merge calls?
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.
yes, those details sound right. We can't expose ProbleHandler to users if we're not going to honor all the fields, that's a broken API.
For custom patches, there's certainly a grey area there, which we'll need to document (@ciarams87). Some fields may not work as expected because it could require internal changes (like with the probe endpoint and such). But that's the nature of allowing a raw JSON patch.
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.
okay good to know
572c5b4
to
5dd1fd8
Compare
Proposed changes
Write a clear and concise description that helps reviewers understand the purpose and impact of your changes. Use the
following format:
Problem: Users want to have a readiness probe for NGINX on startup to verify pod health.
Solution: Expose readiness probe configuration fields in the
NginxProxy
spec, allowing users to customize them as needed. By default, deploy NGINX with a readiness probe at the/readyz
endpoint.Testing: Manual testing
values.yaml
Nginx proxy Config
Nginx starts successfully, Nginx Proxy config has correct values for readiness probe fields, Nginx deployment reflects the same
Nginx restarts a new pod successfully, Nginx deployment reflects the same, server block port is updated
DaemonSet
as well.Please focus on (optional): If you any specific areas where you would like reviewers to focus their attention or provide
specific feedback, add them here.
Closes #3594
Checklist
Before creating a PR, run through this checklist and mark each as complete.
Release notes
If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.