Quantcast
Channel: Cloud Training Program
Viewing all articles
Browse latest Browse all 1891

How To Create A Google Kubernetes Engine Cluster (GKE): Standard & Autopilot [2023]

$
0
0

In Google Kubernetes Engine (GKE), a cluster is a set of virtual machines (VMs) that run containerized applications managed by Kubernetes. A cluster consists of one or more node pools, which are groups of virtual machines that share the same configuration settings. Each node in the cluster runs a Kubernetes node agent, which manages the containers running on that node and communicates with the Kubernetes master to orchestrate the deployment and scaling of the applications running on the cluster.

In this blog post, we will take you through the steps of creating a managed Kubernetes cluster on the Google Cloud Platform i.e. Google Kubernetes Engine (GKE)

We will cover:

Things to Know

1. There are two Kubernetes options:

  • DIY Kubernetes 
  • Managed Kubernetes like GKE, EKS, AKS, OKE, etc 

2. There are two types of GKE Clusters:

  • Standard
  • Autopilot

Within Standard GKE you can deploy as:

  • Regional
  • Zonal

Note: Autopilot GKE is always Regional

To learn more on Region & Zones in GKE Click Here

What is GKE?

GKE clusters are powered by the open-source cluster management system Kubernetes. Kubernetes provides the mechanisms for interacting with your cluster. You deploy and manage your applications, perform administration tasks, set policies, and monitor the health of your deployed workloads using Kubernetes commands and resources.

GKE Logo

GKE (Google Kubernetes Engine) is a managed environment for deploying, managing and scaling containerized applications on Google infrastructure. The GKE environment is made up of multiple machines (specifically, Compute Engine instances) that are clustered together.

Types of GKE Cluster

Clusters in GKE can be of two varieties:

  • Autopilot: Provides a cluster configuration that is fully provisioned and managed. The cluster configuration options for Autopilot-created clusters are created for you. Autopilot clusters have an optimized cluster configuration that is ready for production workloads.
  • Standard: Provides advanced configuration flexibility over the underlying infrastructure of the cluster. The configurations required for your production workloads are determined for clusters created in Standard mode.

GKE Cluster type

Source: GKE Docs

How to Create Kubernetes Cluster on GCP

Google Kubernetes Engine (GKE) is a Kubernetes service that allows you to quickly deploy and manage cluster master and worker nodes. Creating a GKE cluster is simple, and there are numerous manuals available to help you along the way. By following the steps described below, you can easily create a cluster.

We can create a GKE cluster using:

  1. Console 
  2. CLI

Now let us look at how do we create a cluster using GCP console. But before all that you should have a GCP Cloud account to create a cluster. Create a Free Google Cloud Platform Account to get $300 free credit on your GCP portal.

Setting up an Environment

To create a cluster first there is a need to select a project:

1. Navigate to https://console.cloud.google.com/ and sign in with your Google Account Credentials.

2. Select your existing project or if you do not have one then click on create a new project.Select project

3. After selecting the project, in the Cloud Console, navigate to the Navigation menu > Kubernetes Engine.

 Note: Make sure you have selected the correct project.

4. Click on Enable to enable the API.

Enable API

Note: Now we are ready to create a cluster of any type.

Steps To Create GKE Cluster Using Console

We will create both Autopilot and Standard clusters using the console here.

Create an Autopilot cluster

Autopilot is a GKE operation mode that allows you to concentrate on your services and applications while Google manages your nodes and infrastructure. GKE provisions configure and manage the resources and hardware when you deploy your workloads, including when you scale.

To create an Autopilot cluster in Google Kubernetes Engine (GKE), you can follow these steps:

1. Log in to the Google Cloud Console (console.cloud.google.com).

2. Select your project from the drop-down menu at the top of the screen.

3. Click on the Navigation menu (☰) in the upper-left corner and select “Kubernetes Engine” under “Compute”.

4. Click “Create cluster” to start the cluster creation process.

create cluster

5. Under the “Cluster mode” section, select “Autopilot”.

4

6. Configure the cluster settings, such as the cluster name, location, and node pool size.

5

7. Choose the desired Kubernetes version for the cluster.

8. Customize additional settings like node configuration, networking, and security options as required.

networking

Networking defines how applications in the cluster communicate with each other and how clients can reach them.

Note: By default, you can configure access from public networks to your cluster’s workloads. Routes are not created automatically. Private clusters assign internal addresses to Pods and nodes, and workloads are completely isolated from public networks.

