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

Allow multiple webhooks to be used #882

Merged
merged 2 commits into from Nov 11, 2020

Conversation

mmirecki
Copy link
Contributor

@mmirecki mmirecki commented Oct 12, 2020

The PR prepares gatekeeper to be able to create multiple
webhooks. Common webhook code was extracted to a separate
file, and an update to cert rotator is used that allows
to update multiple webhooks.

Tested:
Gatekeeper with the changes was run. An incoming resource
was successfuly denied request due to gatekeeper policy.

An example of adding a new webhook with these changes can be seen in PR 881. This PR adds a mutating webhook .

@mmirecki mmirecki force-pushed the multipleWebhooks branch 2 times, most recently from 95992fc to 14bd93c Compare October 22, 2020 10:37
@mmirecki mmirecki changed the title WIP: Allow cert rotator to work on multiple webhooks Allow multiple webhooks to be used Oct 22, 2020
@mmirecki mmirecki force-pushed the multipleWebhooks branch 2 times, most recently from a13e671 to 788ce4e Compare October 23, 2020 15:35
@codecov-io
Copy link

codecov-io commented Oct 23, 2020

Codecov Report

Merging #882 into master will increase coverage by 0.25%.
The diff coverage is 41.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #882      +/-   ##
==========================================
+ Coverage   43.46%   43.71%   +0.25%     
==========================================
  Files          47       48       +1     
  Lines        3173     3175       +2     
==========================================
+ Hits         1379     1388       +9     
+ Misses       1598     1595       -3     
+ Partials      196      192       -4     
Flag Coverage Δ
unittests 43.71% <41.17%> (+0.25%) ⬆️

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

Impacted Files Coverage Δ
pkg/webhook/policy.go 24.19% <0.00%> (-4.45%) ⬇️
pkg/webhook/stats_reporter.go 80.00% <ø> (ø)
pkg/webhook/common.go 63.63% <63.63%> (ø)
pkg/readiness/ready_tracker.go 69.81% <0.00%> (+0.72%) ⬆️
...onstrainttemplate/constrainttemplate_controller.go 56.67% <0.00%> (+0.97%) ⬆️
pkg/readiness/object_tracker.go 79.14% <0.00%> (+1.22%) ⬆️
pkg/readiness/list.go 91.30% <0.00%> (+8.69%) ⬆️

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 9ca4499...d7bf67f. Read the comment docs.

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.

1 note, 1 nit :)

pkg/webhook/common.go Show resolved Hide resolved
pkg/webhook/policy.go Outdated Show resolved Hide resolved
@mmirecki mmirecki force-pushed the multipleWebhooks branch 4 times, most recently from 87233fc to 3674cb7 Compare October 28, 2020 20:53
@mmirecki
Copy link
Contributor Author

mmirecki commented Oct 28, 2020 via email

