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
-
Use the
v0.3image tag. There is nolatesttag, andv0stays on 0.2.image: ghcr.io/channinghe/labelgate:v0.3 -
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 -
Delete the removed keys from your config file and environment:
docker.ssh.*(LABELGATE_DOCKER_SSH_*) andssh://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.
-
Update the ports. The dashboard and API now listen on
28111(was8080), and the agent listener on28112(was8081). Change your port mappings and agent endpoints, or keep the old ports withapi.address(LABELGATE_API_ADDRESS) andagent.listen(LABELGATE_AGENT_LISTEN).ports: - "127.0.0.1:28111:28111" -
Start Labelgate and open the dashboard. Fix any errors it shows (see below).
If you use agents
-
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. -
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) andconnect.token(LABELGATE_CONNECT_TOKEN).openssl rand -hex 32 -
End the agent endpoint in
/ws.LABELGATE_CONNECT_ENDPOINT=wss://main.example.com:28112/ws -
Self-signed certificates need a CA. Certificates are now checked. Point
connect.tls.ca(LABELGATE_CONNECT_TLS_CA) on the agent, oragent.tls.ca(LABELGATE_AGENT_TLS_CA) on the main instance for inbound agents, at your CA file. -
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.agentscan 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
conflicterror 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, addcleanup: "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
conflictfor 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.bakInside 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:
-
Note the current instance ID. It is in the
Storage readyline of the startup log, afterinstance_id=:docker compose logs labelgate | grep instance_idIf the log is gone, read it from the comment of a DNS record Labelgate created (
labelgate:a1b2c3d4 ...). -
Stop Labelgate:
docker compose down. -
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 -
Change the image to
ghcr.io/channinghe/labelgate:v0.2, roll back your agents too, and rundocker 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=a1b2c3d4Without 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.