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

1417 policy webhooks rev2 #3

Closed
wants to merge 4 commits into from
Closed

Conversation

coyote240
Copy link
Owner

This PR will be submitted upstream to address cosign issue sigstore#1417, creating the basic types and CRD for ClusterImagePolicy as proposed in https://docs.google.com/document/d/1gBLEOOHWOmvHVsoJbgGU74GdwA6CGxMRp3MAeEB50l4/edit#

Comment on lines +17 to +26
rules:
- apiGroups:
- sigstore.dev
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- clusterimagepolicies

Choose a reason for hiding this comment

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

This will be automatically populated by the webhook when it adds the caBundle

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh cool, we didnt realize that knative was modifying the webhook configurations. Made the changes now!

Comment on lines +45 to +54
rules:
- apiGroups:
- sigstore.dev
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- clusterimagepolicies

Choose a reason for hiding this comment

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

same

Comment on lines +96 to +101
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

Choose a reason for hiding this comment

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

Can we avoid checking in status with crd-gen?

Copy link
Collaborator

Choose a reason for hiding this comment

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

sure! we will remove this.

@@ -42,7 +42,7 @@ spec:
- name: webhook
# This is the Go import path for the binary that is containerized
# and substituted here.
image: ko://github.com/sigstore/cosign/cmd/cosign/webhook
image: ko.local/webhook:70c8e156ba665ade1745f695dad6052f7f265e91c28aaaab6710ece2d5274224

Choose a reason for hiding this comment

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

Revert before going upstream.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah we are creating a new branch with merge commits and these changes removed

Comment on lines +9 to +11
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=clusterimagepolicies,scope=Cluster
// +kubebuilder:storageversion

Choose a reason for hiding this comment

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

I think we're pretty quickly get tired of juggling both of these, and I know when Knative Eventing briefly used controller-runtime they ended up having to maintain their own fork at times due to dependency hell.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I dont understand. Are you saying we should not use kubebuilder?

Choose a reason for hiding this comment

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

I'm saying that if we use it, it shouldn't be "load bearing" and we should be prepared to rip it out if we need to (e.g. due to dep hell).

You can get basically every piece of codegen we need from K8s/Knative directly.

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

That’s exactly what I’d use

Choose a reason for hiding this comment

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

We don't generate the whole CRD, which is mostly boilerplate. We have tooling to generate the openapiv3 schemas here: https://github.com/knative-sandbox/sample-controller/blob/6a2c2d197b4f37e6020ea19639a1077b7f6e50ab/cmd/schema/main.go#L30-L31

I can take care of adding this stuff (and the webhooks) if you want to focus on filling out the schema/defaulting/validation?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh it is okay, we can add it. We were looking to see examples of how it is generated, thats all.

Choose a reason for hiding this comment

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

Most of the boilerplate is, like additionalPrinterColumns, but this is the output from the tool:
https://github.com/knative-sandbox/sample-controller/blob/6a2c2d197b4f37e6020ea19639a1077b7f6e50ab/config/300-simpledeployment.yaml#L32-L86

Choose a reason for hiding this comment

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

We can probably use yq to get this added to ./hack/update-codegen.sh

func NewPolicyMutatingAdmissionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
return defaulting.NewAdmissionController(
ctx,
"defaulting.clusterimagepolicy.sigstore.dev",

Choose a reason for hiding this comment

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

Suggestion: I'm wondering if we want to add cosigned.sigstore.dev here. I don't have strong feelings.

Choose a reason for hiding this comment

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

}

type SecretRef struct {
Name string `json:"name,omitempty"`

Choose a reason for hiding this comment

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

I suggest you use instead *v1.SecretReference from ``k8s.io/api/core/v1` instead of creating a new type.

)

type ClusterImagePolicySpec struct {
Images []ImagePattern `json:"images,omitempty"`

Choose a reason for hiding this comment

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

I don't think the Images field should be omitted if empty.

Copy link
Owner Author

Choose a reason for hiding this comment

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

We've dropped omitempty for now.

}

type ImagePattern struct {
Pattern string `json:"pattern,omitempty"`

Choose a reason for hiding this comment

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

same as above, json:"pattern:

OCI string `json:"oci"`
}

type TLog struct {

Choose a reason for hiding this comment

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

suggestion: it'd be great to have some golang documentation to explain the purpose of each field. That would generate some valuable documentation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

cool, sounds good. we will add it.

@kkavitha kkavitha force-pushed the 1417-policy-webhooks-rev2 branch from 1413194 to 0850842 Compare February 23, 2022 15:38
@kkavitha kkavitha closed this Mar 3, 2022
@kkavitha kkavitha deleted the 1417-policy-webhooks-rev2 branch March 3, 2022 16:06
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