-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Watch controller Pods and make then available in k8sStore #3455
Conversation
} | ||
|
||
// hasSameOwner returns true if both Pods share at least 1 owner | ||
func hasSameOwner(pod1, pod2 *corev1.Pod) bool { |
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.
@aledbf do you know any better way of validating two Pods are deployed by the same Deployment
?
|
||
// getCurrentPod returns the current Pod based on environment namespace and name | ||
func (s k8sStore) getCurrentPod() *corev1.Pod { | ||
ns := os.Getenv("POD_NAMESPACE") |
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.
@aledbf do you know any better of getting current controller Pod
?
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've replaced this with k8s.GetPodDetails
https://github.com/kubernetes/ingress-nginx/pull/3455/files#diff-ece58b3bebec02a6d3173c8d8099d298R257
rootfs/etc/nginx/template/nginx.tmpl
Outdated
@@ -924,6 +924,10 @@ stream { | |||
|
|||
{{ template "CUSTOM_ERRORS" (buildCustomErrorDeps $all.ProxySetHeaders (collectCustomErrorsPerServer $server)) }} | |||
|
|||
location /debug { |
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 is for example purpose, I'll remove that
@wayt what are you trying to do exactly? I don't want to add an additional listener (pod listener will increase the apiserver pressure considerably) |
We would like to have the controller pod list available within the nginx configuration templating. I understand that would add pressure on the apiserver, would you have any better idea regarding this? This doesn't require a high reactivity and could be done much more lazily. |
Is there an HTTP endpoint to get current number of replicas (in corresponding deployment resource) from API server? Or maybe just HTTP GET current list of replicas from API server? The problem with this is when a replica dies we won't know it. |
@wayt with the current information we already have about the pod, using the |
@aledbf oh great! I didn't know about that. I'll have a look. |
@wayt using the current information about the pod to build a watcher using the same labels that the pod is also another option (cleaner) |
41362de
to
8eb5eb2
Compare
I've updated the PR, it now keeps track of the controller Pods based on labels. /assign @ElvinEfendi |
) | ||
|
||
// PodLister makes a Store that lists Pods. | ||
type PodLister struct { |
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.
Why are you adding a podlister?
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.
Do you think I can only use a cache.Store
? Since we don't need any custom function.
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, it's fine. I posted the comment before reading the complete PR, sorry :)
/approve |
@wayt waiting @ElvinEfendi lgtm |
@@ -773,3 +835,20 @@ func (s k8sStore) Run(stopCh chan struct{}) { | |||
go wait.Until(s.checkSSLChainIssues, 60*time.Second, stopCh) | |||
} | |||
} | |||
|
|||
// ListControllerPods returns a list of ingress-nginx controller Pods | |||
func (s k8sStore) ListControllerPods() []*corev1.Pod { |
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.
Can you make this clear that it returns only Running
pods? Something like ListRunningControllerPods
return client.CoreV1().Pods(store.pod.Namespace).List(options) | ||
}, | ||
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { | ||
|
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 need for this newline. same as above
/lgtm The two comments can be addressed in the subsequent PR when we implement posting this data to Lua. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aledbf, ElvinEfendi, wayt 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 |
/remove hold |
/hold cancel |
What this PR does / why we need it:
This add controller pod tracking for ingress-nginx. The list is available from the store
ListControllerPods()
function.The purpose behind this is to track the number of running replicas.
A PR will follow to push this into a lua shared dict.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #Special notes for your reviewer: