Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

[WIP] Add controller pod list in nginx configuration templating #158

Closed
wants to merge 63 commits into from

Conversation

wayt
Copy link

@wayt wayt commented Nov 20, 2018

What this PR does / why we need it:

This add controller pod tracking for ingress-nginx. It will feed the list of Running ingress-nginx controller Pod to the configuration template.

It is still WIP, open for comments :)

This is required for https://github.com/Shopify/edgescale/issues/631

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:

Cc @ElvinEfendi @Shopify/edgescale

Fernando Diaz and others added 30 commits November 6, 2018 22:24
The following annotations will be added:

- enable-modsecurity
- enable-owasp-core-rules
- modsecurity-transaction-id

Fixes kubernetes#3167
Customize ModSecurity to be used in Locations
Update annotations.md. Remove Duplication.
Add e2e test for round robin load balancing
Restructure load balance e2e tests and update round robin test
Prevent X-Forwarded-Proto forward during external auth subrequest
bugfix: set canary attributes when initializing balancer
Convert isValidClientBodyBufferSize to something more generic
@wayt wayt changed the title Add controller pod list in nginx configuration templating [WIP] Add controller pod list in nginx configuration templating Nov 20, 2018
@wayt
Copy link
Author

wayt commented Nov 20, 2018

Here is an example:

$ k scale --replicas=3 deployment nginx-ingress-controller
deployment.extensions/nginx-ingress-controller scaled
$ http http://192.168.99.100:31362/debug "Host: http-echo.com"
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 1
Content-Type: text/html
Date: Tue, 20 Nov 2018 20:58:46 GMT
Server: nginx/1.15.6

3

$ k scale --replicas=1 deployment nginx-ingress-controller
deployment.extensions/nginx-ingress-controller scaled
$ http http://192.168.99.100:31362/debug "Host: http-echo.com"
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 1
Content-Type: text/html
Date: Tue, 20 Nov 2018 20:59:27 GMT
Server: nginx/1.15.6

1

$ k scale --replicas=5 deployment nginx-ingress-controller
deployment.extensions/nginx-ingress-controller scaled
$ http http://192.168.99.100:31362/debug "Host: http-echo.com"
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 1
Content-Type: text/html
Date: Tue, 20 Nov 2018 21:00:26 GMT
Server: nginx/1.15.6

5

return pods
}

func hasSameOwner(pod1, pod2 *corev1.Pod) bool {
Copy link
Author

Choose a reason for hiding this comment

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

That's the best way I've found to check if an ingress-nginx pod is under the same deployment than the running pod.

Is there any better function for that un k8s codebase?

Choose a reason for hiding this comment

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

I can not think of any better option. One could use namespace but it would not be a complete solution since technically speaking there can be two ingress-nginx deployments under single namespace.

@@ -833,6 +833,10 @@ stream {

{{ template "CUSTOM_ERRORS" (buildCustomErrorDeps $all.ProxySetHeaders (collectCustomErrorsPerServer $server)) }}

location /debug {
return 200 "{{ len $all.ControllerPods }}";
Copy link
Author

Choose a reason for hiding this comment

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

This is for testing purpose OFC

@wayt
Copy link
Author

wayt commented Nov 21, 2018

Replaced by upstream PR kubernetes#3455

@wayt wayt closed this Nov 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants