Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cloudflared tunnel ready command #1135

Merged
merged 20 commits into from
Nov 18, 2024

Conversation

firecow
Copy link
Contributor

@firecow firecow commented Dec 28, 2023

This would make it possible to have a Docker image without wget and curl, and still make docker healthchecking in docker possible

closes #1126

@firecow
Copy link
Contributor Author

firecow commented Apr 11, 2024

@jlaffaye I there anything I can do to fast-track the PR somehow ?

@firecow
Copy link
Contributor Author

firecow commented Apr 23, 2024

@felipelima-circle

image

Am I to understand that the /healthcheck "just" returns the string "ok"?
It makes no checking that the tunnels are actually healthy?

If that is a correct assumption, I would much rather use /ready

It at least checks that ready connections are above 0

image

I've renamed the sub command to cloudflared tunnel ready to avoid confusion about what this command actually does.

@firecow firecow changed the title Add cloudflared tunnel health command Add cloudflared tunnel ready command Apr 23, 2024
@felipelima-circle
Copy link

@firecow That makes sense. 👍🏻

@CodaBool
Copy link

CodaBool commented May 19, 2024

A merge of master into your branch may be in order because I was getting an error about "UDP Buffer Sizes" that forced me to merge in master. Which resolved it. But past that this seems to work fine on a quick test.

I stood up a separate service at port 8081 to make a cloudflare tunnel with. Then wrote a docker healthcheck into a docker-compose.yml. Which had my local IP there:

healthcheck:
  test: tunnel --metrics 192.168.0.15:8081 ready || exit 1

Which worked great. The timeout was a little high at 30 seconds but it's fine.

@firecow
Copy link
Contributor Author

firecow commented May 21, 2024

A merge of master into your branch may be in order because I was getting an error about "UDP Buffer Sizes" that forced me to merge in master. Which resolved it. But past that this seems to work fine on a quick test.

I stood up a separate service at port 8081 to make a cloudflare tunnel with. Then wrote a docker healthcheck into a docker-compose.yml. Which had my local IP there:

healthcheck:
  test: tunnel --metrics 192.168.0.15:8081 ready || exit 1

Which worked great. The timeout was a little high at 30 seconds but it's fine.

Master has been merged.

@kamaradski
Copy link

kamaradski commented Jun 20, 2024

I'm really waiting for this, as in AWS ECS I can also not get the workaround #1126 working at all. If something breaks our tunnels are currently just hanging. not ideal.

@firecow
Copy link
Contributor Author

firecow commented Jun 21, 2024

@DevinCarr or @jcsf One of you guys, wanna give this PR some ❤️ ?

@firecow firecow mentioned this pull request Jun 28, 2024
@firecow
Copy link
Contributor Author

firecow commented Aug 22, 2024

@chungthuang, @DevinCarr and @jcsf I've synced the fork

@huyz
Copy link

huyz commented Oct 6, 2024

Can anyone push this further along?

@huyz
Copy link

huyz commented Oct 6, 2024

What would be the use case of the old /heathcheck endpoint, if any?

@huyz
Copy link

huyz commented Oct 6, 2024

Is there a docker image for this, while we wait for an official merge?

@firecow
Copy link
Contributor Author

firecow commented Oct 7, 2024

@huyz I've just synced the fork. But we need some maintainer or developer to approve the test runs, and eventually merge the change into master.

@firecow
Copy link
Contributor Author

firecow commented Nov 14, 2024

~/workspace/firecow-cloudflared-fork$ make cloudflared && ./cloudflared tunnel --metrics 127.0.0.1:40026 ready; echo $?
GOOS=linux GOARCH=amd64  go build -mod=vendor  -ldflags='-X "main.Version=c39f0ae3" -X "main.BuildTime=2024-11-14-1739 UTC" ' github.com/cloudflare/cloudflared/cmd/cloudflared
Get "http://127.0.0.1:40026/ready": dial tcp 127.0.0.1:40026: connect: connection refused
1
~/workspace/firecow-cloudflared-fork$ make cloudflared && ./cloudflared tunnel --metrics 127.0.0.1:40027 ready; echo $?
GOOS=linux GOARCH=amd64  go build -mod=vendor  -ldflags='-X "main.Version=c39f0ae3" -X "main.BuildTime=2024-11-14-1739 UTC" ' github.com/cloudflare/cloudflared/cmd/cloudflared
0

Just leaving this here for reference.

It seems like the feature is doing what it is supposed to do.

@chungthuang chungthuang merged commit 3480a33 into cloudflare:master Nov 18, 2024
3 of 4 checks passed
@firecow firecow deleted the tunnel-health branch November 18, 2024 18:36
@huyz
Copy link

huyz commented Nov 23, 2024

For a noob, can someone give the exact syntax to put in docker-compose.yml to make this healthcheck work out of the box?

@IngmarStein
Copy link

@huyz here's what I use:

    environment:
      - TUNNEL_TOKEN=${TUNNEL_TOKEN}
      - TUNNEL_METRICS=0.0.0.0:60123
    healthcheck:
      test: ["CMD", "cloudflared", "tunnel", "--metrics", "localhost:60123", "ready"]
      interval: 30s
      timeout: 30s
      retries: 3

@Letgamer
Copy link

As this feature is now merged I propose to add the Healthcheck directly into the Dockerfile so that it works automatically and doesn't have to be configured in a docker-compose.yaml file.
@firecow Maybe this is not possible because of the --metrics requirement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Built-in Docker Healthcheck
9 participants