taikun.cloud

Taikun Help Center

Kubeconfig

In simple terms, kubeconfig is a configuration file used by Kubernetes to connect to a cluster. It contains information such as the location of the cluster, authentication details, and other settings that enable a user to interact with the cluster using command-line tools. Using Kubeconfig, you can allow users to access your cluster, but not servers. It means Kubeconfig is a yaml file that contains relevant info to authenticate cluster and will enable the use of its resources, keeping servers protected.

YAML is a human-readable data serialization format. In simpler terms, it’s a way to represent data in a text format that’s easy for humans to read and write while still being accessible for computers to parse and understand. YAML files typically use a hierarchical structure based on indentation, key-value pairs, and lists.

One of the features of Taikun is the ability to easily download your kubeconfig file. All you need to do is access the Projects tab and then navigate to your Project. You can select “Add Kubeconfig” from there and save the file to your local machine. And if you’re specifically looking for information when creating a Kubeconfig, the Official Documentation also has you covered there.

How to add a Kubeconfig in Taikun

How to use Kubeconfig

The kubeconfig file is used with the Kubectl command-line tool to access the cluster. When you run kubectl commands, it reads the kubeconfig file to know which cluster to connect to and how to authenticate with that cluster. This allows you to manage multiple Kubernetes clusters from a single command-line tool by switching between different kubeconfig files.

You can download Kubectl:

  • Using curl command-line tool, for example downloading the version 1.25.0:

curl https://dl.k8s.io/release/v1.25.0/bin/linux/amd64/kubectl

The command makes a HTTP request, opening the URL in the Terminal. 

  • Using the native package management, with apt install command-line to access the Repository.

apt install kubectl

Note: you should choose kubectl version according to your cluster’s version. 

You can read more about downloading Kubectl according to operating system.

Now, you have to download the Kubeconfig file Screen Shot 2022-11-03 at 12.18.35. You have different ways to access Kubeconfig in your Terminal:

  •  Using –kubeconfig parameter in command line, directly referencing the location of the Kubeconfig file. Ex:

get pods --kubeconfig/home/Documents/kubeconfig.yaml

The parameter must be used in every command line to specify the kubeconfig file.

  • Adding a value to variable kubeconfig, using export parameter. You must indicate the location of the file. Ex:


export KUBECONFIG=/home/Documents/kubeconfig.yaml

To make sure the value was added, you can use the echo command to show up the current kubeconfig value:


echo $KUBECONFIG
  • Creating the config file for authentication.

Be sure you are in in home directory. 


/home/your_user

Create a new folder kube.


mkdir ~/.kube

Now, you must create the config file inside the kube folder. Its must contains all the content from the Kubeconfig file:


vim /.kube/config








See the list of kubectl commands. Here are a few basic kubectl commands to get you started:


kubectl get pods

Show you a list of all the pods running in your cluster.


kubectl describe pod <pod-name>

This command will give you more detailed information about a specific pod, including its status and any events or issues.


kubectl create deployment <deployment-name> --image=<container-image>

Create a new deployment using the specified container image.


kubectl scale deployment <deployment-name> --replicas=<number-of-replicas>

Scale the specified deployment to the specified number of replicas.


kubectl logs <pod-name>

Show the logs for a specific pod.


kubectl exec -it <pod-name> -- /bin/bash

Open a terminal session inside a running pod.