Deploy an application to Knative serving

Learn how to use the Google Cloud console to deploy a prebuilt sample container to run as a Knative serving service.

Before you begin

You must have access to the Google Cloud project and cluster where Knative serving is installed. For details, see Knative serving 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 Cloud 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 Knative serving page.

    Go to Knative serving

  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 Knative serving and wait for the deployment to finish.

Congratulations! You have just deployed a service to a Knative serving 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 Knative serving page.

    Go to Knative serving

  2. Click the name of your new Knative serving 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:

Congratulations! Your Knative serving service is live and handling requests.

Clean up

You can delete the Knative serving 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. In the Google Cloud console, go to the Knative serving page.

    Go to Knative serving

  2. In the services list, locate the Knative serving 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 Knative serving works, see the Architectural overview.