Labelgate

Upgrading to v0.3

What to change before moving from Labelgate v0.2 to v0.3, and how to roll back.

Your labels keep working in v0.3, but a few settings must change before you upgrade.

Before you upgrade

  1. Use the v0.3 image tag. There is no latest tag, and v0 stays on 0.2.

    image: ghcr.io/channinghe/labelgate:v0.3
  2. Set an API token. api.token (LABELGATE_API_TOKEN) needs at least 16 characters. Without it the dashboard and the API are off.

    openssl rand -hex 32   # put the output in LABELGATE_API_TOKEN
  3. Delete the removed keys from your config file and environment:

    • docker.ssh.* (LABELGATE_DOCKER_SSH_*) and ssh:// Docker endpoints. Use the local socket, tcp:// with TLS, or an agent instead.
    • db.retention (LABELGATE_DB_RETENTION)
    • db.vacuum_interval (LABELGATE_DB_VACUUM_INTERVAL)

    If any are left, Labelgate does not start and lists all of them at once.

  4. Update the ports. The dashboard and API now listen on 28111 (was 8080), and the agent listener on 28112 (was 8081). Change your port mappings and agent endpoints, or keep the old ports with api.address (LABELGATE_API_ADDRESS) and agent.listen (LABELGATE_AGENT_LISTEN).

    ports:
      - "127.0.0.1:28111:28111"
  5. Start Labelgate and open the dashboard. Fix any errors it shows (see below).

If you use agents

  1. Upgrade the main instance and every agent together. v0.2 and v0.3 cannot talk to each other. The main instance keeps an offline agent's records for 24 hours (sync.agent_grace), then deletes them. Finish within that time.

  2. Use strong agent tokens. Every agent token needs at least 32 random characters. This covers agent.agents.<id>.token, agent.accept_token (LABELGATE_AGENT_ACCEPT_TOKEN) and connect.token (LABELGATE_CONNECT_TOKEN).

    openssl rand -hex 32
  3. End the agent endpoint in /ws.

    LABELGATE_CONNECT_ENDPOINT=wss://main.example.com:28112/ws
  4. Self-signed certificates need a CA. Certificates are now checked. Point connect.tls.ca (LABELGATE_CONNECT_TLS_CA) on the agent, or agent.tls.ca (LABELGATE_AGENT_TLS_CA) on the main instance for inbound agents, at your CA file.

  5. Allow host names in agent tunnel services. An agent's tunnel service may point to an IP address. To use a host name such as http://web:80, allow it in the main instance's config file:

    agent:
      agents:
        edge1:
          services: ["web"]
      # agents that connect with accept_token:
      accept_services: ["web"]

    agent.agents can only be set in the config file.

What changes you may notice

  • Existing records are no longer taken over. If a hostname already has a DNS record, Access application or tunnel rule that Labelgate did not create, you get a conflict error and nothing is changed. Records that v0.2 created still belong to Labelgate. See Ownership & Conflicts.

  • Label mistakes are errors now. A typo or a bad value (hostnme, proxied: "maybe") shows up in the dashboard and the logs. The service's existing Cloudflare resources stay as they are until you fix the label.

  • Cleanup is on by default. Labelgate deletes its resources 30 minutes (sync.remove_delay) after their container is gone. v0.2 did the same, but its docs said otherwise. To keep a service's resources, add cleanup: "false":

    labelgate.tunnel.web.cleanup: "false"
  • One hostname belongs to one host. If the main host or an agent already uses a hostname, other hosts get a conflict for it. A DNS service and a tunnel service on the same hostname are also a conflict.

  • Access follows your labels. Removing an e-mail from a label removes that person's access on the next sync. Shared Access policies made by v0.2 are left alone. Delete them in Cloudflare when you no longer need them.

If something goes wrong

On first start, v0.3 upgrades its database by itself. Before that, it saves a copy of the old database next to it:

./labelgate-data/labelgate.db.v0.2.bak

Inside the container this is /app/config/labelgate.db.v0.2.bak. If that file already exists, the new copy gets a timestamp at the end. If the copy cannot be written (folder not writable or disk full), Labelgate stops and changes nothing.

To go back to v0.2:

  1. Note the current instance ID. It is in the Storage ready line of the startup log, after instance_id=:

    docker compose logs labelgate | grep instance_id

    If the log is gone, read it from the comment of a DNS record Labelgate created (labelgate:a1b2c3d4 ...).

  2. Stop Labelgate: docker compose down.

  3. Put the backup back in place. The data folder belongs to UID 65532, so use sudo:

    cd labelgate-data
    sudo mv labelgate.db labelgate.db.v0.3
    sudo rm -f labelgate.db-wal labelgate.db-shm
    sudo cp -p labelgate.db.v0.2.bak labelgate.db
  4. Change the image to ghcr.io/channinghe/labelgate:v0.2, roll back your agents too, and run docker compose up -d.

Always restore the backup file before you start v0.2. v0.2 also starts on a v0.3 database, without an error, but then works with stale data from before the upgrade.

When you upgrade to v0.3 again, set the ID from step 1 before the first start:

LABELGATE_INSTANCE_ID=a1b2c3d4

Without it, the upgrade gives the database a new ID. The records that your first v0.3 run created then look like another instance's, and you get conflicts.

On this page