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:
In the Google Cloud console, go to the Knative serving page.
Select the Google Cloud project in which your GKE cluster resides.
In the list of available clusters, click Login to connect.
Open the Create service form by clicking Create service.
In the available clusters dropdown menu, select your cluster.
Leave
default
as the name of the namespace where you want your service to run.Enter a service name of your choice. For example,
hello
.Click Next.
Select Deploy one revision from an existing container image, then select hello from in the Demo containers list.
Click Next.
Select External under Connectivity, so that you can access your service from the web.
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:
In the Google Cloud console, go to the Knative serving page.
Click the name of your new Knative serving service to open the Service details page. For example, hello.
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:http://hello.default.kuberun.11.111.11.111.nip.io
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:
In the Google Cloud console, go to the Knative serving page.
In the services list, locate the Knative serving service that you created and click its checkbox to select it.
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.