Cloud run demo
"Hello World" is a simple Kubernetes application that contains a single Deployment and a corresponding Service. The Deployment contains a web server that simply prints "Hello World".
This sample was written to demonstrate how to use the Cloud Code extension for Visual Studio code.
gcloud builds submit --tag gcr.io/cloud-build-1/helloworld #Build your container image using Cloud Build. The image is stored in Container Registry and can be re-used if desired
gcloud beta run deploy --image gcr.io/cloud-build-1/helloworld #respond y to allow unauthenticated invocations.
Cloud Run automatically and horizontally scales your container image to handle the received requests, then scales down when demand decreases. You only pay for the CPU, memory, and networking consumed during request handling.
gcloud beta container clusters create shane-gke \
--addons=HorizontalPodAutoscaling,HttpLoadBalancing,Istio,CloudRun \
--machine-type=n1-standard-4 \
--cluster-version=latest \
--zone=us-central1-a \
--enable-stackdriver-kubernetes --enable-ip-alias \
--scopes cloud-platform
gcloud config set run/cluster [shane-gke]
gcloud config set run/cluster_location us-central1-a
gcloud beta run deploy --image gcr.io/cloud-build-1/helloworld --cluster shane-gke
#Scroll down to the istio-ingressgateway service and copy the external IP address shown next to the Load Balancer. Ignore the other values.
curl -H "Host: helloworld.default.example.com" [LOAD_BALANCER_IP] #access the service
Note that although these instructions don't enable cluster autoscaling to resize clusters for demand, Cloud Run on GKE automatically scales instances within the cluster.
As an alternative to using the Cloud Code extension, the application can be deployed to a cluster using standard command line tools
Skaffold is a command line tool that can be used to build, push, and deploy your container images
skaffold run --profile cloudbuild -v=debug
Currently get an error
FATA[0002] build failed: building [gcr.io/cloud-build-1/helloworld]: checking bucket is in correct project: iterating over buckets: Get https://www.googleapis.com/storage/v1/b?alt=json&pageToken=&prefix=cloud-build-1_cloudbuild&project=cloud-build-1&projection=full: oauth2: cannot fetch token: unexpected EOF
kubectl is the official Kubernetes command line tool. It can be used to deploy Kubernetes manifests to your cluster, but images must be build seperately using another tool (for example, using the Docker CLI)