0
0
GCPcloud~5 mins

Why managed Kubernetes matters in GCP - Why It Works

Choose your learning style9 modes available
Introduction
Running Kubernetes on your own means handling complex setup and maintenance. Managed Kubernetes services take care of this for you, so you can focus on your apps instead of the infrastructure.
When you want to deploy containerized apps without managing the underlying servers and Kubernetes control plane.
When you need automatic updates and security patches for your Kubernetes cluster.
When you want easy scaling of your app without manual intervention on the cluster.
When you prefer to avoid the complexity of setting up networking and storage for Kubernetes.
When you want integrated monitoring and logging without extra setup.
Commands
This command creates a managed Kubernetes cluster named 'example-cluster' with 3 nodes in the specified zone. It sets up the control plane and worker nodes automatically.
Terminal
gcloud container clusters create example-cluster --zone us-central1-a --num-nodes 3
Expected OutputExpected
Creating cluster example-cluster in us-central1-a... Created [https://container.googleapis.com/v1/projects/my-project/zones/us-central1-a/clusters/example-cluster]. To inspect the contents of your cluster, go to: https://console.cloud.google.com/kubernetes/workload_/gcloud/us-central1-a/example-cluster?project=my-project kubeconfig entry generated for example-cluster. NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS example-cluster us-central1-a 1.26.3-gke.100 35.233.123.45 e2-medium 1.26.3-gke.100 3 RUNNING
--num-nodes - Sets the number of worker nodes in the cluster
--zone - Specifies the compute zone for the cluster
This command lists all the worker nodes in the Kubernetes cluster to verify they are ready and connected.
Terminal
kubectl get nodes
Expected OutputExpected
NAME STATUS ROLES AGE VERSION example-cluster-default-pool-1a2b3c4d-5f6g7h8i Ready <none> 2m v1.26.3-gke.100 example-cluster-default-pool-1a2b3c4d-9j0k1l2m Ready <none> 2m v1.26.3-gke.100 example-cluster-default-pool-1a2b3c4d-3n4o5p6q Ready <none> 2m v1.26.3-gke.100
This command deletes the managed Kubernetes cluster to clean up resources when no longer needed.
Terminal
gcloud container clusters delete example-cluster --zone us-central1-a --quiet
Expected OutputExpected
Deleting cluster example-cluster in us-central1-a... Deleted [https://container.googleapis.com/v1/projects/my-project/zones/us-central1-a/clusters/example-cluster].
--quiet - Skips confirmation prompt for deletion
Key Concept

Managed Kubernetes handles the hard parts of running a cluster so you can focus on your applications.

Common Mistakes
Trying to set up Kubernetes manually without using a managed service.
Manual setup is complex, error-prone, and requires ongoing maintenance.
Use a managed Kubernetes service like GKE to automate cluster management.
Not specifying the zone or region when creating the cluster.
The command will fail or create the cluster in an unexpected location.
Always include the --zone or --region flag with a valid location.
Forgetting to delete the cluster after use.
Clusters incur costs even when not in use.
Run the delete command to remove the cluster and avoid charges.
Summary
Create a managed Kubernetes cluster with gcloud to avoid manual setup.
Use kubectl to check that your cluster nodes are ready and running.
Delete the cluster when done to save costs and clean up resources.