-
Notifications
You must be signed in to change notification settings - Fork 0
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
Tarfetch: make it a button #11
base: main
Are you sure you want to change the base?
Conversation
TimothyLoyer
commented
Oct 11, 2023
•
edited
Loading
edited
- Revise tarfetch to work as a resource button rather than as a separate UI resource
- Added tests
- Updated readme
Co-authored-by: Noelle Leigh <[email protected]>
7ea0f57
to
09378ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you include a section here explaining why someone might want to use this tar-based method of getting files out of a container instead of using kubectl cp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll explain it to you, and then try to condense an explanation for the readme.
Here is what kubectl cp --help
says:
Examples:
# !!!Important Note!!!
# Requires that the 'tar' binary is present in your container
# image. If 'tar' is not present, 'kubectl cp' will fail.
#
# For advanced use cases, such as symlinks, wildcard expansion or
# file mode preservation, consider using 'kubectl exec'.
# Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-namespace>
tar cf - /tmp/foo | kubectl exec -i -n <some-namespace> <some-pod> -- tar xf - -C /tmp/bar
# Copy /tmp/foo from a remote pod to /tmp/bar locally
kubectl exec -n <some-namespace> <some-pod> -- tar cf - /tmp/foo | tar xf - -C /tmp/bar
These more advanced examples are what tarfetch is doing - allowing a bit more flexibility than kubectl cp
and puts it in a nice UI button.
I mentioned flexibility... in the less advanced examples for kubectl cp
, it can only work when you know the exact name of the pod (odd since you can use a pattern like deploy/<deployment name>
when using the kubectl exec
examples). This means we can create a sync button which points at a deployment as a sync target.
# Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace
kubectl cp /tmp/foo_dir <some-pod>:/tmp/bar_dir
# Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container
kubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container>
# Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-namespace>
kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar
# Copy /tmp/foo from a remote pod to /tmp/bar locally
kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like...
## Alternatives
### Syncback
[Syncback](https://github.com/tilt-dev/tilt-extensions/tree/master/syncback) was the first Tilt extension to enable synchronization of files out of a Kubernetes container. Unfortunately it relies on rsync being installed on the host and container systems; a requirement which is rarely fulfilled by default (contrast this with tar, which is pre-installed on most Unix-y systems and can be made available through Windows Subsystem for Linux).
### kubectl cp
Kubectp has a [copy command](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#cp) which relies on tar as well (tarfetch is designed from the "advanced use cases" mentioned in `kubectl cp --help`). The biggest difference between using tarfetch and using `kubectl cp` is the constraints of the latter. Where `kubectl cp` requires an explicit pod name, tarfetch (leveraging `kubectl exec`) can derive the correct pod from a `<type>/<name>` declaration (i.e. `deployment/my-app`).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good to me (minus the "Kubectp" typo).