Skip to content

Allow VolumeMounts to be specified in Container. - #3061

Merged
knative-prow-robot merged 5 commits into
knative:masterfrom
mattmoor:volumes
Feb 5, 2019
Merged

knative-prow-robot merged 5 commits into
knative:masterfrom
mattmoor:volumes

Conversation

@mattmoor

@mattmoor mattmoor commented Feb 1, 2019

Copy link
Copy Markdown
Contributor

This extends the knative/serving API to allow for ConfigMaps and Secrets to be mounted as volumes. All other forms of volume are disallowed.

The container's volume mounts must include all of the provided volumes, they must be ReadOnly (this is defaulted in the webhook), and only a MountPath may be specified.

Related: #1504

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 1, 2019
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 1, 2019
@mattmoor

mattmoor commented Feb 1, 2019

Copy link
Copy Markdown
Contributor Author

Interestingly, we already pass-thru rev.VolumeMounts here, so this won't pass e2e testing as-is...

@mattmoor

mattmoor commented Feb 1, 2019

Copy link
Copy Markdown
Contributor Author

I've updated this to also pass things through (and unit test it). I want to poke at it a bit more manually, and then add an e2e test tomorrow.

@mattmoor

mattmoor commented Feb 1, 2019

Copy link
Copy Markdown
Contributor Author

I've also fixed the markdown linting 🤦‍♂️

@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 1, 2019
@mattmoor

mattmoor commented Feb 1, 2019

Copy link
Copy Markdown
Contributor Author

Ok, this now has conformance tests for a ConfigMap and a Secret as well.

@mattmoor

mattmoor commented Feb 1, 2019

Copy link
Copy Markdown
Contributor Author

@evankanderson I believe we need to update this portion of the runtime contract as well, do you have any suggested wording?

Mounts

Platform providers SHOULD NOT allow additional volume mounts. Stateless
applications should package their dependencies within the container. As
serverless applications are expected to scale horizontally and statelessly,
per-container volumes are likely to introduce state and scaling bottlenecks and
are NOT RECOMMENDED.

@mattmoor

mattmoor commented Feb 1, 2019

Copy link
Copy Markdown
Contributor Author

I want to make sure certain folks have a crack at this, so I'm going to put a
/hold

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 1, 2019
@mattmoor
mattmoor force-pushed the volumes branch 2 times, most recently from 82086cd to 3c53040 Compare February 1, 2019 06:20

@vagababov vagababov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice stuff! Thanks!

Comment thread test/conformance/volumes_test.go Resolved
@mattmoor
mattmoor force-pushed the volumes branch 2 times, most recently from cf4c807 to 3367836 Compare February 1, 2019 06:51
mattmoor added a commit to mattmoor/docs that referenced this pull request Feb 1, 2019
This requires this new feature available in 0.4: knative/serving#3061
mattmoor added a commit to mattmoor/docs that referenced this pull request Feb 1, 2019
This requires this new feature available in 0.4: knative/serving#3061
@mattmoor

mattmoor commented Feb 1, 2019

Copy link
Copy Markdown
Contributor Author

Here's a sample for the Secrets portion of this: knative/docs#852

@vagababov vagababov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 1, 2019
@knative-prow-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mattmoor, vagababov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@mattmoor

mattmoor commented Feb 2, 2019

Copy link
Copy Markdown
Contributor Author

/retest

@mattmoor

mattmoor commented Feb 2, 2019

Copy link
Copy Markdown
Contributor Author

/retest

Looks like our test setup is really struggling with TestScaleToN/scale-50 🤦‍♂️

This extends the knative/serving API to allow for ConfigMaps and Secrets to be mounted as volumes.  All other forms of volume are disallowed.

The container's volume mounts must include all of the provided volumes, they must be ReadOnly (this is defaulted in the webhook), and only a MountPath may be specified.

These are then passed through to the Deployment, and the rest is up to K8s.

This adds two conformance tests, one for each of ConfigMap and Secret, which simply expects the Service to echo back the randomized text read from the mounted volume.

Related: knative#1504

