- Click Activate Cloud Shell at the top of the Google Cloud console.
- Set Compute Zone
gcloud config set compute/zone us-central1-a
- Create a New Cluster
gcloud container clusters create hello-world
- You will use Project ID in many of the commands in this lab. The Project ID is conveniently stored in an environment variable in Cloud Shell. You can see it here:
- Run the following to clone the samples:
git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git
- Change directories:
- Docker containers are built using a Dockerfile. The sample code provides a basic Dockerfile that we can use.
- Run the following command to publish your container image:
gcloud docker -- push gcr.io/$DEVSHELL_PROJECT_ID/hello-node:1.0
- Create the pod using kubectl:
kubectl create deployment hello-node --image=gcr.io/$DEVSHELL_PROJECT_ID/hello-node:1.0
- Run the following to expose the deployment with the kubectl expose command:
kubectl expose deployment hello-node --name=hello-node --type=LoadBalancer --port=80 --target-port=8080
- To get the IP address for your service, run the following command:
kubectl get svc hello-node
- Open a new browser window or tab and navigate to the external IP address from the previous step. You should see the sample code up and running!