Tailscale is a zero config VPN, creating a secure mesh network for your servers, computers and/or Cloud instances. Every device is assigned a static IP and domain regardless of how you are connected to the internet. It essentially mimics a local network for any device regardless of where you are.
Here are a few blog posts that I found extremely helpful.
This demo is based on the Tailscale example for Kubernetes - https://github.com/tailscale/tailscale/tree/main/docs/k8s.
- Clone Tailscale repository
git clone https://github.com/tailscale/tailscale.git
- Build Tailscale container image
docker build -t quay.io/$USER/tailscale-k8s tailscale/docs/K8s docker push quay.io/$USER/tailscale-k8s
- Clone this Tailscale-learning repository
- Log in to the OpenShift cluster
- Create namespace
oc new-project demo
- Generate a One-off or Ephemeral Key from the Tailscale Admin Console.
The
One-off key
as the name suggests can only be used once. - Update the
tailscale/secret/tailscale-api-key-secret.yaml
with the generated key - Create K8s Secret containing key
oc apply -f secret/tailscale-api-key-secret.yaml
- Create the required serviceaccount, role and rolebinding
oc apply -f rbac
- Create a userspace sidecar pod
oc apply -f userspace-sidecar/userspace-sidecar.yaml
- From Tailscale Admin Console, the Machines tab should now show a machine for
nginx
with a connected status. - From Tailscale Admin Console, check Settings > Keys and confirm the one time key is gone
- Bring up nginx on browser and curl using Tailscale IP address
- Enable MagicDNS by adding a nameserver (ie. CloudFlare - 1.1.1.1 or Google - 8.8.8.8)
- Bring up nginx using the Tailscale FQDN
- Switch to Developere view and deploy an Nginx pod from a template
- Retrieve the ClusterIP for Nginx
- Identify Pod and Service CIDR for cluster
oc get network cluster -o yaml
- Update subnet-router.yaml with CIDRs
- Create subnet-router pod
- From Tailscale Admin Console, check Machines subnet-router should show as connected
- Enable the routes for the subnet-router
- Connect to a PodIP
oc get po -o wide curl http://$POD_IP:$PORT
- Connect to a ClusterIP
oc get svc curl http://$CLUSTER_IP:$PORT