@evankanderson evankanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall, this LGTM, except for the question about exclusion between (/tmp, /var/log, dev), and volumeMounts. (IMO, it's fine for the deployer to stomp the name-resolution related files in /etc if they know what they are doing.)

It looks like this also needs some text in docs/runtime-contract.md for the new volume mount types, including guidance about when and how to use ConfigMaps and Secrets? I suggest something like the following:

In general, stateless applications should package their dependencies within the container and not rely on mutable external state for templates, logging configuration, etc. In some cases, it may be necessary for certain application settings to be overridden at deploy time (for example, database backends or authentication credentials). When these settings need to be loaded via a file, read-only mounts of application configuration and secrets are supported by ConfigMap and Secrets volumes. Platform providers MAY apply updates to Secrets and ConfigMaps while the application is running; these updates could complicate rollout and rollback. It is up to the developer to choose appropriate policies for mounting and updating ConfigMap and Secrets which are mounted as volumes.

As serverless applications are expected to scale horizontally and statelessly, per-container volumes are likely to introduce state and scaling bottlenecks and are NOT RECOMMENDED.

Comment thread test/conformance/volumes_test.go Resolved
Comment thread test/conformance/volumes_test.go Resolved
Comment thread test/conformance/volumes_test.go Resolved
Add validation checks for the mountPath of volumeMounts (for conflicts with reserved paths).

Improve resource naming in the conformance testing.

@mattmoor mattmoor left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

/hold cancel

Now that we're updated the runtime contract text.

I believe I've addressed all of the feedback here, so this is RFAL.

Comment thread test/conformance/volumes_test.go Resolved
Comment thread test/conformance/volumes_test.go Resolved
Comment thread test/conformance/volumes_test.go Resolved
@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 5, 2019
@mattmoor

mattmoor commented Feb 5, 2019

Copy link
Copy Markdown
Contributor Author

Also, thanks for the updated wording for the runtime contract @evankanderson!

@markusthoemmes markusthoemmes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few drive-by comments.

Overall lgtm.

Comment thread test/conformance/volumes_test.go Resolved
Comment thread test/util.go
)

const (
HelloVolumePath = "/hello/world"

Copy link
Copy Markdown
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 specify this as a const and use it in the image? Could we not pass a path to the application as a query parameter and the app then tries to read that path? That'd keep these settings contained in the test and potentially make the image reusable for other filesystem checks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That was the content of my https://github.com/knative/serving/pull/3061/files#r253688795

It sounds like that refactor and consolidation of all our test images is in flight, but will be a separate PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, but I think I'd rather address this holistically in follow up than starting to build general purpose images for individual tests. @dgerd has been doing this for the conformance testing, so it is possible that this can reuse that image.

Comment thread test/conformance/volumes_test.go Resolved
Comment thread test/util.go
)

const (
HelloVolumePath = "/hello/world"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That was the content of my https://github.com/knative/serving/pull/3061/files#r253688795

It sounds like that refactor and consolidation of all our test images is in flight, but will be a separate PR.

@knative-metrics-robot

Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/serving/v1alpha1/revision_validation.go 94.7% 96.5% 1.8

@evankanderson

Copy link
Copy Markdown
Member

/lgtm

/hold if Matt wants more eyes on this.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 5, 2019
@mattmoor

mattmoor commented Feb 5, 2019

Copy link
Copy Markdown
Contributor Author

@evankanderson That /hold won't work, but I'd remove it anyways as there have already been several. thanks for the detailed review!

@mattmoor

mattmoor commented Feb 5, 2019

Copy link
Copy Markdown
Contributor Author

502 talking to https://go.googlesource.com/tools/

/test pull-knative-serving-build-tests

@knative-prow-robot
knative-prow-robot merged commit 18d550c into knative:master Feb 5, 2019
@mattmoor
mattmoor deleted the volumes branch February 5, 2019 18:52
ZhiminXiang pushed a commit to ZhiminXiang/serving-1 that referenced this pull request Feb 7, 2019
* Allow VolumeMounts to be specified in Container.

This extends the knative/serving API to allow for ConfigMaps and Secrets to be mounted as volumes.  All other forms of volume are disallowed.

The container's volume mounts must include all of the provided volumes, they must be ReadOnly (this is defaulted in the webhook), and only a MountPath may be specified.

These are then passed through to the Deployment, and the rest is up to K8s.

This adds two conformance tests, one for each of ConfigMap and Secret, which simply expects the Service to echo back the randomized text read from the mounted volume.

Related: knative#1504

* Fix the type name used in the spec changed.

* Incorporate new runtime contract wording.

Add validation checks for the mountPath of volumeMounts (for conflicts with reserved paths).

Improve resource naming in the conformance testing.

* Rename functional options and improve test errors.

* Check absolute paths, reserved directory parents, and a few other pieces of feedback.
knative-prow-robot pushed a commit to knative/docs that referenced this pull request Feb 19, 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. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants