shavo007 / hello-world

Cloud run demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hello World with Cloud Code

Architecture Diagram

"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".


Table of Contents

Cloud Code for Visual Studio Code

  1. Getting Started
  2. What's in the box
  3. Using Cloud Code
  4. Using the Command Line

Getting Started

This sample was written to demonstrate how to use the Cloud Code extension for Visual Studio code.


Three options

  1. Cloud run vanilla

Containerizing an app and uploading it to Container Registry

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

Deploy to cloud run

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.

Cloud Run console

  1. Cloud run on GKE with istio and knative
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.

Using the Command Line

As an alternative to using the Cloud Code extension, the application can be deployed to a cluster using standard command line tools

Skaffold

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

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)

Resources

About

Cloud run demo


Languages

Language:JavaScript 50.5%Language:Dockerfile 49.5%