After completing this lesson, you will be able to set up and configure kubectl for Kyma
Setting and Configuring Kubectl for Kyma
Accessing Your Kyma Runtime Instance Using Kubectl
You have successfully created a Kyma runtime instance. Now, you want to interact with your Kyma runtime instance and learn how to use the kubectl CLI to manage your resources. But first, you need to know how to set up the kubectl command line interface (CLI) to connect to your Kyma runtime instance, especially because Kyma runtime requires a special plugin of kubectl for the authentication process.
Set up and configure kubectl for Kyma
In this exercise, you will perform the following steps:
Install the kubectl CLI.
Install the kubelogin plugin.
Configure the kubectl CLI to connect to your Kyma runtime instance.
Interact with your Kyma runtime instance using kubectl.
Prerequisites
You have successfully created a Kyma runtime instance in the SAP BTP subaccount.
To verify that the kubelogin plugin is installed correctly, execute the following command in your terminal or command line:
Code Snippet
1
kubectl version --client
If the installation was successful, you should see the client and kubelogin plugin versions as an output.
Connect to your Kyma runtime instance.
As already mentioned, the kubectl relies on the kubeconfig file, which is typically located in the ~/.kube directory (macOS/Linux) or %USERPROFILE%\.kube (Windows).
Go to your SAP BTP subaccount overview page.
Select the link for the KubeconfigURL to download the kubeconfig.yaml file for your Kyma runtime instance.
In the terminal, export the location of your kubeconfig file as an environment variable.
For MacOS/Linux:
Code Snippet
1
export KUBECONFIG={KUBECONFIG_FILE_PATH}
For Windows:
Code Snippet
1
$ENV:KUBECONFIG="{KUBECONFIG_FILE_PATH}"
Note
The kubeconfig file contains the credentials for accessing your Kyma runtime instance. Therefore, it is important to keep it secure.
To verify that the kubeconfig file is configured correctly, execute the following command in your terminal or command line:
Code Snippet
1
kubectl cluster-info
If the configuration was successful, you should see the following output:
Interact with your Kyma runtime instance.
It's now time to use some of the kubectl commands to interact with your Kyma runtime instance.
Execute the following command to get a list of all available resources in your Kyma runtime instance:
Code Snippet
1
kubectl get all --all-namespaces
Get a list of your nodes in your Kyma runtime instance:
Code Snippet
1
kubectl get nodes
Get a list of your Pods in your Kyma runtime instance:
Code Snippet
1
kubectl get pods --all-namespaces
Get a list of your Deployments in the namespace kyma-system:
Get a list of all namespaces in your Kyma runtime instance:
Code Snippet
1
kubectl get namespaces
Delete the namespace you created:
Code Snippet
1
kubectl delete namespace my-namespace
Result
You have successfully installed the kubectl CLI and configured it to connect to your Kyma runtime instance. You can use the basic kubectl commands to interact with it.