Setting up an existing application

If you choose to use your own existing applications, you'll need to open the folder in VS Code before setting up two essential components, your run and debug configurations.

Setting up run configuration

To run an app on Kubernetes, you'll need a run configuration (in .vscode/launch.json) to help build and deploy your application. If your existing project doesn't have a run configuration, you'll be guided to create one when you run the 'Run on Kubernetes' command.

  1. Select 'Run on Kubernetes' from the Cloud Code status bar.

    Choosing Run on Kubernetes from the Cloud Code status bar

  2. Select 'Add Configuration' when Cloud Code recognizes no available configurations.

    Dialog asking whether you'd like to add a configuration

  3. This launches the Artifact Input Wizard.

    For each image to be built, you can select a corresponding Dockerfile from the dropdown list. If there are multiple Dockerfiles in the project, they'll all be displayed in this list.

    Screenshot of Artifact Input Wizard with Dockerfile specified for the available image

  4. Once you click 'Save', you can continue with running the app, using the newly added run configuration (in .vscode/launch.json) and skaffold.yaml.

  5. Confirm whether you'd like to use the current cluster context (or switch to a preferred one).

  6. Depending on the context chosen, you may be prompted to choose an image registry.

  7. An output window will appear where you can track the progress of your running application. You'll also see a live stream of the logs from the running pods within the terminal output.

    Screenshot of dialog notifying successful configuration addition and file tree with added skaffold.yaml and launch.json

For a detailed walkthrough and more customization options, refer to running an application.

Setting up debugging

If your existing project doesn't have an existing launch.json in its .vscode folder for debugging, you can add one using the Debug panel.

  1. Navigate to the Debug panel (using the Debug view icon Debug icon from the left taskbar) and select 'Add Configuration' from the dropdown menu.

    Adding configuration using the debug panel

  2. Select 'Cloud Code Debug' as the environment.

    Setting Cloud Code Debug as the environment

  3. Select the corresponding programming language.

    Selecting a preferred programming language

  4. This will create and open a launch.json file for your project. You can now update configuration attributes in this file to match those of your project. For more information on configuration attributes, refer to this table.

    Configuration attributes displayed in an open launch.json file