Skip to Content

Enable SAP BTP, Kyma Runtime Using the Command Line

Enabling SAP BTP, Kyma Runtime means creating a Kyma environment instance, i.e. a Kyma cluster. You can then use the Kyma cluster to build applications and extensions to SAP and third-party solutions, manage roles, have your Kubernetes objects backed up, and view metrics and logs.
You will learn
  • How to set up a Kyma cluster in a subaccount on SAP BTP, without using the SAP BTP cockpit (see Enable SAP BTP, Kyma Runtime for the same procedure in the cockpit).
  • That the creation of the Kyma cluster takes about 15 - 25 minutes. It happens after step 3 in this tutorial, so you might want to plan in a coffee break before continuing with step 4.
Anna WengerJanuary 25, 2023
Created by
August 11, 2022


  • Step 1
    1. Log in to your global account. We recommend using:

      btp login --sso

    2. Since you’ll be working in a subaccount, run:

      btp list accounts/subaccount
    3. Copy the ID of the subaccount in which you want to set up the Kyma cluster to your clipboard.

    4. Set the target to that subaccount with:

      btp target --subaccount <subaccount ID from your clipboard>

    Once the target is set to the subaccount, you no longer need to specify the subaccount ID with every command.

  • Step 2

    To check if Kyma is already entitled to your subaccount, use the following command:

    btp list accounts/entitlements

    If you don’t have a Kyma entitlement yet, run the following command – note that you need to have admin rights in the global account for managing entitlements, and that you do need the subaccount ID one last time in this case (luckily, it should still be in your clipboard):

    btp assign accounts/entitlement --to-subaccount <subaccount ID from your clipboard> --for-service kymaruntime --plan free --amount 1  

    If you’re not working in a free tier subaccount, see Available Plans in the Kyma Environment.

    You can append --help to the end of complete or incomplete commands. For example, btp accounts/subaccounts --help can help you to find the correct command to get details about a subaccount.

  • Step 3

    To create a Kyma environment instance (the Kyma cluster), you need to pass a .json file as a parameter that contains attributes of the Kyma cluster.

    If you’re using a different plan, you might need a different region. See the Subaccount Regions section in Regions for the Kyma Environment

    1. Create a .json file in a directory of your choice with the following content: {"name": "my-kyma-cluster", "region": "eu-west-2"}

    2. Run the following command to create the Kyma cluster:

      btp create accounts/environment-instance --display-name my-environment-instance --environment kyma --service kymaruntime --plan free --parameters <FULL-PATH-TO-JSON-FILE>

    A new Kubernetes cluster is set up, in which the Kyma runtime and all its components will run.

    To continue with this tutorial, the Kyma cluster needs to be created, but this happens in the background and may take 15‒30 minutes. You can check the status with btp list accounts/environment-instance ‒ once Kyma appears with status OK, you can continue.

  • Step 4

    Once you’ve created the environment instance, you need to get its configuration file: the kubeconfig.yaml, because kubectl relies on the kubeconfig.yaml to configure access to the Kyma cluster.

    To do so, retrieve the environment id and the KubeconfigURL from the newly created environment instance. Note that downloading the kubeconfig.yaml may succeed even if the cluster creation has not succeeded yet. But in this case, the content would be unusable. So make sure that the Kyma environment instance is in status OK after the previous step.

    1. To get your environment id, enter:

      btp list accounts/environment-instance

    2. Copy the environment ID of your new Kyma environment instance to your clipboard for use in the next command.

    3. To retrieve the KubeconfigURL, enter:

      btp get accounts/environment-instance <ENVIRONMENT-ID>

      Tip: If you prefer JSON output, use btp --format json get accounts/environment-instance <ENVIRONMENT_ID> --subaccount <ID>

    4. Copy the KubeconfigURL.

    5. To download the kubeconfig.yaml file and save it to your user directory, enter:

    in PowerShell 5.1 (Windows):

    curl<EnvironmentID> -OutFile <file-path>\kubeconfig.yaml

    in PowerShell 7.x (Windows, Mac, Linux):

    curl<EnvironmentID> > <file-path>\kubeconfig.yaml

    in macOS and Linux:

    curl -o kubeconfig.yaml<ENVIRONMENT-ID>
  • Step 5

    For your convenience, expose the kubeconfig as an environment variable or add the location of kubeconfig.yaml to your path in the system variables. The environment variable is session-based, whereas the path is saved permanently.

    To only use a session-based environment variable, enter:

  • Step 6

    If you’ve created the cluster, you’re automatically assigned the cluster-admin role. This role gives you unrestricted access to configure your cluster. For example, you can assign roles to other users.

    To check if you can access your cluster, run:

    kubectl get namespaces

    You get a token which will also be valid for future sessions.

    To learn more about the Kyma environment and its functionality, see:

Back to top