Skip to Content

Prepare Your Kyma Development Environment

This tutorial shows you how to install tools used in this tutorial, log in to your Kyma cluster, create a namespace for your app, and create a container registry secret.
You will learn
  • How to prepare your Kyma development environment
manjuXManju ShankarMarch 14, 2023

Prerequisites

  • Prepare for SAP BTP Development
  • For Windows, you’ll need Chocolatey. This is a package manager that will speed up and ease installation of the tools in this tutorial. See how to install Chocolatey in Setup/Install.
  • You have prepared a container registry and you’ve logged in to the container registry through your CLI. A container registry is a repo where you can push your docker images. SAP BTP doesn’t currently provide a container registry. You can use any container registry offering as long as it can be reached from public Internet.
  • Step 1

    To earn your badge for the whole mission, you will need to mark all steps in a tutorial as done, including any optional ones that you may have skipped because they are not relevant for you.

    Make sure you’re using the latest CAP tooling version.

    Delete any outdated package-lock.json files in your project directory and run the following commands:

    1. npm install --global @sap/cds-dk to install globally the latest @sap/cds-dk version.

    2. npm install to install your local package.

    3. cds version to double check that the globally installed @sap/cds-dk version and your locally installed @sap/cds version match.

    Log in to complete tutorial
  • Step 2
    Log in to complete tutorial
  • Step 3
    Log in to complete tutorial
  • Step 4
    1. Choose KubeconfigURL under the Kyma Environment tab in your subaccount.

      Kubeconfig URL

      A file kubeconfig.yaml is downloaded.

      Kubeconfig yaml
    2. Copy the kubeconfig.yaml file to the ~/.kube/ directory and rename it to config. Replace or rename any existing file with the same name.

    You can also move and rename the kubeconfig.yaml file from the CLI.

    1. Rename or remove any existing file named config from the ~/.kube/ directory.

    2. Run the following commands:

      KUBECONFIG="$HOME/.kube/config:$HOME/Downloads/kubeconfig.yaml" kubectl config view --raw >$HOME/.kube/config-new
      mv $HOME/.kube/config-new $HOME/.kube/config
      chmod 600 $HOME/.kube/config
      

      In case you experience problems running the commands, check Step 2: Command Line Interpreters from Set Up Local Development Using VS Code for more details on recommended CLIs.

    There are two additional steps for Windows users only:

    1. Go to C:\ProgramData\chocolatey\bin.

    2. Rename kubelogin.exe to kubectl-oidc_login.exe.

    Log in to complete tutorial
  • Step 5
    1. Run the following command to create a namespace risk-management:

      Shell/Bash
      Copy
      kubectl create namespace risk-management
      

      You should get a message namespace/risk-management created.

    2. Switch context to the namespace:

      Shell/Bash
      Copy
      kubectl config set-context --current --namespace risk-management
      

      You should get a message Context "shoot--kyma--X-XXXXXXX" modified.

    Log in to complete tutorial
  • Step 6

    You need the container registry secret to access docker container images in your registry from your Kyma cluster.

    Kubernetes has a special type of secret for container registries and its kubectl command line supports it with the required options:

    Shell/Bash
    Copy
    kubectl create secret docker-registry container-registry \
            "--docker-server=..." \
            "--docker-username=..." \
            "--docker-email=..." \
            "--docker-password=..."
    
    1. Copy the folder scripts from templates/Kyma-Prepare-Dev-Environment to your project directory.

    2. Run the script to create the secret. In your project directory, execute:

      Shell/Bash
      Copy
      ./scripts/create-container-registry-secret.sh
      

      Running this script will prompt you for the required inputs. By using the script, you avoid storing your password in your command line interpreter’s history.

      Can’t run the kubectl create secret docker-registry container-registry \ command?

      If you encounter any errors running this command, make sure you are using the Git BASH command line interpreter, as advised in Step 2: Command Line Interpreters in this tutorial.

    3. When prompted, provide the required details.

      • Docker Server - Use the full qualified hostname for the docker server.
      • User and Email - provide your username and e-mail that you used to create your container registry.
      • API Key - as part of the authentication settings of your container registry, you should be able to generate an API key and provide it here.

      Looking for your docker server URL?

      The docker server URL is the path used for docker login, so you can quickly check it by running the following command in your terminal:

      json
      Copy
      cat ~/.docker/config.json
      
    4. Check if the secret was successfully created:

      Shell/Bash
      Copy
      kubectl get secret
      

      You should be able to see the newly created secret.

      New Secret

    What is the command for creating a Kubernetes namespace with name `my-namespace`?

    Log in to complete tutorial
  • Step 7
    Log in to complete tutorial
  • Step 8
    Log in to complete tutorial
  • Step 9
    Log in to complete tutorial
Back to top