Cloud Code lets you create a Kubernetes application based on a sample or from an existing project.
Creating an application from a template
Cloud Code comes with a collection of starter templates to get you started quickly. To create a Kubernetes application using an existing sample, follow these steps:
- Choose the New Application command using the Cloud Code status bar.
Kubernetes applicationfor the type of sample.
- Select a template 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
Cloud Code clones the sample you chose and opens your newly created project for use.
All language template 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:
- extensions.json: prompt requesting download of related extensions when opening this project
- launch.json: launch configuration (of type 'cloudcode.kubernetes') to run or debug the Kubernetes application
- tasks.json: configuration information for Visual Studio Code Tasks
- 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
- (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, deploy and debug Kubernetes applications
Using your own application
If you'd like to use a project of your own, refer to this guide on setting up your application.