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
- Set the region to
us-east1
gcloud config set compute/region us-east1
- View the project region setting
gcloud config get-value compute/region
- Set zone to
us-east1-b
:
gcloud config set compute/zone us-east1-b
- 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
- Run the following
kubectl create
command tocreate 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
- Create a
Kubernetes Service
, a k8s resource that lets you expose your application to external traffic, using the followingkubectl expose
command.
kubectl expose deployment hello-server --type=loadBalancer --port 8080
-
Run
kubectl get
command to inspect thehello-server
:kubectl get service
-
View the application from the web browser.
http://[EXTERNAL-IP]:8080
7. Deleting the cluster
- Delete the cluster:
gcloud container clusters delete lab-cluster
- When prompted, type
Y
to confirm.
Enjoy Reading This Article?
Here are some more articles you might like to read next: