How-to-connect-with-kubernetes

December 12, 2024
Tags:  ·   ·   ·   ·   · 
Create an Utho account to try this guide with a $100 credit.

How to connect with Kubernetes cluster using Linux

This document provides a step-by-step guide on connecting to a Kubernetes cluster using Linux, including installing kubectl, configuring access with the kubeconfig file, and verifying cluster connection and pod status.


Prerequisites

  • Access to the Utho Cloud UI.
  • Access to the Kubernetes cluster provided by Utho Cloud.
  • The kubeconfig file downloaded from the Utho Kubernetes cluster.
  • A Linux-based system with administrative privileges.

Deployment Steps

Step 1: Installing kubectl Using Snap

The simplest way to install kubectl on your Linux system is by using Snap. Here’s how to do it:

1. Install kubectl via Snap:

Run the following command to install kubectl:

sudo sna p install kubectl --classic

2. Verify Installation version:

To verify that kubectl has been installed correctly,check the version of the client using the command below:

 kubectl version --client

Download the kubeconfig file from the Utho k8s cluster.

3. How to Transfer Cluster File:

If you want to transfer cluster file from one Linux system to another Linux system.

 sudo rsync -av kubeconfig_mks_$CLUSTERID.yaml root@<server-ip>:~/kubeconfig_mks_$CLUSTERID.yaml

Step 2: Configuring Access to Your Kubernetes

To access and manage your Kubernetes cluster, you need to configure kubectl with the cluster configuration file (kubeconfig).

1. Set the KUBECONFIG environment variable:

Assuming the Kubernetes config file is located at /root/kubeconfig_mks_$CLUSTERID.yaml, use the following command to point kubectl to the correct configuration file:

 export KUBECONFIG=/root/kubeconfig_mks_$CLUSTERID.yaml

2. Verify Cluster Connection:

To ensure you’re connected to the cluster, run:

 kubectl cluster-info

Step 3: Checking Running Pods in the Kubernetes

1. Check Pods:

To see the pods running in your Kubernetes cluster, use the following command:

 kubectl get nodes
 kubectl get pods --all-namespaces

This command will list all running pods in every namespace.


 kubectl get pods

This command will show staus of running pods.


Create an Utho account to try this guide with a $100 credit.