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
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
Ouput:
1
2
3
4
5
| ACTIVE: *
ACCOUNT: <account name>
To set the active account, run:
$ gcloud config set account `ACCOUNT`
|
1
| gcloud config list project
|
1
2
| [core]
project = qwiklabs-gcp-03-e98c139c8c35
|
- Set the region to
us-east1
1
| gcloud config set compute/region us-east1
|
- View the project region setting
1
| gcloud config get-value compute/region
|
- Set zone to
us-east1-b:
1
| gcloud config set compute/zone us-east1-b
|
- View project zone setting.
1
| 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 to create a new Deployment hello-server from the hello-app container image
1
| 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 following kubectl expose command.
1
| kubectl expose deployment hello-server --type=loadBalancer --port 8080
|
-
Run kubectl get command to inspect the hello-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.