Deploy an application to Cloud Run for Anthos (Knative serving)

Learn how to use the Google Cloud console to deploy a prebuilt sample container to run as a Cloud Run for Anthos (Knative serving) service.

Before you begin

You must have access to the Google Cloud project and cluster where Cloud Run for Anthos is installed. For details, see Cloud Run for Anthos fleet installation overview.

Tip: See the GKE Enterprise tutorial for details about the shortest path to setting up a GKE Enterprise environment that includes a GKE cluster and Anthos Service Mesh.

Deploying a sample container

Use the Google Cloud console to deploy a sample container and create a service in your cluster:

  1. In the Google Cloud console, go to the Cloud Run for Anthos page.

    Go to Cloud Run for Anthos

  2. Select the Google Cloud project in which your GKE cluster resides.

  3. In the list of available clusters, click Login to connect.

  4. Open the Create service form by clicking Create service.

  5. In the available clusters dropdown menu, select your cluster.

  6. Leave default as the name of the namespace where you want your service to run.

  7. Enter a service name of your choice. For example, hello.

  8. Click Next.

  9. Select Deploy one revision from an existing container image, then select hello from in the Demo containers list.

  10. Click Next.

  11. Select External under Connectivity, so that you can access your service from the web.

  12. Click Create to deploy the hello image to Cloud Run for Anthos and wait for the deployment to finish.

Congratulations! You have just deployed a service to a Cloud Run for Anthos enabled cluster.

Accessing your deployed service

Now that you have a service running, you can send requests to it. In this section, assuming that your cluster uses default name of the ingress gateway, the default test domain is used to demonstrate how to access your service and verify that it's working:

  1. In the Google Cloud console, go to the Cloud Run for Anthos page.

    Go to Cloud Run for Anthos

  2. Click the name of your new Cloud Run for Anthos service to open the Service details page. For example, hello.

  3. At the top of the page, click the URL to access your deployed service through your web browser. For example, if you named your service hello, the URL is similar to the following but includes your cluster's external IP address:

    The URL of the 'hello' service on the Service details page.

Congratulations! Your Cloud Run for Anthos service is live and handling requests.

Clean up

You can delete the Cloud Run for Anthos service to avoid incurring costs from running those resources.

The following considerations apply to deleting a service:

  • Deleting a service deletes all resources related to this service, including all revisions of this service whether they are serving traffic or not.
  • Deleting a service does not automatically remove container images from Container Registry. To delete container images used by the deleted revisions from Container Registry, refer to Deleting images.

  • Deleting a service with one or more Eventarc triggers does not automatically delete these triggers. To delete the triggers refer to Manage triggers.

  • After deletion, the service remains visible in the Google Cloud console and in the command line interface until the deletion is fully complete. However, you cannot update the service.

  • Deleting a service is permanent: there is no undo or restore. However, if after deleting a service, you deploy a new service with the same name in the same region, it will have the same endpoint URL.

To permanently delete the service and all its resources:

  1. Go to Cloud Run for Anthos

  2. In the services list, locate the Cloud Run for Anthos service that you created and click its checkbox to select it.

  3. Click DELETE.

What's next

To learn how to build a container from code source, push to Container Registry, and then deploy, see:

To learn more about how Cloud Run for Anthos works, see the Architectural overview.