IDToken - Tailscale
Tailscale supports federation with external identity providers under their Trust Credentials framework. You can use the IDToken Concourse generates to connect your Concourse container to your tailnet. This example assumes this is the workflow you are trying to achieve with IDToken and Tailscale.
Create a Tag
Create a tag in the Tailscale console. Tag name must be specified. Tag owner and Description can be left blank.
Create New Trust Credential
From the Tailscale console create a new Trust Credential configured with the following information:
- Select OpenID Connect
- Issuer set to Custom issuer
- Issuer URL set to your Concourse URL (e.g.
https://ci.example.com, no path) - Subject is set to the Subject
Scope you'll use in
your pipeline(s). This is how you ensure the Trust Credential is only used
with specific pipelines or jobs.
- e.g. You set
subject_scopetoteamin your pipeline. The name of your Concourse team ismy-team. In Tailscale you'll set the Subject Scope to the name of your team,my-team.
- e.g. You set
- Leave Audience blank. Tailscale will generate this value for you and you'll reference it in your pipeline.
- You do not need to define any Custom Claims for the Trust Client. Leave this blank.
- Press Next to go to the Scopes page
- If you're only using this Trust Credential for connecting Concourse containers to your tailnet, select
Keys > Auth Keyswith the Write permission. Set the Tags to the tag you previously created.
Click Generate Credentials and Tailscale will then give you a Client ID and Audience. Save both, you'll need them in your pipeline.
Connect Container to Tailnet
To connect your Concourse container to your tailnet, you'll need a container
image with the tailscaled and tailscale CLI installed. We'll use the
tailscale/tailscale image for
this example.
We will need to configure Tailscale to run in Userspace networking mode. Read Tailscale's documentation for more information.
Make sure to set --advertise-tags to the tag you created in Tailscale.
var_sources:
- name: tailscale
type: idtoken
config:
# aud claim generated by Tailscale
audience: [ "" ]
# make sure this type aligns with the Subject Scope you set in Tailscale
subject_scope: team
resources:
- name: tailscale
type: registry-image
source:
repository: tailscale/tailscale
tag: latest
jobs:
- name: tailnet
plan:
- get: tailscale
- task: connect-to-tailnet
image: tailscale
params:
CLIENT_ID: "" # generated by Tailscale
IDENTITY_TOKEN: ((tailscale:token))
# required when running Tailscale in non-privileged containers
ALL_PROXY: socks5://localhost:1055/
config:
platform: linux
run:
path: sh
args:
- -c
- |
tailscaled --tun=userspace-networking \
--socks5-server=localhost:1055 \
--outbound-http-proxy-listen=localhost:1055 &> tailscaled.log &
tailscale up --client-id="${CLIENT_ID}" \
--id-token="${IDENTITY_TOKEN}" \
--advertise-tags=tag:ci
tailscale whoami
The container will connect to the tailnet under the hostname of the container, which is the UUID Concourse assigns to the container.
You'll see this output from the tailscale whoami command:
Machine:
Name: f18dc2c7-a089-4342-8761-982d0d849608.tail*****.ts.net
ID: nYvoktQfaC21CNTRL
Addresses: [100.68.231.34/32 fd7a:115c:a1e0::b93b:e723/128]
Tags: tag:ci
Tailnet:
Name: *************
ID: *************
MagicDNS Suffix: tail*****.ts.net
The container will also appear in the
Machines page of the Tailscale
dashboard. The container should be marked as
ephemeral and disappear
after sometime. If you want the container to be removed immediately, run
tailscale logout at the end of your script.