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

volumes: document alternates to the gitRepo volume type #8429

Closed
wants to merge 1 commit into from

Conversation

ericchiang
Copy link
Contributor

Users are better served by not using the built-in gitRepo volume
type. Update the documentation to suggesting using an init
container instead.

NOTE: This doesn't need to wait for 1.11 and can be merged
to master.

Background discussion can be found in:

kubernetes/kubernetes#60999
kubernetes/kubernetes#63445

cc @kubernetes/sig-storage-pr-reviews

@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 8, 2018
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 8, 2018
@k8sio-netlify-preview-bot
Copy link
Collaborator

k8sio-netlify-preview-bot commented May 8, 2018

Deploy preview for kubernetes-io-master-staging ready!

Built with commit 242144a

https://deploy-preview-8429--kubernetes-io-master-staging.netlify.com

rather than extending the Kubernetes API for every such use case.

Here is an example for gitRepo volume:
While Kubernetes has a built-in `gitRepo` volume type, its functionality is
Copy link
Member

Choose a reason for hiding this comment

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

Maybe here, the doc should say gitRepo volume type is deprecated. And then point to a new doc, maybe under tasks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I think it might be better as a new task doc. I think users will want to know "how do I access git in my container", and won't think to go to the init containers page.

@k8s-ci-robot k8s-ci-robot 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 May 15, 2018
@ericchiang
Copy link
Contributor Author

@msau42 added a task document.

git-clone.sh: |
#!/bin/sh -e

# Init Containers will re-run on Pod restart. Remove the directory's contents
Copy link
Member

Choose a reason for hiding this comment

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

Can you document in a comment what each argument is?

Copy link
Member

Choose a reason for hiding this comment

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

Is storing a script a recommended use of a configmap?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is storing a script a recommended use of a configmap?

I couldn't find an example in https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/

However, I think it's nice to be able to inline the example like this. Realistically, a user would probably build a "git-puller" image or something like that.

@ericchiang
Copy link
Contributor Author

Command arguments now documented.

@zacharysarah
Copy link
Contributor

@ericchiang Thanks for adding this, great job on the formatting. 👍
/approve

@msau42 If this looks good to you, please /lgtm it to merge.
/assign @msau42

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zacharysarah

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 May 31, 2018
@zacharysarah zacharysarah added Docs Review: Open Issues and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 31, 2018
@msau42
Copy link
Member

msau42 commented May 31, 2018

/assign @tallclair

@zacharysarah
Copy link
Contributor

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 1, 2018
@zacharysarah
Copy link
Contributor

@tallclair It would be great to get your review on this in light of CVE 2018-11235.

metadata:
name: git-clone
data:
git-clone.sh: |
Copy link
Member

Choose a reason for hiding this comment

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

I haven't seen the pattern of passing a script as a configmap before.... I'm not sure that's a pattern we should be encouraging? I think this can all just be inlined into the deployment.


REPO=$1
REF=$2
DIR=$3
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think it's simpler to just use environment variables instead.

rm -rf $( find $DIR -mindepth 1 )
fi

git clone $REPO $DIR
Copy link
Member

Choose a reason for hiding this comment

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

nit: prefer git clone -- $REPO $DIR (less error-prone)

The [emptyDir](/docs/concepts/storage/volumes/#emptydir) volume type can be used
to share data between multiple containers in a Pod.

First, define a script for cloning a repo to run in the Init Container:
Copy link
Member

Choose a reason for hiding this comment

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

Should we also mention https://github.com/kubernetes/git-sync as another approach, when continuous syncing is desired?

@zacharysarah
Copy link
Contributor

@ericchiang 👋 Please feel free to reopen this PR when you're ready to incorporate review feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. sig/storage Categorizes an issue or PR as relevant to SIG Storage. 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.

6 participants