Cloud Code lets you create a Kubernetes application based on a sample or from an existing project.
Creating an application from a sample application
Cloud Code comes with a collection of samples to get you started quickly. To create a Kubernetes application using an existing sample, follow these steps:
- Click
Cloud Code in the status bar and then select the New Application command.
- Select Kubernetes application for the type of sample.
- Select a sample based on the language you'd like to use from the available options: NodeJS, Go, Python, Java.
Choose a preferred application location on your local machine and then press
Enter
.Cloud Code clones the sample you chose and opens your new project for use.
Sample application structure
All language sample applications have nearly the same structure. This is not the only supported structure but is recommended when starting.
For example, the Node.js Guestbook application 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 this Kubernetes Guestbook Node.js sample app, here are some key files and their uses:
- .vscode
extensions.json
: prompt requesting download of related extensions when opening this projectlaunch.json
: launch configuration (of typecloudcode.kubernetes
) to run or debug the Kubernetes applicationtasks.json
: configuration information for Visual Studio Code Tasks
- kubernetes-manifests
guestbook-backend.deployment.yaml
: Pod specification for the backend nodesguestbook-frontend.deployment.yaml
: Pod specification for the frontend nodesmongo.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 Cloud Code uses to build, deploy and debug Kubernetes applications
Using your own application
For steps to use an existing project, see setting up your application.