Skip to content

Quickstart: Deploy to Google Cloud Run

version: 0.3.0 repository: oci://ghcr.io/helmless alias: service - name: google-cloudrun-job version: 0.3.0 repository: oci://ghcr.io/helmless alias: job

Prerequisites

You'll need:

  • Google Cloud CLI installed
  • Helm CLI installed
  • A Google Cloud account with billing enabled and the roles/run.admin role

Your First Helmless Application

Step 1: Set Up Your Environment

  1. Login to Google Cloud:

    gcloud auth login
    

  2. Set your project and region:

    gcloud config set project YOUR_PROJECT_ID
    gcloud config set run/region europe-west1  # or your preferred region
    

Step 2: Create Your Application Chart

Create a new directory for your service and initialize a Helm chart:

helm create helmless && cd helmless
rm -rf helmless/templates/* && rm -f helmless/values.yaml
echo "output" >> .gitignore

Step 3: Add the Helmless Charts

You now need to add the Helmless charts as dependencies to your application chart.

  1. Add the Helmless chart to your service:
    cat <<EOF >> Chart.yaml
    
    dependencies:
      - name: google-cloudrun-service 
        version: 0.3.0
        repository: oci://ghcr.io/helmless
        alias: service 
    EOF
    
  2. Run helm dependency update to update the dependencies:
    helm dependency update
    

Step 4: Configure Your Service

Now you can configure your service using the values.yaml file.

cat <<EOF > values.yaml
global:
  region: "$(gcloud config get run/region)"
  project: "$(gcloud config get project)"
service:
  name: hello-helmless 
  image:
    name: "cloudrun/container/hello"
    repository: "us-docker.pkg.dev"
    tag: "latest"
  env:
    COLOR: "blue" 
EOF

Google Cloud Run Service Schema

You can find the full schema for the Google Cloud Run Service here.

Step 5: Template the Cloud Run Service Manifest

Next, you can template the Cloud Run Service manifest using the helm template command.

helm template --output-dir output .

This will generate a service.yaml manifest in the output directory that can be used to deploy your service using the gcloud CLI.

Step 6: Deploy Your Service

You can now deploy your service using the gcloud CLI.

gcloud run services replace output/**/service.yaml

That's it! Your service is now deployed to Google Cloud Run.

Step 7: Test Your Service

  1. Start the Cloud Run proxy:
    gcloud run services proxy hello-helmless
    
  1. Open http://localhost:8080 in your browser

You should see a blue-themed "Hello World" page! 🎉

Step 8: Add a Second Environment

Let's simulate a development environment by adding a values.dev.yaml file.

  1. Create a values.dev.yaml file:

    cat <<EOF > values.dev.yaml
    service:
      env:
        COLOR: "green"
    EOF
    

  2. Re-run the template with the new values:

    helm template --output-dir output -f values.dev.yaml .
    

  3. Deploy the new manifest:

    gcloud run services replace output/**/service.yaml
    

  4. Refresh your browser to see the new color!

Clean Up

When you're done, delete the service:

gcloud run services delete hello-helmless

What's Next?

  • CI/CD with Github Actions


    Learn how to deploy your Helmless chart using Github Actions.

    Learn More

  • Cloud Run Schemas


    See the full schema for the Google Cloud Run Service and Job.

    View Schema

  • Examples


    See an example of a Helmless chart for Google Cloud Run.

    View Examples

  • Architecture


    Learn more about Helmless and how it works.

    Learn More