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

dynamic audit configuration api #67547

Merged
merged 2 commits into from Oct 17, 2018
Merged

Conversation

pbarker
Copy link
Contributor

@pbarker pbarker commented Aug 17, 2018

What this PR does / why we need it:
Implements dynamic audit configuration api

Special notes for your reviewer:
This is just the api changes for the dynamic audit configuration feature. Part 2 of the implementation is here #67257

Release note:

Add dynamic audit configuration api

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. release-note Denotes a PR that will be considered when it comes time to generate release notes. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 17, 2018
@pbarker pbarker changed the title dynamic audit api dynamic audit configuration api Aug 17, 2018
@tallclair tallclair self-requested a review August 17, 2018 16:53
@tallclair
Copy link
Member

/ok-to-test
/kind api-change
/priority important-soon
/sig auth
/milestone v1.12

/assign @kubernetes/api-reviewers

@k8s-ci-robot k8s-ci-robot added this to the v1.12 milestone Aug 17, 2018
@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. sig/auth Categorizes an issue or PR as relevant to SIG Auth. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 17, 2018
@tallclair
Copy link
Member

@kubernetes/sig-api-machinery-api-reviews

@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Aug 17, 2018
@pbarker
Copy link
Contributor Author

pbarker commented Aug 17, 2018

@tallclair would you like to see the storage and registration pieces for the api here or in the other PR?

@tallclair
Copy link
Member

I think they belong here.

@@ -0,0 +1,81 @@

#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

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

Why are we copying hack scripts into staging repos? That doesn't seem like a good precedent.

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 copied the pattern from the sample api server, should this be placed elsewhere?

Copy link
Member

Choose a reason for hiding this comment

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

It looks like we already do this: https://github.com/kubernetes/kubernetes/blob/master/hack/update-codegen.sh#L133

If you follow this pattern, this script should be called from there too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah thats the pattern I went with, if we theres a new pattern were shooting for I'm happy to change

Copy link
Member

Choose a reason for hiding this comment

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

:'(


