Skip to main content

tuna and Kubernetes

For long-running setups, use the operator

This example is a quick way to expose a single Service: tuna runs as a plain Deployment. For long-running publishing, we recommend the Kubernetes operator: tunnels, domains, TCP ports, and Ingresses are described as Kubernetes resources, and the operator keeps them in the desired state.

Step 1. Create an API key​

Create an API key with the "For tunnels" preset. Put it into a Secret in a separate namespace for experiments:

kubectl create namespace tuna-example
kubectl -n tuna-example create secret generic tuna --from-literal=TUNA_API_KEY=<your_key>

Step 2. Start a test app​

In this example, it's podinfo. If you already have a Service, skip this step.

kubectl -n tuna-example create deployment podinfo --image=ghcr.io/stefanprodan/podinfo --port=9898
kubectl -n tuna-example expose deployment podinfo --port=9898

Step 3. Start tuna​

tuna reaches the app by its Service name:

tuna.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: tuna
spec:
replicas: 1
selector:
matchLabels:
app: tuna
template:
metadata:
labels:
app: tuna
spec:
containers:
- name: tuna
image: yuccastream/tuna:latest
args: ["http", "podinfo:9898"]
envFrom:
- secretRef:
name: tuna

Keep a single replica: each replica opens its own tunnel.

kubectl -n tuna-example apply -f tuna.yaml
kubectl -n tuna-example logs deploy/tuna

Find the Forwarding line in the tuna log: the url field holds the public tunnel address.

To delete everything created in this example:

kubectl delete namespace tuna-example

Inspector​

In the official yuccastream/tuna image, the Request Inspector is off by default. To turn it on, see Inspector in Docker; in Kubernetes, set the same variables in the container's env.