This page shows you how to create a Google Kubernetes Engine cluster enabled for Cloud Run for Anthos on-prem and deploy a prebuilt sample container to the cluster.
Before you begin
- This quickstart assumes you have an active GKE on-prem cluster
with Cloud Run for Anthos enabled. To create one, see
Creating a GKE on-prem cluster
with Cloud Run for Anthos enabled.
For more information on Anthos, see Pricing for Anthos.
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Cloud project. Learn how to confirm that billing is enabled for your project.
- To send a request to the deployed sample service, install cURL.
- Set up the
gcloud
command line and thekubectl
command line tool, described next.
Setting up gcloud
To set up the gcloud
command line for Cloud Run for Anthos on-prem:
If you haven't already, install and initialize the Cloud SDK.
Set the platform to
kubernetes
and set your default project setting forgcloud
to the one you just created:gcloud config set run/platform kubernetes gcloud config set project PROJECT-ID
Replace PROJECT_ID with your project ID.
Update installed
gcloud
components:gcloud components update
Install the
gcloud
components:gcloud components install beta
Setting up kubectl
If you are already using GKE on-prem, kubectl
may already be
installed.
If kubectl
is not installed, you can install it using the command:
gcloud components install kubectl
Deploying a sample container
To deploy a container to the cluster you just created:
Run the command:
gcloud run deploy SERVICE --image IMAGE_URL
- Replace SERVICE with the name of the service you are deploying to. You can omit this parameter entirely, but you will be prompted for the service name if you omit it.
- Replace
IMAGE_URL
with a reference to the container image, for example,gcr.io/myproject/my-image:latest
.
Wait for the deployment to finish. Upon successful completion, a success message is displayed with the URL of the deployed service.
Accessing your deployed service
After deploying your service, you can use cURL to send a request and verify the service is working, using the external IP address of the Load Balancer service created for the Istio ingress controller:
Get and note the IP address using the
kubectl
command line:kubectl get svc istio-ingress -n gke-system --output 'jsonpath={.status.loadBalancer.ingress[0].ip}'
Get and note the host name using the
kubectl
command line:kubectl get route SERVICE --output jsonpath='{.status.url}' | sed 's/https\?:\/\///'
Replace SERVICE with the name of the service.
Invoke cURL with the
HOST_URL
andIP_ADDRESS
of your service:curl -v -H "Host: HOST_URL" http://IP_ADDRESS
Replace:
- HOST_URL with the host name you obtained in previous steps.
- IP_ADDRESS with the IP address you obtained in previous steps.
Clean up
Delete your Cloud Run for Anthos on-prem service by executing:
gcloud run services delete SERVICE
Replace SERVICE with the name of the service.
What's next
To learn how to build a container from code source, push to Container Registry, and deploy, refer to: