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
iwonahahnIwona HahnOctober 17, 2022
Created by
iwonahahn
July 5, 2022
Contributors
iwonahahn
manjuX
manjuX

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 your package.json is using @sap/cds 6.0.1 or newer and you have @sap/cds-dk 6.0.1 or newer globally installed.

    Run the following commands in your project directory:

    1. npm install to install your local package.

    2. cds version to check the globally installed @sap/cds-dk version and your locally installed @sap/cds version.

    To upgrade, run the following commands in your project directory:

    • npm install @sap/cds@>=6
    • npm install -g @sap/cds-dk@>=6
  • Step 2
  • Step 3
  • 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.

    === “Windows”

    There are two additional steps for Windows users only:
    
    3. Go to `C:\ProgramData\chocolatey\bin`.
    
    4. Rename `kubelogin.exe` to `kubectl-oidc_login.exe`.
    
  • 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.

  • 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
      cat ~/.docker/config.json
      ```
      
    4. Check if the secret was successfully created:

      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`?

  • Step 7
  • Step 8
  • Step 9
Back to top