A Quick Guide to Connect GKE Cluster from CentOS 8 / RHEL 8

To connect to a Google Kubernetes Engine (GKE) cluster from a CentOS 8 / RHEL 8 host machine, you can follow these general steps. Please note that you should have the Google Cloud SDK (gcloud) installed and configured on your CentOS 8 / RHEL 8 machine to interact with GKE clusters.

Here are the steps:

Install Google Cloud SDK:

If you haven’t already, you need to install the Google Cloud SDK on your CentOS 8 / RHEL 8 machine. You can do this by following the official documentation: https://cloud.google.com/sdk/docs/install

Initialize the SDK: After installation, you should initialize the Google Cloud SDK by running the following command in your terminal:


gcloud init

This command will guide you through the setup process, which includes:

  • Logging in with your Google account.
  • Selecting or creating a GCP project.
  • Setting the default configuration, which includes the project ID, region, and zone.
  • Authentication: You’ll be prompted to authenticate yourself using your Google account credentials. Follow the instructions provided during the authentication process.

Authenticate and Set Default Project:

Run the following commands to authenticate with your Google Cloud account and set your default project:


gcloud auth login

To list your GCP projects:


gcloud projects list

To set a default project if it’s not already set:


gcloud config set project PROJECT_ID

To list your Compute Engine instances:


gcloud compute instances list

Replace PROJECT_ID with your actual Google Cloud project ID.

Install kubectl:

kubectl is the Kubernetes command-line tool that you will use to interact with your GKE cluster. You can install it on CentOS 8 / RHEL 8 using the following commands:


sudo yum install -y kubectl

Get Credentials for the Cluster:

To configure kubectl to use your GKE cluster, run the following command:


gcloud container clusters get-credentials CLUSTER_NAME --zone ZONE_NAME

Replace CLUSTER_NAME with the name of your GKE cluster and ZONE_NAME with the zone where your cluster is located.

Verify Connection:

You can verify that you’re connected to your GKE cluster by running a simple kubectl command, such as:


kubectl get nodes

This should display a list of the nodes in your GKE cluster.

Now, you have successfully connected to your GKE cluster from your CentOS 8 / RHEL 8 host machine. You can use kubectl to manage and interact with your Kubernetes cluster as needed. Remember to configure your Kubernetes resources and access controls based on your application’s requirements.

References:

https://kubernetes.io/docs/
https://www.redhat.com/en/topics/containers/what-is-kubernetes
https://www.ibm.com/topics/kubernetes
https://www.infoworld.com/article/3268073/what-is-kubernetes-your-next-application-platform.html

 

Asif Khan

Asif Khan

DevOps, Linux, and Cloud engineer with 10+ years building infrastructure that stays up, and automation so I do not have to fix it at 2am. My focus is automation, security, and systems built to survive failure, using Infrastructure as Code, CI/CD, containers, monitoring, and cloud platforms instead of manual fixes. This blog is where I write down what worked, and just as often what didn't the first time around. Real tutorials you can run yourself, troubleshooting notes pulled from actual outages, and the kind of detail you only get once you've hit the problem firsthand. If you're trying to get Linux, DevOps, and cloud infrastructure to behave, that's what you'll find here: reproducible solutions you can understand, test, and apply in your own environment.