Skip to content

Sharing a service with your lab

Sometimes the thing you've built on FLAME is a service other people want to use: a TensorBoard showing a training run, a fine-tuned model behind vLLM or llama.cpp, a self-hosted Weights & Biases server, a Gradio demo. FLAME can publish a service like that at its own HTTPS address, such as https://tensorboard.my-workspace.ws.flamecluster.io, that only members of your workspace can reach. Labmates open it in a browser and sign in with their usual FLAME login; scripts call it with an API credential.

You describe what to publish with a small Kubernetes resource called a ServiceExposure. FLAME handles the address, the TLS certificate and the login in front of it.

What you'll need first

  • A FLAME workspace where you're an owner or member, and kubectl access to it (from your JupyterHub server, or your own machine via CLI access).
  • Your service running in a Kubernetes Service in that workspace (step 1 below).

Published services are reachable from the Drexel network: on campus, on the Drexel VPN, or from inside FLAME. They are not on the public internet.

Don't use tunnels such as ngrok

Tools like ngrok, cloudflared or Tailscale Funnel put a service on the public internet with no Drexel login in front of it. Use a ServiceExposure instead: it's just as quick, and only your workspace can get in.

Who can reach a published service

Who How they get in
Workspace owners, members and viewers, in a browser Open the address and sign in through Globus, like any other FLAME site.
Scripts and programs Send Authorization: Bearer <token>, using a token from one of your workspace's API credentials.

Step 1: Run your service behind a Kubernetes Service

A ServiceExposure points at a Kubernetes Service in your workspace's namespace, which routes to the pods doing the work. For example, TensorBoard reading logs from your workspace storage:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: tensorboard
spec:
  replicas: 1
  selector:
    matchLabels: {app: tensorboard}
  template:
    metadata:
      labels: {app: tensorboard}
    spec:
      containers:
        - name: tensorboard
          image: tensorflow/tensorflow:2.17.0
          command: [tensorboard, --logdir=/workspace/runs, --bind_all, --port=6006]
          ports:
            - containerPort: 6006
          volumeMounts:
            - name: workspace
              mountPath: /workspace
      volumes:
        - name: workspace
          persistentVolumeClaim:
            claimName: workspace-storage-my-workspace
---
apiVersion: v1
kind: Service
metadata:
  name: tensorboard
spec:
  selector: {app: tensorboard}
  ports:
    - port: 6006

Apply it with kubectl apply -n my-workspace -f tensorboard.yaml.

Anything that serves HTTP works the same way: vLLM, llama.cpp's llama-server, a W&B server, a Gradio or Streamlit app, your own API.

Turn off your service's own login

