Creating an application

Creating an application from a template

To set up a basic Kubernetes application using an existing sample, use the Command Palette.

The Command Palette is accessible from the 'Manage' menu Manage icon (gear icon). Once the Command Palette has launched:

  • Type or select Cloud Code: New Application.
  • Select a template based on the language you'd like to use from the available options: NodeJS, Go, Python, Java.

    This example uses the 'Node.js: Guestbook' template.

  • Choose a preferred application location on your local machine.

  • On clicking enter, a simple two microservice Kubernetes application will be created (number of microservices created is dependent on the template you use).

    Creating a new application workflow

Template structure

All language template applications have nearly the same structure. This is not the only supported structure but is recommended when starting.

For the NodeJS Guestbook application, this is what the template structure looks like:

|---- .vscode
|      └---- launch.json
|---- kubernetes-manifests
|     |---- guestbook-backend.deployment.yaml
|     |---- guestbook-backend.service.yaml
|     |---- guestbook-frontend.deployment.yaml
|     |---- guestbook-frontend.service.yaml
|     |---- mongo.deployment.yaml
|     └---- mongo.service.yaml
|---- src
|     |---- backend
|     |     |---- Dockerfile
|     |     |---- index.js
|     |     |---- app.js
|     |     └---- package.json
|     |---- frontend
|           |---- Dockerfile
|           |---- index.js
|     |     |---- app.js
|           └---- package.json
└---- skaffold.yaml

Taking a closer look at the Guestbook Node.js sample app, here are some key files and their respective uses:

  • .vscode
    • extensions.json: prompt requesting download of related extensions when opening this project
    • launch.json: run and debug configuration information
    • tasks.json: configuration information for Visual Studio Code Tasks
  • kubernetes-manifests
    • guestbook-backend.deployment.yaml: Pod specification for the backend nodes
    • guestbook-frontend.deployment.yaml: Pod specification for the frontend nodes
    • mongo.deployment.yaml: Pod specification for the database
  • src
    • (backend|frontend)/app.js: Node.js code with the web server logic
    • (backend|frontend)/Dockerfile: used to build the container image for our program
  • skaffold.yaml: config file for Skaffold, which is used by Cloud Code to build and run images

Using your own application

If you'd like to use a project of your own, you'll need to set up your run and debug configurations. Refer to this guide on setting up your application.

Getting Support

To send feedback, report issues on GitHub, or ask a question on Stack Overflow.