9. Leave the default settings for Advanced Options as that is an optional field. Click “Create” to start the cluster creation process

7

8

After a few minutes, your Autopilot GKE cluster will be ready for use. Autopilot manages the cluster resources for you, so you don’t need to worry about node sizing, scaling, or upgrades. You can then deploy your applications to the cluster using Kubernetes commands or using the Google Cloud Console.

Create a Standard cluster

To create a Standard cluster in Google Kubernetes Engine (GKE), you can follow these steps:

1. Log in to the Google Cloud Console (console.cloud.google.com).

2. Select your project from the drop-down menu at the top of the screen.

3. Click on the Navigation menu (☰) in the upper-left corner and select “Kubernetes Engine” under “Compute”.

GKE

4. Click “Create cluster” to start the cluster creation process.

GKE

5. Under the “Location” section, select the “Zonal” option.

GKE

6. Choose the desired zone where you want to create the cluster.

GKE

  • Name: k21cluster1
  • Location Type: Zonal
  • Zone: asia-southeast1-c (you can select the default location also i.e., us-central1-c)

7. From the left pane, select default-pool under NODE POOLS.

GKE

Note – A node pool is a group of nodes within a cluster that all have the same configuration. Node pools use a NodeConfig specification. When you create a cluster, the number of nodes and type of nodes that you specify becomes the default node pool. Then, you can add additional custom node pools of different sizes and types to your cluster. All nodes in any given node pool are identical to one another.

GKE

Specify a name for the default pool and a number of nodes required. Leave everything as default.

  • Name: k21demo-default-pool
  • Number of nodes: 3

8. Configure the other cluster settings, such as machine type.

GKE

GKE

9. Choose the desired Kubernetes version for the cluster.

10. Customize additional settings like node configuration, networking, and security options as required.

11. Click “Create” to start the cluster creation process.

GKE

GKE

After a few minutes, your zonal GKE cluster will be ready for use. You can then deploy your applications to the cluster using Kubernetes commands or using the Google Cloud Console.

Steps To Create GKE Cluster Using CLI

1. Create a Cluster by executing the following command:

$ gcloud container clusters create [CLUSTER-NAME]

Note: Replace [CLUSTER-NAME] with a unique name of your choice.

cli1

2. Authenticating a cluster

To interact with your cluster, it is imperative that you get the authentication credentials for the same.

To authenticate the cluster, run the following command:

$ gcloud container clusters get-credentials [CLUSTER-NAME]

Note: Replace [CLUSTER-NAME] with the name of your cluster.

cli2

Connect to the GKE Cluster

1. Now to connect a cluster  Click on Connect.

Connect 1

2. Click on Run In cloud shell  & Continue.

connect 2

connect 3

3. Run the command given

connect 4

4. Finally, test the connection by running the below Kubectl command

$ kubectl get nodes

Delete Cluster

To delete a cluster in Google Kubernetes Engine (GKE), you can follow these steps:

1. Log into the Google Cloud Console (console.cloud.google.com).

2. Select your project from the drop-down menu at the top of the screen.

3. Click on the Navigation menu (☰) in the upper-left corner and select “Kubernetes Engine” under “Compute”.

4. Click on the name of the cluster that you want to delete.

delete 1

6. Click the “Delete” button in the top bar to delete the cluster.

7. In the confirmation dialog box, enter the cluster name and click “Delete”.

delete 2

Note:  Deleting a cluster will permanently delete all of the nodes, pods, services, and other resources in the cluster. Make sure that you have a backup of any data that you want to preserve before deleting the cluster. Also, deleting a cluster will stop all billing for the cluster, so make sure that you have downloaded any billing data that you need before deleting the cluster.

Conclusion

So in the above steps, we have covered all concepts related to a GKE cluster and also we have learned how to create different types of GKE clusters & connect with them. Finally, we saw how to delete a cluster.

Related/References

Join FREE Masterclass

To know about what is the Roles and Responsibilities of Kubernetes administrator, why you should learn Docker and KubernetesJob opportunities for Kubernetes administrator in the market, and what to study Including Hands-On labs you must perform to clear Certified Kubernetes Administrator (CKA) certification exam by registering for our FREE Masterclass.k8s content upgrade

The post How To Create A Google Kubernetes Engine Cluster (GKE): Standard & Autopilot [2023] appeared first on Cloud Training Program.


Viewing all articles
Browse latest Browse all 1891

Trending Articles