FLAME's gateway already checks that every request comes from your workspace, so don't configure an API key or password on the service itself (for example, leave off vLLM's --api-key). The gateway removes the Authorization header before a request reaches your service, so a service that expects its own key there won't receive it.

Step 2: Create the ServiceExposure

apiVersion: urcf.drexel.edu/v1alpha1
kind: ServiceExposure
metadata:
  name: tensorboard
spec:
  service: tensorboard
  port: 6006
kubectl apply -n my-workspace -f exposure.yaml
  • metadata.name becomes the first part of the address, so choose something short: lowercase letters, digits and hyphens. The whole address, without https://, can be at most 64 characters.
  • spec.service and spec.port name the Service and which of its ports to publish. spec.port is the Service's own port, the one FLAME forwards requests to inside the cluster. It doesn't change the published address, which is always standard HTTPS (port 443) with no port number in the URL.

Then check on it with kubectl get serviceexposures (or the short form, kubectl get svcx):

NAME          SERVICE       PORT   URL                                                   PHASE   MESHED   AGE
tensorboard   tensorboard   6006   https://tensorboard.my-workspace.ws.flamecluster.io   Ready   False    2m

The exposure is Pending for a minute or so while FLAME issues its certificate, then becomes Ready. If it says Error, the status message in kubectl describe svcx tensorboard explains why, for example a misspelled Service name or port. MESHED is explained in the next section.

Encrypting traffic inside FLAME

The connection from a browser or program to the published address is always HTTPS. Inside FLAME, the gateway then forwards each request to your pods. That second hop is encrypted only if your pods are in FLAME's service mesh, which MESHED reports:

MESHED Gateway to your pods
True Encrypted by the mesh.
False Unencrypted. Fine for most dashboards and demos, but use the mesh for anything sensitive.
Unknown No running pods behind the Service yet.

To join the mesh, add two annotations to your pod template:

  template:
    metadata:
      labels: {app: tensorboard}
      annotations:
        linkerd.io/inject: enabled
        config.linkerd.io/default-inbound-policy: all-unauthenticated

The first adds the mesh's proxy to the pod. The second lets code elsewhere in your workspace keep calling the service directly at its in-cluster address (below). Without it, the proxy refuses anything that isn't in the mesh. The gateway's traffic is encrypted either way. Re-apply the Deployment, and MESHED becomes True within about five minutes.

Keep meshed services in their own pods

The proxy handles all of a pod's network traffic, not just requests from the gateway, and it slows down large transfers. Run the service in a small pod of its own, as in the Deployment above, rather than in a pod that also moves data in bulk. A server started inside your JupyterHub notebook can't join the mesh this way, so its exposure stays MESHED False; run it as a Deployment instead if it needs encrypting.

Step 3: Share the address

Send the URL to your labmates. When they open it they're sent through the FLAME login and then straight to your service. Anyone who isn't on your workspace gets an access-denied page.

To unpublish, delete the ServiceExposure:

kubectl delete svcx tensorboard -n my-workspace

Calling a published service from code

Programs authenticate with an API credential from the same workspace as the service. Set one up and fetch its secret as described in the inference guide; the same credential also works for the FLAME inference API. Then send its token in the Authorization header.

For an OpenAI-compatible server such as vLLM, that's just the inference guide's example with a different base_url, reusing its ClientCredentialsToken helper:

from openai import OpenAI

client = OpenAI(
    api_key=ClientCredentialsToken(),
    base_url="https://my-model.my-workspace.ws.flamecluster.io/v1",
)

Or from the shell:

curl -H "Authorization: Bearer $TOKEN" \
  https://my-model.my-workspace.ws.flamecluster.io/v1/models

From inside FLAME, skip the gateway

Code running in the same workspace (a notebook, a TrainJob) can reach the service directly at http://<service>.<workspace>.svc:<port>, for example http://tensorboard.my-workspace.svc:6006, with no token at all. That's also faster. The published address is for people and programs outside the cluster. Direct calls like this are encrypted only if the calling pod is in the mesh too. Calls from a notebook never are, since notebooks can't join the mesh.

Knowing who is calling

Requests that come through the gateway carry a header saying who sent them, which your service can use for its own logging or permissions:

Header Set when
X-Flame-User A person signed in through the browser. The value is their email address.
X-Flame-Credential A program used an API credential. The value is the credential's client ID.

The gateway sets these from the verified login and discards any copy the caller sent, so they can be trusted for requests that arrive through the published address. Requests from inside your workspace that use the in-cluster address bypass the gateway, and those callers can set any header they like.

Limits

  • HTTP-based services only: plain HTTP, WebSockets, server-sent events and gRPC all work. Raw TCP and UDP services (databases, for example) can't be published this way.
  • Up to 64 ServiceExposures per workspace.
  • Addresses of at most 64 characters, such as tensorboard.my-workspace.ws.flamecluster.io (43). A longer one can't get a TLS certificate, so the ServiceExposure goes to Error; pick a shorter name.
  • Services with their own Authorization-header login can't be used through the gateway, because the gateway uses that header itself. For example, logging runs with the wandb SDK to a W&B server on FLAME from a machine outside FLAME won't work this way; log from inside FLAME using the in-cluster address, or sync offline runs afterwards with wandb sync.