// +k8s:openapi-gen=true
// WebhookClientConfig contains the information to make a connection with the webhook
type WebhookClientConfig struct {
Copy link
Member

Choose a reason for hiding this comment

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

Copied from the admission webhook configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, it essentially needs the same methods but there were incompatibilities with the admission implementation. Talking internally we decided to factor it into a common package. This PR doesn't look to refactor the admission pieces but does allow the owners of that package the ability to go that route in the future.

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Webhook describes a webhook and the resources and operations it applies to.
type Webhook struct {
Copy link
Member

Choose a reason for hiding this comment

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

I am confused about why this is a separate type from the backend configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah this may not be necessary, just wrapping the client configuration similar to the current admission package. We can scrap it


// ClientConfig holds the connection parameters for the webhook
// required
ClientConfig apiv1alpha1.WebhookClientConfig
Copy link
Member

Choose a reason for hiding this comment

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

If this is supposed to be a reference to a webhook, shouldn't it be a name? OTOH if this is where the webhook configuration is stored, why is there a top level Webhook type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a nested webhook configuration, the top level webhook type was just to keep parity with the original design, it can be scrapped though

@lavalamp
Copy link
Member

/assign

@lavalamp
Copy link
Member

lavalamp commented Aug 17, 2018 via email

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 17, 2018
@pbarker pbarker force-pushed the audit-api branch 2 times, most recently from d52579d to a0b5315 Compare August 18, 2018 19:20
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 18, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pbarker, thockin

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 15, 2018
Copy link
Member

@lavalamp lavalamp left a comment

Choose a reason for hiding this comment

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

Sorry, still one more thing about the defaulting...


var (
// DefaultQPS is the default QPS value
DefaultQPS = func(i int64) *int64 { return &i }(int64(10))
Copy link
Member

Choose a reason for hiding this comment

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

Something got scrambled, no doubt in a comment I gave :)

I suggest making these consts, declaring func intPtr(i int64) *int64 { return &i } somewhere, and calling intPtr(DefaultQPS) in the DefaultThrottle function.

Making these constant will prevent people from taking their address, which is the error I think it's important to avoid.

@pbarker pbarker force-pushed the audit-api branch 2 times, most recently from 0a03327 to 1c16ef6 Compare October 16, 2018 00:36
DefaultBurst = int64(15)
)

func intPtr(i int64) *int64 { return &i }
Copy link
Member

Choose a reason for hiding this comment

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

nit: use

utilpointer "k8s.io/utils/pointer"
utilpointer.Int64Ptr

(of dubious value, but we favour consistency...)

@tallclair
Copy link
Member

@lavalamp - I just noticed these APIs are being added to Kubernetes (k8s.io/api/auditregistration/v1alpha1/types.go) but auditing is really a generic apiserver feature. Should these APIs be moved to apiserver apis (k8s.io/apiserver/pkg/apis/auditregistration/v1alpha1/types.go)?

@pbarker
Copy link
Contributor Author

pbarker commented Oct 16, 2018

@tallclair that was initially explored but there were issues with the scheme #67547 (comment) In order to do this properly there wound need to be some fundamental changes to the apiserver

@tallclair
Copy link
Member

@pbarker Thanks, but I interpreted that comment as separating audit & auditregistration into 2 different API groups. IIUC, the auditregistration API group could still be part of the apiserver apis. I don't feel particularly strongly on the distinction, but I'd like an ACK from someone with more of a stake in the difference.

@pbarker
Copy link
Contributor Author

pbarker commented Oct 16, 2018

Sorry @tallclair, couldn't remember where all the conversations happened, there is more context here #67547 (comment)

@pbarker
Copy link
Contributor Author

pbarker commented Oct 16, 2018

/retest

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Oct 16, 2018

@pbarker: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-local-e2e-containerized be4c4a8f5c6f56222ce9818e34f64b85ecd8b8e9 link /test pull-kubernetes-local-e2e-containerized

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

func DefaultThrottle() *auditregistrationv1alpha1.WebhookThrottleConfig {
return &auditregistrationv1alpha1.WebhookThrottleConfig{
QPS: utilpointer.Int64Ptr(DefaultQPS),
Burst: utilpointer.Int64Ptr(DefaultBurst),
Copy link
Member

Choose a reason for hiding this comment

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

I argued so hard against making these library functions :( I just don't think it's worth the import dependency to avoid a 3 line function definition.

But this is tilting at windmills so I'm not asking for a change :(

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, sorry. To quote my original comment:

(of dubious value, but we favour consistency...)

@lavalamp
Copy link
Member

Give me a minute to think about whether it now makes sense to put this in with the meta api.

@spiffxp
Copy link
Member

spiffxp commented Oct 17, 2018

/milestone v1.13
I'm adding this to the v1.13 milestone since it relates to kubernetes/enhancements#600 which is currently planned for v1.13

@lavalamp
Copy link
Member

/lgtm

I don't want to block this any more. Likely it should go in a more general place. We can always move it later.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 17, 2018
@k8s-ci-robot k8s-ci-robot merged commit 0652e09 into kubernetes:master Oct 17, 2018
@WanLinghao
Copy link
Contributor

WanLinghao commented Nov 2, 2018

@pbarker In the design doc(https://github.com/kubernetes/community/blob/master/keps/sig-auth/0014-dynamic-audit-configuration.md), it is mentioned that the Policy in dynamic audit feature is v1beta1 of legacy audit. Why it is changed in your implementation. Did I miss anything?

 // Policy is the current audit v1beta1 Policy object
    // if undefined it will default to the statically configured cluster policy if available
    // if neither exist the backend will fail
    Policy *Policy

@pbarker
Copy link
Contributor Author

pbarker commented Nov 2, 2018

Hey @WanLinghao, this was a piece we iterated on in this PR. There was a desire to have the audit mechanism in the API be more composable and additive, so that as an app developer I could write audit rules and have them contained with the rest of my deployment configuration. So we temporarily slimmed down the audit policy so that we could do this rework as we head to beta. We'll be having some talks on this in the future.

@WanLinghao
Copy link
Contributor

@pbarker So do we have any plan to push the Policy in dynamic audit feature into something similar with the one in legacy audit feature?

@pbarker
Copy link
Contributor Author

pbarker commented Nov 5, 2018

@WanLinghao its not possible to delete fields from an API once you put them there. So we scoped down the policy object to the bare minimum until we have a clear direction, then it will be added to.

@pbarker pbarker deleted the audit-api branch December 18, 2018 22:50
@tallclair tallclair mentioned this pull request Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver area/code-generation area/kubeadm area/kubectl area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/autoscaling Categorizes an issue or PR as relevant to SIG Autoscaling. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet