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 subpath functionality to --mount flag #1655

Merged
merged 4 commits into from
Apr 18, 2022

Conversation

vyasgun
Copy link
Contributor

@vyasgun vyasgun commented Apr 14, 2022

Description

User can now specify subpath of a volume to be mounted using the --mount flag

gvyas-mac:client gvyas$ ./kn service update hello-example-2 --image gcr.io/knative-samples/helloworld-go --mount /mydir2=cm:cm1/xyzzz/jhg --mount /etc/mydir3=sc:my-sec
Updating Service 'hello-example-2' in namespace 'default':

  0.053s The Configuration is still working to reflect the latest desired specification.
  4.387s Traffic is not yet migrated to the latest revision.
  4.428s Ingress has not yet been reconciled.
  4.488s Waiting for load balancer to be ready
  4.659s Ready to serve.

Service 'hello-example-2' updated to latest revision 'hello-example-2-00005' is available at URL:
http://hello-example-2.default.10.111.180.117.sslip.io
gvyas-mac:client gvyas$ kubectl get pod hello-example-2-00005-deployment-746c9959-dwtbh -o json | jq -r '.spec.containers[0].volumeMounts'
[
  {
    "mountPath": "/mydir",
    "name": "myvol",
    "readOnly": true,
    "subPath": "abc/xyz"
  },
  {
    "mountPath": "/mydir2",
    "name": "mydir2-e1669d63",
    "readOnly": true,
    "subPath": "xyzzz/jhg"
  },
  {
    "mountPath": "/etc/mydir3",
    "name": "etc-mydir3-cc5ae7ae",
    "readOnly": true
  },
  {
    "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount",
    "name": "kube-api-access-t9kks",
    "readOnly": true
  }
]

Changes

  • Modified --mount flag so it can process subpaths in volumes
  • Added unit tests

Reference

Fixes #1015

Copy link

@knative-prow knative-prow bot left a comment

Choose a reason for hiding this comment

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

@vyasgun: 1 warning.

In response to this:

Description

User can now specify subpath of a volume to be mounted using the --mount flag

gvyas-mac:client gvyas$ ./kn service update hello-example-2 --image gcr.io/knative-samples/helloworld-go --mount /mydir2=cm:cm1/xyzzz/jhg --mount /etc/mydir3=sc:my-sec
Updating Service 'hello-example-2' in namespace 'default':

 0.053s The Configuration is still working to reflect the latest desired specification.
 4.387s Traffic is not yet migrated to the latest revision.
 4.428s Ingress has not yet been reconciled.
 4.488s Waiting for load balancer to be ready
 4.659s Ready to serve.

Service 'hello-example-2' updated to latest revision 'hello-example-2-00005' is available at URL:
http://hello-example-2.default.10.111.180.117.sslip.io
gvyas-mac:client gvyas$ kubectl get pod hello-example-2-00005-deployment-746c9959-dwtbh -o json | jq -r '.spec.containers[0].volumeMounts'
[
 {
   "mountPath": "/mydir",
   "name": "myvol",
   "readOnly": true,
   "subPath": "abc/xyz"
 },
 {
   "mountPath": "/mydir2",
   "name": "mydir2-e1669d63",
   "readOnly": true,
   "subPath": "xyzzz/jhg"
 },
 {
   "mountPath": "/etc/mydir3",
   "name": "etc-mydir3-cc5ae7ae",
   "readOnly": true
 },
 {
   "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount",
   "name": "kube-api-access-t9kks",
   "readOnly": true
 }
]

Changes

  • Modified --mount flag so it can process subpaths in volumes
  • To be added: unit tests

Reference

Fixes #

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.

@@ -38,6 +38,11 @@ const (
PortFormatErr = "the port specification '%s' is not valid. Please provide in the format 'NAME:PORT', where 'NAME' is optional. Examples: '--port h2c:8080' , '--port 8080'."
)

type MountInfo struct {
Copy link

Choose a reason for hiding this comment

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

Golint comments: exported type MountInfo should have comment or be unexported. More info.

@knative-prow knative-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 14, 2022
@codecov
Copy link

codecov bot commented Apr 14, 2022

Codecov Report

Merging #1655 (0b63a1d) into main (bb055ee) will increase coverage by 0.16%.
The diff coverage is 90.32%.

@@            Coverage Diff             @@
##             main    #1655      +/-   ##
==========================================
+ Coverage   79.32%   79.48%   +0.16%     
==========================================
  Files         171      171              
  Lines       12939    12963      +24     
==========================================
+ Hits        10264    10304      +40     
+ Misses       1955     1941      -14     
+ Partials      720      718       -2     
Impacted Files Coverage Δ
pkg/kn/flags/podspec_helper.go 82.43% <89.65%> (+4.00%) ⬆️
pkg/kn/flags/podspec.go 77.51% <100.00%> (+0.18%) ⬆️

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 bb055ee...0b63a1d. Read the comment docs.

@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 14, 2022
Copy link
Contributor

@dsimansk dsimansk left a comment

Choose a reason for hiding this comment

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

Once the other PR is merged, can you please rebase and update changelog? Looks good otherwise.

Copy link
Contributor

@dsimansk dsimansk left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Apr 18, 2022
@knative-prow
Copy link

knative-prow bot commented Apr 18, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dsimansk, vyasgun

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

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 18, 2022
@vyasgun
Copy link
Contributor Author

vyasgun commented Apr 18, 2022

/retest

@knative-prow knative-prow bot merged commit b858dab into knative:main Apr 18, 2022
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/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.

Add support for volume sub-paths
2 participants