@mmirecki mmirecki force-pushed the multipleWebhooks branch 2 times, most recently from 10a9dc4 to e1d240e Compare October 28, 2020 22:10
pkg/webhook/common.go Show resolved Hide resolved
@@ -243,33 +210,25 @@ func (h *validationHandler) getDenyMessages(res []*rtypes.Result, req admission.
logging.Process, "admission",
logging.EventType, "violation",
logging.ConstraintName, r.Constraint.GetName(),
logging.ConstraintGroup, r.Constraint.GroupVersionKind().Group,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we removing group/version from the log lines and events?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad (late night commits should be forbidden)

Copy link
Contributor

Choose a reason for hiding this comment

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

LOL no worries, thought I missed something

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like group/version are still missing?

@mmirecki mmirecki force-pushed the multipleWebhooks branch 3 times, most recently from 0000426 to 572dd3b Compare October 29, 2020 08:46
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.

1 comment about group/version

@@ -243,33 +210,25 @@ func (h *validationHandler) getDenyMessages(res []*rtypes.Result, req admission.
logging.Process, "admission",
logging.EventType, "violation",
logging.ConstraintName, r.Constraint.GetName(),
logging.ConstraintGroup, r.Constraint.GroupVersionKind().Group,
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like group/version are still missing?

@mmirecki mmirecki force-pushed the multipleWebhooks branch 2 times, most recently from cb67b23 to d7bf67f Compare November 2, 2020 12:50
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.

This looks like all of my comments have been addressed. Is there any other outstanding work here?

@mmirecki
Copy link
Contributor Author

mmirecki commented Nov 3, 2020

This looks like all of my comments have been addressed. Is there any other outstanding work here?

No, all done in this one.

@maxsmythe
Copy link
Contributor

@ritazh @shomron @sozercan LGTY?

@ritazh
Copy link
Member

ritazh commented Nov 10, 2020

PR looks great! Please resolve conflicts in go.mod.

The PR prepares gatekeeper to be able to create multiple
webhooks. Common webhook code was extracted to a separate
file, and an update to cert rotator is used that allows
to update multiple webhooks.

Tested:
Gatekeeper with the changes was run. An incoming resource
was successfuly denied request due to gatekeeper policy.

Signed-off-by: mmirecki <mmirecki@redhat.com>
@mmirecki
Copy link
Contributor Author

PR looks great! Please resolve conflicts in go.mod.

Done

@ritazh ritazh merged commit f3ec64a into open-policy-agent:master Nov 11, 2020
julianKatz pushed a commit to julianKatz/gatekeeper that referenced this pull request Nov 12, 2020
The PR prepares gatekeeper to be able to create multiple
webhooks. Common webhook code was extracted to a separate
file, and an update to cert rotator is used that allows
to update multiple webhooks.

Tested:
Gatekeeper with the changes was run. An incoming resource
was successfuly denied request due to gatekeeper policy.

Signed-off-by: mmirecki <mmirecki@redhat.com>

Co-authored-by: Rita Zhang <rita.z.zhang@gmail.com>
Signed-off-by: juliankatz <juliankatz@google.com>
@mmirecki mmirecki deleted the multipleWebhooks branch November 16, 2020 11:49
shomron pushed a commit to shomron/gatekeeper that referenced this pull request Nov 25, 2020
The PR prepares gatekeeper to be able to create multiple
webhooks. Common webhook code was extracted to a separate
file, and an update to cert rotator is used that allows
to update multiple webhooks.

Tested:
Gatekeeper with the changes was run. An incoming resource
was successfuly denied request due to gatekeeper policy.

Signed-off-by: mmirecki <mmirecki@redhat.com>

Co-authored-by: Rita Zhang <rita.z.zhang@gmail.com>
shomron pushed a commit to shomron/gatekeeper that referenced this pull request Nov 25, 2020
The PR prepares gatekeeper to be able to create multiple
webhooks. Common webhook code was extracted to a separate
file, and an update to cert rotator is used that allows
to update multiple webhooks.

Tested:
Gatekeeper with the changes was run. An incoming resource
was successfuly denied request due to gatekeeper policy.

Signed-off-by: mmirecki <mmirecki@redhat.com>
Signed-off-by: Oren Shomron <shomron@gmail.com>

Co-authored-by: Rita Zhang <rita.z.zhang@gmail.com>
shomron added a commit that referenced this pull request Dec 1, 2020
#982)

* Allow multiple webhooks to be created (#882)

The PR prepares gatekeeper to be able to create multiple
webhooks. Common webhook code was extracted to a separate
file, and an update to cert rotator is used that allows
to update multiple webhooks.

Tested:
Gatekeeper with the changes was run. An incoming resource
was successfuly denied request due to gatekeeper policy.

Signed-off-by: mmirecki <mmirecki@redhat.com>
Signed-off-by: Oren Shomron <shomron@gmail.com>

Co-authored-by: Rita Zhang <rita.z.zhang@gmail.com>

* Scope secrets cache to single namespace (#972)

Incorporate open-policy-agent/cert-controller#16 to avoid caching
cluster-wide secrets in certificate rotation controller. This will
reduce the memory consumption of Gatekeeper on clusters with a large
number of secrets defined.

Fixes: #831

Signed-off-by: Oren Shomron <shomron@gmail.com>

Co-authored-by: Max Smythe <smythe@google.com>

* Fix e2e test flakiness (#964)

* Fix e2e test flakiness

Signed-off-by: Max Smythe <smythe@google.com>
Signed-off-by: Oren Shomron <shomron@gmail.com>

Co-authored-by: Marcin Mirecki <mmirecki@redhat.com>
Co-authored-by: Rita Zhang <rita.z.zhang@gmail.com>
Co-authored-by: Max Smythe <smythe@google.com>
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.

None yet

4 participants