Skip to content

Commit

Permalink
Added nodejs example
Browse files Browse the repository at this point in the history
  • Loading branch information
ernoaapa committed Dec 29, 2018
1 parent 0209345 commit 1a6650b
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ kubectl (Kubernetes CLI) plugin to syncronize local files to _Pod_ and executing
This can be used for example to build and run your local project in Kubernetes while using your prefed editor locally.

## Install
## MacOS with Brew
### MacOS with Brew
```shell
brew install ernoaapa/kubectl-plugins/warp
```
## Linux / MacOS without Brew
### Linux / MacOS without Brew
1. Download binary from [releases](https://github.com/ernoaapa/kubectl-warp/releases)
2. Add it to your `PATH`

Expand All @@ -19,6 +19,9 @@ When the plugin binary is found from `PATH` you can just execute it through `kub
kubectl warp --help
```

### Examples
There's some examples with different languages in [examples directory](examples/)

## Development
### Prerequisites
- Golang v1.11
Expand Down
1 change: 1 addition & 0 deletions examples/nodejs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
18 changes: 18 additions & 0 deletions examples/nodejs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# kubectl warp NodeJS example
This is an example of using `kubectl warp` for developing NodeJS app "real-time" in Kubernetes cluster.

`kubectl warp` start temporary _Pod_ and keep your local files insync so that you can make changes to files locally, but run the actual code in the Kubernetes cluster.

## Prerequisites
- Install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
- Install [kubectl warp](https://github.com/ernoaapa/kubectl-warp#install)

Here we
1. start official `node` Docker image in Kubernetes
2. sync current directory to the container
3. run `npm install`
4. start watching changes with `npm run watch` command

```shell
kubectl warp -i -t --image node nodejs-example -- npm install && npm run watch
```
6 changes: 6 additions & 0 deletions examples/nodejs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

var startTime = new Date();

setInterval(function () {
console.log('Hello world! (started at ' + startTime.toISOString() + ')')
}, 1000);
30 changes: 30 additions & 0 deletions examples/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "kubectl-warp-example",
"version": "1.0.0",
"description": "Example NodeJS project for demostrating kubectl warp command",
"main": "index.js",
"scripts": {
"start": "node index.js",
"watch": "nodemon index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ernoaapa/kubectl-warp.git"
},
"keywords": [
"kubernetes",
"kubectl",
"warp",
"rsync"
],
"author": "Erno Aapa <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/ernoaapa/kubectl-warp/issues"
},
"homepage": "https://github.com/ernoaapa/kubectl-warp#readme",
"dependencies": {
"nodemon": "^1.18.9"
}
}

0 comments on commit 1a6650b

Please sign in to comment.