Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I run Tailscale on one of my Bitbucket self-hosted pipeline runner? Maybe an alternative?

dominexus
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 5, 2023

I'm working on proper communication to provide internal access for Bitbucket pipeline runners by running Tailscale to access the private networks in my private server domain, but neither of the two approaches, which are demonstrated below, worked to accomplish the internal communication.

 

For the following approaches, let's say `100.XXX.XXX.129` is the Tailscale IP of my dedicated server.

 


Attempt 1

  1. Create a docker network called `tailscale-net`
  2. Run a Tailscale docker container, advertising ip range 172.150.30.0/24 and assign it to docker network tailscale-net (Of course, + log in and approve the device)
  3. Run the Bitbucket pipeline runner on Docker that is connected to docker network `tailscale-net`
  4. Use this small snippet of code as one of the steps to ssh:
    - pipe: atlassian/ssh-run:0.7.1
    variables:
    SSH_USER: ${TAILSCALE_SSH_USER}
    SERVER: 100.XXX.XXX.129
    PORT: ${TAILSCALE_SSH_PORT}
    MODE: 'command'
    COMMAND: "echo communication received"

 

Issues: 

  • Networks assigned to the bitbucket pipeline self-hosted runner do not replicate across the sub-runners
  • SSH `100.XXX.XXX.129:22` has no connection to host

 


Attempt 2

  1. In the sub runner of the bitbucket pipeline runner, upgrade the packages
  2. Install the https and ca certificates
  3. Install netcat for sock5 proxy
  4. Add the modifications in `~/.ssh/config` for StrictHostKeyChecking & ProxyCommand
  5. Change the file ownership of the ssh config to `600`
  6. Install Tailscale on the sub runner
  7. Modify the tailscaled daemon to use userspace-networking and socks5 server
  8. Run tailscale up with an auth key
  9. After installing tailscale, run the same ssh pipe, shown in attempt 1

 

- step:
name: Upgrading stuff
# runs-on: # Disable this if self-hosted is not available
# - 'self.hosted'
image: atlassian/default-image:4
script:
- apt-get update -y
- apt-get install -y apt-transport-https ca-certificates
- apt- get install -y netcat
- echo "Configure SSH client"
# - echo "Host *" >> ~/.ssh/config
- echo "StrictHostKeyChecking no" >> ~/.ssh/config
- echo "ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p" >> ~/.ssh/config
- cat ~/.ssh/config
- chmod 600 ~/.ssh/config
- curl -fsSL https://tailscale.com/install.sh | sh
- apt-get update -y
- tailscaled --tun=userspace-networking --state=tailscaled.state --socks5-server=127.0.0.1:1080 &
- tailscale up --hostname=bbp-$BITBUCKET_WORKSPACE-haproxy --authkey=$TAILSCALE_AUTH_KEY
- echo "Set up HTTP proxy for all outgoing HTTP requests"
- echo "Connecting to remote server"
- pipe: atlassian/ssh-run:0.7.1
variables:
SSH_USER: ${TAILSCALE_SSH_USER}
SERVER: 100.XXX.XXX.129
PORT: ${TAILSCALE_SSH_PORT}
MODE: 'command'
COMMAND: "echo communication received"

(credits to Brewww article for allowing deployments with bitbucket pipelines and tailscale) 

 

Issues (after Tailscale was installed and up):

  • SSH hangs until operation time out & pauses with these lines before the timeout:
    2023/12/06 00:35:34 magicsock: 1 active derp conns: derp-10=cr3s,wr3s

    2023/12/06 00:35:34 post-rebind ping of DERP region 10 okay

    2023/12/06 00:35:51 network-lock unavailable; no state directory
  • SSH through magic sock fails to force-set UDP write buffer size to 7340032 while initializing the connection
  • WG Engine errors setting DNS config after major link change: getting OS base config is not supported

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events