{"id":719,"date":"2021-06-13T02:01:00","date_gmt":"2021-06-13T02:01:00","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=719"},"modified":"2021-06-13T02:01:00","modified_gmt":"2021-06-13T02:01:00","slug":"setup-kubernetes-cluster-google-cloud","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=719","title":{"rendered":"How To Configure and Setup Kubernetes Cluster On Google Cloud (GKE)"},"content":{"rendered":"<p>This guide walks you through deploying a Kubernetes Cluster on google cloud using the Google Kubernetes Engine (GKE).<\/p>\n<h2 id=\"about-google-kubernetes-engine\">About Google Kubernetes Engine<\/h2>\n<p>Google cloud offers its own managed Kubernetes service called Google Kubernetes Engine, also know as GKE.<\/p>\n<p>Several companies use GKE for their production workload. One of the best examples would be <a href=\"https:\/\/cloud.google.com\/blog\/products\/containers-kubernetes\/bringing-pokemon-go-to-life-on-google-cloud?ref=devopscube.com\" rel=\"noreferrer noopener\">hosting the PokemopnGo game on GKE<\/a>. In fact, it is the largest GKE deployment ever.<\/p>\n<p>Compared to other managed services like EKS (AWS) and AKS (Azure), GKE is relatively easy to set up and operate.<\/p>\n<p>In my <a href=\"https:\/\/devopscube.com\/docker-container-clustering-tools\/\" rel=\"noreferrer noopener\">container orchestration platform Post<\/a>, I have listed the difference between managed and self-hosted Kubernetes implementation. One main advantage of managed kubernetes clusters is the less administrative overhead.<\/p>\n<p>If you use GKE you can avoid the Kubernetes administrative overhead as it is taken care of by Google cloud. You just need to focus on deploying applications on Kubernetes.<\/p>\n<p>GKE has two types of clusters.<\/p>\n<ol>\n<li><strong>Autopilot Cluster:<\/strong> All cluster infrastructure operations are taken care of by Google cloud. You just have to focus on application deployments.<\/li>\n<li><strong>Standard Cluster<\/strong>:  Here except for the control plane, you have to manage the underlying infrastructure (Nodes, scaling etc)<\/li>\n<\/ol>\n<p>Following image shows the main difference between autopilot and standard GKE cluster.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/autopilot-vs-standard-1.png\" class=\"kg-image\" alt=\"difference between autopilot and standard GKE cluster.\" loading=\"lazy\" width=\"1428\" height=\"822\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/autopilot-vs-standard-1.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/autopilot-vs-standard-1.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/autopilot-vs-standard-1.png 1428w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>In this blog, I will focus only on the Standard GKE cluster. To know more about GKE, there is no better place than the google cloud <a href=\"https:\/\/cloud.google.com\/kubernetes-engine\/docs?ref=devopscube.com\" rel=\"noreferrer noopener\">official GKE documentation<\/a><\/p>\n<h2 id=\"create-vpc-with-gke-subnet-secondary-ip-ranges\">Create VPC With GKE Subnet &amp; Secondary IP Ranges<\/h2>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note:<\/strong><\/b> Ensure you have the IAM admin permissions to create the network, GKE cluster, and associated components.<\/div>\n<\/div>\n<p>You can create the GKE cluster in the default VPC provided by Google cloud. However, for learning and better understanding, lets create our own VPC.<\/p>\n<p>Normally, when we deploy non-containerized workloads on VPC, we would just create subnets with primarry IP ranges.<\/p>\n<p>When it comes to the GKE cluster,  we need to create a subnet to host the cluster nodes, and secondary IP ranges under the subnet for the kubernetes pod and service network. In google cloud term; it is called VPC native clusters.<\/p>\n<p>So, lets plan for nework for the following requirements.<\/p>\n<p><!--kg-card-begin: html--><\/p>\n<table class=\"has-fixed-layout\">\n<tbody>\n<tr>\n<td><strong>Cluster Requirements<\/strong><\/td>\n<td><strong>Calculated IP ranges<\/strong><\/td>\n<\/tr>\n<tr>\n<td>The cluster should accommodate 200 Nodes. (Primary Subnet)<\/td>\n<td>This means we need a subnet with a minimum of <strong>254 IP addresses<\/strong>. That is <code><strong>10.0.1.0\/24<\/strong><\/code><\/td>\n<\/tr>\n<tr>\n<td>Each node should accommodate 75 pods (Secondary range &#8211; Pod network)<\/td>\n<td>200&#215;75 = 15000 . So we will \/18 secondary range that would give 16384 IP addresses. 172.16.0.0\/18 (<strong>172.16.0.0 &#8211; 172.16.63.255<\/strong>)<\/td>\n<\/tr>\n<tr>\n<td>The cluster should support 2000 services. Secondary range &#8211; Service network)<\/td>\n<td>This means we need a \/21 range for the service network. Assuming we continue from the pod range, it would be be 172.16.64.0\/20 (<strong>172.16.64.0 &#8211; 172.16.79.255<\/strong>)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!--kg-card-end: html--><\/p>\n<p>Finally we have arrived to the following network ranges.<\/p>\n<ol>\n<li>Primary subnet (For Cluster Nodes) &#8211; <strong>10.0.1.0\/24<\/strong><\/li>\n<li>Secondary network (For pods) &#8211; <strong>172.16.0.0\/18<\/strong><\/li>\n<li>Secondary network (For services) &#8211; <strong>172.16.64.0\/20<\/strong><\/li>\n<\/ol>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/gke-cluster-1.png\" class=\"kg-image\" alt=\"GKE cluster network architecture\" loading=\"lazy\" width=\"2000\" height=\"1500\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/gke-cluster-1.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/gke-cluster-1.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/03\/gke-cluster-1.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/gke-cluster-1.png 2224w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>So here is what we are going to do.<\/p>\n<ol>\n<li>Create a VPC<\/li>\n<li>Add a subnet with pod and service secondary range networks.<\/li>\n<\/ol>\n<p>Now that we have finalized the network ranges let&#8217;s create a VPC network. I am calling network name as <code>gke-network<\/code><\/p>\n<pre><code>gcloud compute networks create gke-network --subnet-mode=custom<\/code><\/pre>\n<p>Create a subnet named <code>gke-subnet-a <\/code> with two secondary ranges named <code>pod-network <\/code>&amp; <code>service-network<\/code><\/p>\n<pre><code>gcloud compute networks subnets create gke-subnet-a \\\n    --network gke-network \\\n    --region us-central1 \\\n    --range 10.0.1.0\/24 \\\n    --secondary-range pod-network=172.16.0.0\/18,service-network=172.16.64.0\/20<\/code><\/pre>\n<p>By default the subnet creates a routed to the internet gateway. So you dont have to do anything to enable internet access for the nodes.<\/p>\n<p>However,  we need to add custom firewall rules to access the nodes from outside the VPC network.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note: <\/strong><\/b>When running production workloads, careful consideration has been given to the network design by keeping the subnets fully private without internet gateways.<\/div>\n<\/div>\n<p>Now we have the necessary network infrastructure to deploy a public GKE cluster.<\/p>\n<h2 id=\"setting-up-kubernetes-cluster-on-google-cloud\">Setting Up Kubernetes Cluster On Google Cloud<\/h2>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note:<\/strong><\/b> If you are looking for a self-hosted test\/POC kubernetes cluster setup on google cloud, you can use Kubeadm to quickly configure it. Refer to my <a href=\"https:\/\/devopscube.com\/setup-kubernetes-cluster-kubeadm\/\" rel=\"noreferrer noopener\">Kubeadm cluster setup guide<\/a> for setting up one master node and multi worker node Kubernetes setup.<\/div>\n<\/div>\n<p>There are two types of standard GKE cluster.<\/p>\n<ol>\n<li><strong>Public GKE cluster: <\/strong>Control plane node is publicly accessible, and all the worker nodes have a public interface attached to them. Here the cluster is secured using firewall rules and whitelisting only approved IP ranges to connect to the cluster API. This reduces the attack surface. The public clusters are normally not part of an organization&#8217;s hybrid network due to the fact that the nodes have a public interface.<\/li>\n<li><strong>Private GKE Cluster: <\/strong>The control plan and worker nodes get deployed in a predefined VPC network range defined by the user. The access to the cluster components will be completely private through VPC networks. Even though the control plane gets launched in the CIDR given by the user, that VPC gets created and managed by google cloud. We can only control the worker node subnets.<\/li>\n<\/ol>\n<p>This tutorial will guide you through the steps for setting up a highly available multi-zone public kubernetes cluster.<\/p>\n<h3 id=\"prerequitests\">Prerequitests<\/h3>\n<ol>\n<li>You should have <code>gcloud<\/code> configured from the machine you are trying to set up the cluster. Refer to <a href=\"https:\/\/devopscube.com\/setup-google-cloud-clisdk\/\" rel=\"noreferrer noopener\">google cloud SDK setup guide<\/a> to configure gcloud<\/li>\n<li>If you are using google cloud servers, gcloud is available by default. You should have the admin service account attached to the server for provisioning GKE services.<\/li>\n<\/ol>\n<h2 id=\"gke-cluster-creation-using-gcloud-cli\">GKE Cluster Creation Using gcloud CLI<\/h2>\n<p><strong>Step 1:<\/strong> We will use the gcloud CLI to launch a regional multi-zone cluster.<\/p>\n<p>In our setup, we will be doing the following.<\/p>\n<ol>\n<li>Spin up the cluster in <code>us-central1<\/code> the region with one instance per zone (total three zones) using <code>g1-small<\/code>(1.7GB) machine type with autoscaling enabled.<\/li>\n<li><strong>Preemptible VMs<\/strong> with autoscaling to a maximum of three-node per to reduce the cost of the cluster.<\/li>\n<li>Cluster gets deployed with custom <strong>VPC, subnets &amp; secondary ranges<\/strong> we created in the previous section.<\/li>\n<li>Enable the <strong>master authorized network<\/strong> to allow only whitelisted IP ranges to connect to the master API. I have given 0.0.0.0\/0, you can replace this with your IP address.<\/li>\n<li>Add a network tag named &#8220;<code>webapps<\/code>&#8221; to add a custom firewall rule to the GKE cluster nodes for testing purposes.<\/li>\n<\/ol>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note<\/strong><\/b>: When deploying a cluster in production, more configurations need to be considered for the network and the cluster. It depends on the organizational policy and project requirements.<\/div>\n<\/div>\n<p>Now, lets create the cluster using the following command.<\/p>\n<pre><code>gcloud container clusters create demo-gke \\\n      --region us-central1 \\\n      --no-enable-ip-alias \\\n      --node-locations us-central1-a,us-central1-b,us-central1-c \\\n      --num-nodes 1 \\\n      --enable-autoscaling \\\n      --min-nodes 1 \\\n      --max-nodes 3 \\\n      --node-labels=env=dev \\\n      --machine-type g1-small \\\n      --enable-autorepair  \\\n      --node-labels=type=webapps \\\n      --enable-vertical-pod-autoscaling \\\n      --preemptible \\\n      --disk-type pd-standard \\\n      --disk-size 50 \\\n      --enable-ip-alias \\\n      --network gke-network \\\n      --subnetwork gke-subnet-a \\\n      --cluster-secondary-range-name pod-network \\\n      --services-secondary-range-name service-network \\\n      --tags=webapp \\\n      --enable-master-authorized-networks \\\n      --master-authorized-networks=0.0.0.0\/0<\/code><\/pre>\n<p>On a successful execution, you will see the cluster details in the output as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-16-45.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"947\" height=\"157\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-16-45.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-16-45.png 947w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Also, you check the google kubernetes engine dashboard to view all the details about the cluster.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-17-35.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1105\" height=\"423\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-17-35.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/image-17-35.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-17-35.png 1105w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p><strong>Step 2: <\/strong>You can get all the information about the  GKE cluster using the following command.<\/p>\n<pre><code>gcloud container clusters describe  demo-gke --region=us-central1<\/code><\/pre>\n<p><strong>Step 3: <\/strong>Now, we need to download the cluster <code>kubeconfig<\/code> to our location workstation.<\/p>\n<p>The following command generates the <code>kubeconfig<\/code> and adds it to the <code>~\/.kube\/config<\/code> file.<\/p>\n<pre><code>gcloud container clusters get-credentials demo-gke  --region=us-central1<\/code><\/pre>\n<p>You can also get the connect command from the GKE GUI.<\/p>\n<h2 id=\"gcloud-kubectl-component-installation\">gcloud Kubectl Component Installation<\/h2>\n<p>Kubectl is a command-line utility for interacting with the kubernetes cluster. You can get more information about kubectl <a href=\"https:\/\/kubernetes.io\/docs\/user-guide\/kubectl-overview\/?ref=devopscube.com\" rel=\"noopener\">from here<\/a><\/p>\n<p>If you already have <code>kubectl<\/code> in your workstation, you can ignore this step.<\/p>\n<p>To install kubectl component, execute the following gcloud command.<\/p>\n<pre><code>gcloud components install kubectl<\/code><\/pre>\n<p>Now, you can get your cluster information using the kubectl command using the following command.<\/p>\n<pre><code>kubectl cluster-info<\/code><\/pre>\n<p>The output would look like the following.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-18-39.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"595\" height=\"178\"><\/figure>\n<h2 id=\"deploy-nginx-on-gke-for-validation\">Deploy Nginx on GKE for Validation<\/h2>\n<p>Let&#8217;s deploy a sample Nginx application in a custom namespace to validate the cluster.<\/p>\n<p><strong>Step 1:<\/strong> Create a namespace named demo<\/p>\n<pre><code>kubectl create namespace demo<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Let&#8217;s deploy a sample Nginx app in the demo namespace. Also, create a Nodeport service for testing purposes.<\/p>\n<p>Copy the following and execute directly on the terminal.<\/p>\n<pre><code>cat &lt;&lt;EOF | kubectl apply -f -\n---\napiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: nginx-deployment\n  namespace: demo\nspec:\n  selector:\n    matchLabels:\n      app: nginx\n  replicas: 2 \n  template:\n    metadata:\n      labels:\n        app: nginx\n    spec:\n      containers:\n      - name: nginx\n        image: nginx:latest\n        ports:\n        - containerPort: 80\n---\napiVersion: v1\nkind: Service\nmetadata:\n  name: nginx-service\n  namespace: demo\nspec:\n  selector:\n    app: nginx\n  type: NodePort\n  ports:\n    - port: 80\n      targetPort: 80\n      nodePort: 32000\nEOF<\/code><\/pre>\n<p>Lets check the deployment status.<\/p>\n<pre><code>kubectl get deployments -n demo<\/code><\/pre>\n<p>Also lets describe the service and check the nodePort details.<\/p>\n<pre><code>kubectl describe svc nginx-service -n demo<\/code><\/pre>\n<p><strong>Step 3: <\/strong>Now to access the application on node port <code>32000<\/code>, you need to add an ingress firewall rule to allow traffic on port 32000 from the internet.<\/p>\n<p>This rule is applicable for all instances with <code>gke-webapps<\/code> tag in <code>gke-network<\/code><\/p>\n<pre><code>gcloud compute firewall-rules create gke-webapps \\\n    --network=gke-network \\\n    --allow=tcp:32000 \\\n    --description=\"Allow incoming traffic on TCP port 32000\" \\\n    --direction=INGRESS \\\n    --source-ranges=\"0.0.0.0\/0\" \\\n    --target-tags=\"gke-webapps\"<\/code><\/pre>\n<p>For demonstration purposes, I am adding <code>0.0.0.0\/0<\/code> as the source IP range. Meaning, allow traffic from anywhere on the internet.<\/p>\n<p>You can get your public IP by a simple google search and add it as a source instead of <code>0.0.0.0\/0<\/code><\/p>\n<p>For example, <code>53.45.78.32\/32 <\/code>as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-7-59.png\" class=\"kg-image\" alt=\"get public IP from a google search for GKE firewall\" loading=\"lazy\" width=\"498\" height=\"283\"><\/figure>\n<p>We deployed the cluster with a network tag named &#8220;<code>gke-webapps<\/code>&#8220;. So we need to add a firewall rule that applies to the <code>gke-webapps<\/code> tag. The rule gets applied to all the cluster instances as it has the <code>gke-webapps<\/code> tag attached to it.<\/p>\n<p><strong>Step 5: <\/strong>Now that we have added the rule, lets try accessing the Nginx app using a nodes IP.<\/p>\n<p>The following command will list all GKE nodes with their public IP address. Grab one IP and try accessing port 32000 and see if you can access the Nginx page.<\/p>\n<pre><code>gcloud compute instances list --filter=\"name~'gke-demo-*'\"<\/code><\/pre>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-8-56.png\" class=\"kg-image\" alt=\"GKE list all Public IP for Nodes \" loading=\"lazy\" width=\"1111\" height=\"113\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-8-56.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/image-8-56.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-8-56.png 1111w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>For example, <code>http:\/\/35.224.101.80:32000\/<\/code><\/p>\n<p>You should see the Nginx page.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-9-41.png\" class=\"kg-image\" alt=\"GKE deploy sample Nginx app on NodePort service\" loading=\"lazy\" width=\"559\" height=\"248\"><\/figure>\n<h2 id=\"expose-nginx-as-a-loadbalancer-service\">Expose Nginx as a Loadbalancer Service<\/h2>\n<p>The same deployment can be exposed as a Loadbalancer by modifying the NodePort to Loadbalancer in the service file. GKE will create a Loadbancer that points to the Nginx service endpoint.<\/p>\n<pre><code>apiVersion: v1\nkind: Service\nmetadata:\n  name: nginx-service\n  namespace: demo\nspec:\n  selector:\n    app: nginx\n  type: LoadBalancer\n  ports:\n    - port: 80\n      targetPort: 80<\/code><\/pre>\n<h2 id=\"accessing-kubernetes-objects-from-gke-dashboard\">Accessing Kubernetes Objects From GKE Dashboard<\/h2>\n<p>Kubernetes dashboard is not part of the default GKE setup. The dashboard addon is depricated.<\/p>\n<p>However, there is a workload explorer in the Kubernetes engine dashboard. You can browse all the cluster objects from the dashboard.<\/p>\n<p>I have recorded a small demo in the following gif file. Take a look.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/gke-object-explorer-1.gif\" class=\"kg-image\" alt=\"Exploring GKE kubernetes resources in Kubernetes engine dashbaord.\" loading=\"lazy\" width=\"1728\" height=\"1080\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/gke-object-explorer-1.gif 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/gke-object-explorer-1.gif 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/03\/gke-object-explorer-1.gif 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/gke-object-explorer-1.gif 1728w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h2 id=\"gke-cluster-logging-monitoring\">GKE Cluster Logging &amp; Monitoring<\/h2>\n<p>By default GKE pushes all the logs to its Stackdriver logging and monitoring systems.<\/p>\n<p>You can check the cluster logs from the Kubernetes engine dashboard.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-10-56.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"2000\" height=\"1419\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-10-56.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/image-10-56.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/03\/image-10-56.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w2400\/2025\/03\/image-10-56.png 2400w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>From the monitoring dashboard you can create alerts based on the metrics generated from the cluster.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note: <\/strong><\/b>When it comes to production level logging, organizations push the logs to central logging systems like Splunk through pub-sub. And tools like Prometheus are used to collect all the cluster resource metrics (Nodes, pods, etc.)<\/div>\n<\/div>\n<h2 id=\"troubleshooting-gke-nodes\">Troubleshooting GKE Nodes<\/h2>\n<p>If you use the default container optimized OS (COS) for the GKE cluster, there are only a limited utilities for troubleshooting the node issues.<\/p>\n<p>Also, COS does  not come with any package manager.<\/p>\n<p>However, GKE provides a command that deploys a container in which you can install the required utilities using from the <code>apt<\/code> package manager.<\/p>\n<p>Here is what you need to do. Login to a GKE node.<\/p>\n<p>Execute the following command. It will automatically log in to a toolbox container with root privileges.<\/p>\n<pre><code>toolbox<\/code><\/pre>\n<p>Then, you can install required troubleshooting utilities and carry on with the node troubleshooting.<\/p>\n<h2 id=\"delete-gke-cluster\">Delete GKE Cluster<\/h2>\n<p>If you want to delete the GKE cluster, use the following command.<\/p>\n<pre><code>gcloud container clusters delete demo-gke --region us-central1  --quiet<\/code><\/pre>\n<p>Also, to remove the firewall rule, execute the following command.<\/p>\n<pre><code>gcloud compute firewall-rules delete gke-webapps --quiet<\/code><\/pre>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>Setting up a Kubernetes cluster on google cloud is an easy task.<\/p>\n<p>However, many configurations need to be considered for production setup from a security, scalability, and network standpoint.<\/p>\n<p>Refer to the <a href=\"https:\/\/devopscube.com\/key-considerations-kubernetes-cluster-design-setup\/\" rel=\"noreferrer noopener\">Kubernetes design consideration<\/a> blog for some standard design recommendations.<\/p>\n<p>If you have any questions, let me know in the comments.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/setup-kubernetes-cluster-google-cloud\/\" target=\"_blank\" rel=\"noopener noreferrer\">How To Configure and Setup Kubernetes Cluster On Google Cloud (GKE) \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/setup-kubernetes-cluster-google-cloud\/<\/p>\n","protected":false},"author":1,"featured_media":720,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-719","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/719","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=719"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/719\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/720"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=719"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=719"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=719"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}