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

Feature Request: Automatically generate list of remote volumes #917

Closed
turettn opened this Issue Feb 2, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@turettn
Copy link
Contributor

turettn commented Feb 2, 2019

I've recently discovered telepresence, and quickly got hooked. I have a whole bunch of micro-services running on k8s, each with a different list of volume mounts. Instead of having to manually create sym-links or use proot to create fake bindings, what I really want is to be able to get a list of mounts from telepresence, which I can then use to automatically handle the mounts.

To solve these problems, I propose adding a TELEPRESENCE_MOUNTS environment variable to the local container that holds a colon-separated list of remote mount points, ignoring those that docker automatically creates (/sys/*, /proc/*, /dev/*, resolv.conf, hostname, hosts).

With this in hand, I can do something like this in the entry-point of my container:

def telepresence_remote_mounts():
    mounts = os.environ.get('TELEPRESENCE_MOUNTS')
    if not mounts:
        return

    tele_root = os.environ.get('TELEPRESENCE_ROOT')

    for mount in mounts.split(':'):
        dir_name, link_name = os.path.split(mount)
        os.makedirs(dir_name, exist_ok=True)
        
        link_src = os.path.join(tele_root, mount[1:])
        os.symlink(link_src, mount)

If I'm running telepresence, I get all the volumes where they would normally be, and everything works as expected. If I'm in production, the environment variable is not present and nothing changes.

This saves me from having to manually maintain a list of volume mounts for each micro-service, and standardizes the telepresence workflow across all of them.

I will submit a pull request for consideration shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.