Skip to content

Support running in containers (Serverless) #504

Closed

Description

@danderson

We have minimal support for containers, in that a Dockerfile exists. However, that Dockerfile doesn't embed correct version numbers, doesn't support authkey enrollment, and we have the same problem that Kubernetes had with incompatible host vs. container iptables. As such, we don't currently publish official images anywhere.

This is a tracking bug to make the container image good enough that we can support it as an official platform.

Activity

  1. bradfitz commented on Jun 24, 2020

    @bradfitz
    Member

    When we do this, revisit #301 from @khos2ow

  2. hamishforbes commented on Jun 24, 2020

    @hamishforbes

    FWIW this is my hacky setup for running tailscale in a sidecar with nginx-ingress.
    It might help other people coming across this issue.
    https://gist.github.com/hamishforbes/2ac7ae9d7ea47cad4e3a813c9b45c10f
    Just add a persistent vol for state + secret with your authkey.

    This was enough to let me access services via ingress on a cluster with no inbound access, so i stopped tinkering there!
    Only tested with EKS and the AWS VPC CNI, might make a difference...

  3. toonsevrin commented on Jun 25, 2020

    @toonsevrin

    @hamishforbes "privileged: true, NET_ADMIN"

    For #502 (an operator to expose a k8s service to your tailscale network), the Tailscale network only has to be accessible within the operator container itself. Would it be possible to get rid of these capabilities somehow in this case?

  4. hamishforbes commented on Jun 25, 2020

    @hamishforbes

    I think that option was required to get the tun kernel module visible in the container.
    My setup doesn't seem give host access either, only access to the pod, the tailscale tunnel doesn't appear on the host, nor do iptables rules.

  5. toonsevrin commented on Jun 25, 2020

    @toonsevrin

    Pretty sure you won't need privileged then:

    For interacting with the network stack, instead of using --privileged they should use --cap-add=NET_ADMIN to modify the network interfaces.

    Source: Docker docs

    Do you think networking setup can be done in an initContainer? Similar to how istio only requires NET_ADMIN on init?

  6. hamishforbes commented on Jun 25, 2020

    @hamishforbes

    You're right, after a bit of messing about privileged isn't required.
    Without privileged you do, however, have to create /dev/net/tun yourself with mknod /dev/net/tun c 10 200.
    Otherwise this happens:

    3.0M/19.1M Starting userspace wireguard engine with tun device "tailscale0"
    3.1M/19.1M Linux kernel version: 4.14.173-137.229.amzn2.x86_64
    3.1M/19.1M is CONFIG_TUN enabled in your kernel? `modprobe tun` failed with: modprobe: can't change directory to '/lib/modules': No such file or directory
    3.1M/19.1M CreateTUN: can't create TUN device; /dev/net/tun does not exist
    wgengine.New: can't create TUN device; /dev/net/tun does not exist
    

    Updated the gist!

    Currently I don't think all the networking setup can be done at init.
    I tried manually creating the tailscale0 tun device in an init container with NET_ADMIN.
    The tunnel shows up in the main container (you still have to create /dev/net/tun though) however tailscaled tries to modify it (even if you set the MTU to 1280 in init) and that fails.

    2.9M/19.0M Starting userspace wireguard engine with tun device "tailscale0"
    3.1M/19.0M Linux kernel version: 4.14.173-137.229.amzn2.x86_64
    3.2M/19.0M is CONFIG_TUN enabled in your kernel? `modprobe tun` failed with: modprobe: can't change directory to '/lib/modules': No such file or directory
    3.2M/19.0M CreateTUN: failed to set MTU of TUN device
    wgengine.New: failed to set MTU of TUN device
    

    Maybe this would be feasible if tailscaled had some kind of init mode? But there might be other stuff being done during normal operation that requires NET_ADMIN too 🤷‍♂️.

    For me the 2 biggest pain points in running tailscale in containers/k8s are the 2 command startup and the state file.

    Starting tailscaled and then having to configure it with another command is not much fun in containers.
    Some way to start tailscaled with all the necessary config (either flags, env vars or config file, don't really care) would be ideal.

    And then having to keep the state file around to prevent the IP changing if the container is restarted also sucks.
    DNS automation could fix this, I don't really care what the IP is just that my DNS entries keep working when the container restarts.

  7. toonsevrin commented on Jun 25, 2020

    @toonsevrin

    @hamishforbes I was thinking about the persistent volume (I agree that that sucks). I think it makes a lot of sense to have an operator manage the identities and push them into Secrets/ConfigMaps. That way no persistent volumes are required (not even for the Operator).

  8. toonsevrin commented on Jun 25, 2020

    @toonsevrin

    Perhaps you can create a PR to fix the MTU issue? I still have one more exam in a couple of days so won't be able to look at this myself up to then :')

    Also, is there already an issue created for running in non-daemon mode, I agree that that would be nice to have.

  9. 59 remaining items

  10. DentonGentry commented on May 20, 2021

    @DentonGentry
    Contributor
  11. StevenACoffman commented on May 21, 2021

    @StevenACoffman
    Contributor

    FYI - A working cillium kubernetes + tailscale setup config got posted here: cilium/cilium#16266

  12. unixfox commented on May 21, 2021

    @unixfox

    FYI - A working cillium kubernetes + tailscale setup config got posted here: cilium/cilium#16266

    Small note is that this is for accessing the network of an existing cilium cluster and not for having an encrypted network between every node by using tailscale and cilium (something that I would really want).

  13. DentonGentry commented on Jun 26, 2021

    @DentonGentry
    Contributor

    In 1.10 the userspace-networking mode added support for AWS Lambda.

  14. pratikbin commented on Jul 8, 2021

    @pratikbin
    Contributor

    Can anyone put Dockerfile here to kick-start ?
    @StevenACoffman @DentonGentry @orrc @pirate @bradfitz ...

    Edit: Apologies. Found it in this very repo

  15. pschulten commented on Jul 8, 2021

    @pschulten

    Now, this is an example of a clean Dockerfile, 😊

  16. abh commented on Jul 8, 2021

    @abh

    @DentonGentry Why Alpine 3.11 instead of 3.14? (Apologies if that's covered already elsewhere and I missed it).

  17. Xe commented on Jul 8, 2021

    @Xe
    Contributor

    That's likely because the dockerfile is older and hasn't been updated. Speaking as an experienced Alpine user the dockerfile as-is should work fine if you replace 3.11 with 3.14.

  18. DentonGentry commented on Jul 21, 2021

    @DentonGentry
    Contributor

    In 1.12 the userspace-networking mode handles operation in container environments which do not have CAP_NET_ADMIN set.

    At this point I'm going to close this as done, I think the support for containers and for serverless environments overall is pretty good. If there are specific environments which do not work or issues encountered, please open new bugs. This one is long and covers a number of issues already.

  19. brybalicious commented on Aug 9, 2021

    @brybalicious

    Amazing. I will try out the new functionality next time I implement tailscale!

  20. changed the title [-]Support running in containers (Docker, Kubernetes)[/-] [+]Support running in containers (Serverless)[/+] on Aug 11, 2021
  21. metaskills commented on May 31, 2023

    @metaskills

    FWIW, I created a Lambda Container project with container packages that make it a bit easier thank Lambda layers. Details here https://github.com/rails-lambda/tailscale-extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions