Google Kubernetes Engine

Part of Google Cloud Skills Boost labs

Google Kubernetes Engine(GKE)

  • Kubernetes is an open source system for automating deployment, scaling, and management of containerized applications.

  • Google Kubernetes Engine(GKE) is a fully managed Kubernetes service with full Kubernetes API, 4-way autoscaling, release channels, and multi-cluster support.

  • We’ll learn how to create a GKE cluster, deploy an application to the cluster and delete the cluster

1. Create GCP account

2. Activate Cloud Shell

  • Click Activate Cloud Shell at the top of the Google Cloud console: Vite utilizes ESBuild, a Go-based bundler, for production builds. ESBuild is renowned for its incredible speed and efficiency.
  • List the active account name
    gcloud auth list 

Ouput:

ACTIVE: *
ACCOUNT: <account name>

To set the active account, run:
    $ gcloud config set account `ACCOUNT`
  • List the project ID:
gcloud config list project
[core]
project = qwiklabs-gcp-03-e98c139c8c35

3. Configure your environment

  1. Set the region to us-east1
gcloud config set compute/region us-east1
  1. View the project region setting
gcloud config get-value compute/region
  1. Set zone to us-east1-b:
gcloud config set compute/zone us-east1-b
  1. View project zone setting.
gcloud config get-value compute/zone

4. Create a GKE cluster

A cluster consists of at least one cluster master and multiple worker machines called nodes. Nodes are Computer Engine virtual machine instances that run the Kubernetes processes necessary to make them part of the cluster.

  • Create a cluster: gcloud container clusters create --machine-type=e2-medium --zone=ZONE lab-cluster

5. Get authentication credentials for the cluster

  • You need authentication credentials to interact with the cluster.
  • Authenticate with the cluster: gcloud container clusters get-credentials lab-cluster

6. Deploy an app to the cluster

  • Example: deploy and run the hello-app in the cluster
  1. Run the following kubectl create command to create a new Deployment hello-server from the hello-app container image
kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:1.0
  1. Create a Kubernetes Service, a k8s resource that lets you expose your application to external traffic, using the following kubectl expose command.
kubectl expose deployment hello-server --type=loadBalancer --port 8080
  1. Run kubectl get command to inspect the hello-server: kubectl get service

  2. View the application from the web browser. http://[EXTERNAL-IP]:8080

7. Deleting the cluster

  1. Delete the cluster: gcloud container clusters delete lab-cluster
  2. When prompted, type Y to confirm.



Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • How to set up live reloading Golang
  • Running LLMs Locally with Open Web UI and Ollama
  • Intro to GCP Cloud Shell and gcloud
  • Creating A Build Tool Using Go
  • Using Tiled with Kaplay