Skip to content

Add Cloudflare Tunnel sidecar to Cloud Run deployment#11

Closed
MrOrz wants to merge 4 commits into
feat/cloud-run-deployment-3681228675650959013from
add-cloudflare-tunnel-sidecar-1605954862584609923
Closed

Add Cloudflare Tunnel sidecar to Cloud Run deployment#11
MrOrz wants to merge 4 commits into
feat/cloud-run-deployment-3681228675650959013from
add-cloudflare-tunnel-sidecar-1605954862584609923

Conversation

@MrOrz
Copy link
Copy Markdown
Member

@MrOrz MrOrz commented Mar 2, 2026

Added cloudflared container to service.template.yaml to support Cloudflare Tunnel sidecar architecture.

Changes included:

  • Injected TUNNEL_TOKEN from Google Secret Manager (CLOUDFLARE_TUNNEL_TOKEN) using valueFrom.secretKeyRef.
  • Added TUNNEL_URL environment variable for network connectivity targeting http://localhost:8080.
  • Configured autoscaling and CPU throttling (run.googleapis.com/cpu-throttling: "false") to ensure instance stability for the tunnel.
  • Restricted sidecar resource usage to 100m vCPU and 128Mi Memory.

PR created automatically by Jules for task 1605954862584609923 started by @MrOrz

Co-authored-by: MrOrz <108608+MrOrz@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions github-actions Bot temporarily deployed to pr-11 March 2, 2026 20:18 Destroyed
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Cloud Run deployment by introducing a Cloudflare Tunnel sidecar. This integration allows for secure, direct connectivity to the Cloud Run service via Cloudflare, bypassing traditional ingress configurations. The changes ensure the tunnel operates efficiently with appropriate resource allocation and stable CPU performance.

Highlights

  • Cloudflare Tunnel Sidecar: Integrated the 'cloudflared' container into the Cloud Run deployment to establish a Cloudflare Tunnel.
  • Secret Management: Configured the 'TUNNEL_TOKEN' environment variable to securely fetch its value from Google Secret Manager.
  • Network Configuration: Defined 'TUNNEL_URL' to direct traffic to 'http://localhost:8080' for internal service communication.
  • Resource Management: Applied specific CPU and memory limits ('100m' vCPU, '128Mi' Memory) for the 'cloudflared' sidecar.
  • Performance Optimization: Disabled CPU throttling for the Cloud Run service to ensure stable performance for the tunnel.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • service.template.yaml
    • Added the 'cloudflared' container definition to the service template.
    • Configured 'TUNNEL_TOKEN' to retrieve its value from 'CLOUDFLARE_TUNNEL_TOKEN' in Google Secret Manager.
    • Set the 'TUNNEL_URL' environment variable to 'http://localhost:8080'.
    • Defined resource limits for the 'cloudflared' container (100m cpu, 128Mi memory).
    • Disabled CPU throttling for the overall Cloud Run service.
Activity
  • PR created automatically by Jules for task 1605954862584609923 started by @MrOrz.
  • No human activity has occurred on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a Cloudflare Tunnel sidecar to the Cloud Run deployment. The configuration correctly disables CPU throttling for instance stability and sets up the cloudflared container with resource limits and secret handling. However, there are two key issues to address. First, the container image uses the :latest tag, which is not recommended for production as it can lead to unpredictable deployments; a specific version should be pinned. Second, and more critically, the TUNNEL_URL for the sidecar is configured to point to port 8080, but the ingress container it should be forwarding traffic to is running on port 3000. This misconfiguration will prevent the tunnel from functioning correctly.

Comment thread service.template.yaml
name: CLOUDFLARE_TUNNEL_TOKEN
key: latest
- name: TUNNEL_URL
value: "http://localhost:8080"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The TUNNEL_URL is configured to point to http://localhost:8080, but no container is listening on this port. The ingress container, which serves the frontend, is configured to listen on port 3000. The tunnel should forward traffic to the ingress container. Please update the port to 3000 for the tunnel to work correctly.

          value: "http://localhost:3000"

Comment thread service.template.yaml
periodSeconds: 10
failureThreshold: 6
- name: cloudflared
image: cloudflare/cloudflared:latest
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using the :latest tag for container images is not recommended in production environments. It can lead to unpredictable behavior when a new version is pushed to the registry, and it makes it difficult to track which version of the image is running or to roll back to a previous version. It's best practice to pin to a specific, immutable image tag (e.g., a version number or a git SHA).

        image: cloudflare/cloudflared:2024.5.1

…N using envsubst

Co-authored-by: MrOrz <108608+MrOrz@users.noreply.github.com>
@github-actions github-actions Bot temporarily deployed to pr-11 March 2, 2026 20:27 Destroyed
Co-authored-by: MrOrz <108608+MrOrz@users.noreply.github.com>
@github-actions github-actions Bot temporarily deployed to pr-11 March 2, 2026 20:36 Destroyed
Co-authored-by: MrOrz <108608+MrOrz@users.noreply.github.com>
@github-actions github-actions Bot temporarily deployed to pr-11 March 3, 2026 10:24 Destroyed
@MrOrz
Copy link
Copy Markdown
Member Author

MrOrz commented Mar 3, 2026

We cannot setup tunnels for each PR, give up tunnel solution

@MrOrz MrOrz closed this Mar 3, 2026
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.

1 participant