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

Added image-policy proposal #27129

Merged
merged 1 commit into from
Aug 5, 2016
Merged

Added image-policy proposal #27129

merged 1 commit into from
Aug 5, 2016

Conversation

erictune
Copy link
Member

@erictune erictune commented Jun 9, 2016

Add proposal for image policy.

@k8s-github-robot k8s-github-robot added kind/design Categorizes issue or PR as related to design. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels Jun 9, 2016
@erictune
Copy link
Member Author

erictune commented Jun 9, 2016

@wteiken

@erictune
Copy link
Member Author

erictune commented Jun 9, 2016

@philips it might make sense to have https://github.com/coreos/clair be a backend for this image policy webhook, or something like that? Can you at-mention the right people from Clair?

Also @ericchiang because it is a type of authorization, but intentionally not in RBAC.

@erictune
Copy link
Member Author

erictune commented Jun 9, 2016

@roberthbailey

- For non-replicated things (size 1 ReplicaSet, PetSet), a single node failure may disable it.
- a node rolling update will eventually check for liveness of replacements, and would be throttled if
in the case when the image was no longer allowed and so replacements could not be started.
- rapid node restarts will cause existing pod objects to be restared by kubelet.
Copy link
Contributor

@ericchiang ericchiang Jun 9, 2016

Choose a reason for hiding this comment

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

s/restared/restarted/

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@erictune
Copy link
Member Author

erictune commented Jun 9, 2016

@jerbia

@ericchiang
Copy link
Contributor

cc @gtank @ecordell

}

// ImageReviewSpec is a description of the token authentication request.
type ImageReviewSpec struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to know the authenticated user / service account that is attempting to perform this action? Who can matter as much as what in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nm, saw the comment below. Commented there.

@erictune
Copy link
Member Author

xref: #22888

- a newly created replicaSet will be unable to create Pods.
- updating a deployment will be safe in the sense that it will detect that the new ReplicaSet is not scaling
up and not scale down the old one.
- an existing replicaSet will not be unable to create Pods that replace ones which are terminated. If this is due to
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "will not be unable to create" -> "will be unable to create"

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.


## Admission controller

An `ImagePolicyWebhook` admission controller will be written. The admission controller examines all pod objects which are
Copy link
Member

Choose a reason for hiding this comment

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

Is the webhook going to be tried until success? How would it distinguish retryable failure from permanent failure?

Copy link
Member Author

Choose a reason for hiding this comment

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

The admission controller will admit if the webhook times out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will the admin be able to set a policy for a namespace (e.g., fail-open/fail-closed)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Will this be a generic webhook for any admission plugin? I'd like to see a generic one and it seems like the work here would be about the same.

Copy link
Member Author

Choose a reason for hiding this comment

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

It will not be a generic webhook. A generic webhook would need a lot more discussion:

  • a generic webhook needs to touch all objects, not just pods. So it won't have a fixed schema
  • a generic webhook client needs to ignore kinds it doesn't care about, or the apiserver needs to know which backends care about which kinds
  • it exposes our whole API to a webhook without giving us (the project) any chance to review or understand how it is being used.
  • because we don't know which fields of an object are inspected by the backend, caching is not effective. Sending fewer fields allows caching.
  • sending fewer fields makes it possible to rev the version of the webhook request slower than the version of our internal obejcts (e.g. pod v2 could still use imageReview v1.)
  • probably lots more reasons.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added section about this in Alternatives section.

@erictune
Copy link
Member Author

@fabioy this is the proposal for image admission controller that we talked about.

- only run images that are scanned to confirm they do no contain vulnerabilities
- only run images that use a "required" base image
- only run images that contain binaries which were built from peer reviewed, checked-in source
by a trusted compiler toolchain.
Copy link
Contributor

Choose a reason for hiding this comment

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

@erictune isn't the other obvious example images that are signed by a public key in a key list?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I would do that in conjunction with other controls. I might want to also enforce the whitelist of signing keys at the node level, at which point the check in the apiserver is more a nice-to-have. But you could do it that way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding your suggestion to the doc.

@erictune
Copy link
Member Author

I've addressed most comments and updated the docs.

The open issues, as I see it, are:

  • how to handle init-containers
  • if the schema should be a subset of PodSpec, so that additional fields fall in the same places.
  • something about interfaces that I don't quite follow.

@smarterclayton
Copy link
Contributor

smarterclayton commented Jul 26, 2016 via email

@philips
Copy link
Contributor

philips commented Jul 27, 2016

cc the Clair team @Quentin-M @jzelinskie @josephschorr

## Admission controller

An `ImagePolicyWebhook` admission controller will be written. The admission controller examines all pod objects which are
created or updated. It can either admit the pod, or reject it. If it is rejected, the request sees a `403 FORBIDDEN`

Choose a reason for hiding this comment

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

This description is a little vague in the plurality sense. I think this should work over a set of webhooks rather than one. For example, this Pull Request on GitHub has multiple webhooks that must validate it before it is merged.

Copy link
Contributor

Choose a reason for hiding this comment

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

I kinda understood this as being able to setup multiple, but having it explicit in the proposal is a good idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

This description is a little vague in the plurality sense. I think this should work over a set of webhooks rather than one. For example, this Pull Request on GitHub has multiple webhooks that must validate it before it is merged.

Seems like we could support a single callout and if someone wanted a union, they could write the union in their particular handler. That keeps our core code out of the business of deciding between the ands, ors, and trumps, which inevitably follow the "give me more than one".

I don't see an issue with making a reference impl for the webhook that can provide a simple union, but I don't think we want to bake multiples into our admission plugin.

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel convinced.

Copy link

@jzelinskie jzelinskie Jul 31, 2016

Choose a reason for hiding this comment

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

@deads2k It seems there's precedent in other parts of k8s for doing it the way you have described, so I agree.

@k8s-github-robot k8s-github-robot added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Jul 28, 2016
The WebHook request and response are JSON, and correspond to the following `go` structures:

```go
// Filename: pkg/apis/authentication.k8s.io/register.go
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these types intended to live in the authentication.k8s.io API group? Is the package name correct here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, fixed.


// ImageReviewContainerSpec is a description of a container within the pod creation request.
type ImageReviewContainerSpec struct {
Image string
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be Image, ImageHash string?

Copy link
Member Author

Choose a reason for hiding this comment

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

Images can be specified to docker, and in pod.spec.container[].image as either image:tag or image@SHA:012345679abcdef. So, this field also accepts either format.

It is up to the backend to decide if it accepts image:tag or only accepts image@SHA:012345679abcdef format. There are reasons you might chose to do either way, so this API doesn't have an opinion.

@Q-Lee Q-Lee added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 4, 2016
@Q-Lee
Copy link
Contributor

Q-Lee commented Aug 4, 2016

This is very close. Let's put this and I'll make the remaining changes in a new, narrower PR.

@k8s-github-robot
Copy link

PR changed after LGTM, removing LGTM. @erictune @philips @soltysh @Q-Lee

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 5, 2016
@k8s-bot
Copy link

k8s-bot commented Aug 5, 2016

GCE e2e build/test passed for commit 9d59ae5.

@erictune erictune merged commit 6f0bc85 into kubernetes:master Aug 5, 2016
xingzhou pushed a commit to xingzhou/kubernetes that referenced this pull request Dec 15, 2016
@erictune erictune deleted the imgprov branch August 8, 2017 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. kind/design Categorizes issue or PR as related to design. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet