Kubeconfig

 

kubeconfig

 

At User Tab, select Projects. Click Kubeconfigs button Screenshot from 2022-11-29 12-48-30

To access your cluster and virtual machines, you must add a SSH key to your Access Profile. It'll give the user total access to Kubemaster of the cluster from attached Projects.

You can read more about Access Profiles here

Using Kubeconfig, you can allow users to access your cluster, but not servers. It means Kubeconfig is a yalm file that contains relevant infos to authenticate cluster and allow the use of its resources, keeping servers protection.

Create a new Kubeconfig

  • Click Add Kubeconfig in the upper right Screenshot from 2022-11-29 13-24-30

  • Choose a Name: use at least 3 lowercase alphanumeric characters

  • Choose a Namespace: isolated group located within the cluster
  • Choose a Role: you can choose between admin/edit/view
  • Select a Predefined Validity Period: choose a period the kubeconfig will expire
  • Select a Kubeconfig Type
    • Personal Kubeconfig: only selected User is allowed
    • Application Kubeconfig: choose if only project Managers are allowed, or all users with access to the project
  • You can find a specific Kubeconfig using the Search Tab Screenshot from 2022-11-29 13-42-23

At the Actions Tab, you can:

Screen Shot 2022-11-03 at 12.18.35 Download Kubeconfig

Screenshot from 2022-11-15 13-19-48Delete 

How to use Kubeconfig

The Kubeconfig file is used with the Kubectl command-line tool to access the cluster. 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 operation system here5-1

See a list of kubectl commands here

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