Skip to content
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

Helm enable to config controller manager & audit port #1438

Merged
merged 14 commits into from
Aug 23, 2021

Conversation

NissesSenap
Copy link
Contributor

What this PR does / why we need it:
The current port can be taken when running in hostNetwork mode.
To work around this I want to be able to configure the controller-manager port in the helm chart.

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
Fixes #

Special notes for your reviewer:

The current port can be taken when running in hostNetwork mode

Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
Edvin Norling added 2 commits July 14, 2021 14:29
Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
@NissesSenap
Copy link
Contributor Author

Remove the config for healthz port due to using a string instead of int.
One solution could to put in to two separate variables, one fort port and one for address.
It's probably solvable with helm some way as well. Would love some help to solve that.

This way we can still easily define the port but not the addr.
I think it's a good enough middle way.

Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
@NissesSenap
Copy link
Contributor Author

Re-added the healthz probe again and ignored the address feature. For now just adding port support.

@NissesSenap
Copy link
Contributor Author

For some reason that I don't know I can't get the

        - --health-addr=":{{ .Values.controllerManager.healthPort }}"

to work. When I try to run with the default value of 9090 i get:
If I remove the definition of --health-addr at all it works without an issue.

The generated value:

      --health-addr=":9090"

I assume I do some easy stupid error, if someone can point me in the correct direction it will be a quick fix.

{"level":"error","ts":1626271697.9305024,"logger":"setup","msg":"unable to start manager","error":"error listening on \":9090\": listen tcp: address tcp/9090\": unknown port","stacktrace":"github.com/go-logr/zapr.(*zapLogger).Error\n\t/go/src/github.com/open-policy-agent/gatekeeper/vendor/github.com/go-logr/zapr/zapr.go:132\nsigs.k8s.io/controller-runtime/pkg/log.(*DelegatingLogger).Error\n\t/go/src/github.com/open-policy-agent/gatekeeper/vendor/sigs.k8s.io/controller-runtime/pkg/log/deleg.go:144\nmain.main\n\t/go/src/github.com/open-policy-agent/gatekeeper/main.go:171\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:225"}

Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! WRT port numbers, I think the " quotes may be being included in the string argument, try dropping them?

Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
NissesSenap and others added 2 commits August 4, 2021 08:21
Edvin Norling added 2 commits August 4, 2021 09:51
Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
Also remove some withespace
Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
@NissesSenap NissesSenap changed the title Helm enable to config controller manager port Helm enable to config controller manager & audit port Aug 4, 2021
Update the GKE docs since we use the name webhook-server
you don't have to update the svc targetPort.

Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
Comment on lines -10 to +9
targetPort: 8443
targetPort: webhook-server
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Realized I need to change the gatekeeper-webhook-service port.
Instead of changing this using kustomize i changed this in the config file instead and use the name.

Thanks to this it will also simplify the GKE usage since they won't have to update the service since we are using the port name instead of the port number, I have updated the docs accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect!

@NissesSenap NissesSenap requested a review from maxsmythe August 4, 2021 08:24
Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the PR!

Comment on lines -10 to +9
targetPort: 8443
targetPort: webhook-server
Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect!

@maxsmythe maxsmythe requested review from sozercan and ritazh August 4, 2021 23:05
@codecov-commenter
Copy link

codecov-commenter commented Aug 4, 2021

Codecov Report

Merging #1438 (b17b24d) into master (5975122) will decrease coverage by 0.07%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1438      +/-   ##
==========================================
- Coverage   52.03%   51.95%   -0.08%     
==========================================
  Files          83       83              
  Lines        7593     7593              
==========================================
- Hits         3951     3945       -6     
- Misses       3263     3265       +2     
- Partials      379      383       +4     
Flag Coverage Δ
unittests 51.95% <ø> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/readiness/list.go 79.41% <0.00%> (-11.77%) ⬇️
...onstrainttemplate/constrainttemplate_controller.go 52.02% <0.00%> (-1.91%) ⬇️
...kg/controller/mutators/assign/assign_controller.go 47.42% <0.00%> (-1.72%) ⬇️
pkg/readiness/object_tracker.go 84.24% <0.00%> (+1.83%) ⬆️
pkg/watch/replay.go 81.46% <0.00%> (+2.24%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f33db10...b17b24d. Read the comment docs.

@NissesSenap
Copy link
Contributor Author

Thanks for all your help @maxsmythe do you want me to squash the commits or is it something that you do when you merge?

- --port=8443
- --port=HELMSUBST_DEPLOYMENT_CONTROLLER_MANAGER_PORT
- --health-addr=:HELMSUBST_DEPLOYMENT_CONTROLLER_MANAGER_HEALTH_PORT
- --prometheus-port=HELMSUBST_DEPLOYMENT_CONTROLLER_MANAGER_PROMETHEUS_PORT
Copy link
Member

Choose a reason for hiding this comment

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

thoughts about calling this metrics-port? since the exporter can target more than Prometheus

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds reasonable, i will update PR when i get to work tomorrow or later tonight.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess the main reason why I used prometheusPort is due to that the flag is --prometheus-port but if you change this flag in the future to make it more generic we won't have to change the helm values at least :)
I will just verify the change locally and then I will update the PR.

@sozercan
Copy link
Member

sozercan commented Aug 5, 2021

@NissesSenap no need to squash manually, we'll squash merge when PR merges

Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
@NissesSenap NissesSenap requested a review from sozercan August 6, 2021 09:07
@NissesSenap
Copy link
Contributor Author

Anything needed to move this PR forward? Would be great if we can get this merged.
Ping @sozercan @maxsmythe

Copy link
Member

@sozercan sozercan left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. LGTM

@sozercan sozercan merged commit 1901725 into open-policy-agent:master Aug 23, 2021
@NissesSenap
Copy link
Contributor Author

No worries, thank you

simongottschlag pushed a commit to simongottschlag/gatekeeper that referenced this pull request Aug 26, 2021
…ent#1438)

Co-authored-by: Sertaç Özercan <852750+sozercan@users.noreply.github.com>
@NissesSenap NissesSenap deleted the helm/port-config branch September 1, 2021 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants