Skip to content

Commit 1a6650b

Browse files
committed
Added nodejs example
1 parent 0209345 commit 1a6650b

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-2
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ kubectl (Kubernetes CLI) plugin to syncronize local files to _Pod_ and executing
55
This can be used for example to build and run your local project in Kubernetes while using your prefed editor locally.
66

77
## Install
8-
## MacOS with Brew
8+
### MacOS with Brew
99
```shell
1010
brew install ernoaapa/kubectl-plugins/warp
1111
```
12-
## Linux / MacOS without Brew
12+
### Linux / MacOS without Brew
1313
1. Download binary from [releases](https://github.com/ernoaapa/kubectl-warp/releases)
1414
2. Add it to your `PATH`
1515

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

22+
### Examples
23+
There's some examples with different languages in [examples directory](examples/)
24+
2225
## Development
2326
### Prerequisites
2427
- Golang v1.11

examples/nodejs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

examples/nodejs/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# kubectl warp NodeJS example
2+
This is an example of using `kubectl warp` for developing NodeJS app "real-time" in Kubernetes cluster.
3+
4+
`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.
5+
6+
## Prerequisites
7+
- Install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
8+
- Install [kubectl warp](https://github.com/ernoaapa/kubectl-warp#install)
9+
10+
Here we
11+
1. start official `node` Docker image in Kubernetes
12+
2. sync current directory to the container
13+
3. run `npm install`
14+
4. start watching changes with `npm run watch` command
15+
16+
```shell
17+
kubectl warp -i -t --image node nodejs-example -- npm install && npm run watch
18+
```

examples/nodejs/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
var startTime = new Date();
3+
4+
setInterval(function () {
5+
console.log('Hello world! (started at ' + startTime.toISOString() + ')')
6+
}, 1000);

examples/nodejs/package.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "kubectl-warp-example",
3+
"version": "1.0.0",
4+
"description": "Example NodeJS project for demostrating kubectl warp command",
5+
"main": "index.js",
6+
"scripts": {
7+
"start": "node index.js",
8+
"watch": "nodemon index.js",
9+
"test": "echo \"Error: no test specified\" && exit 1"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/ernoaapa/kubectl-warp.git"
14+
},
15+
"keywords": [
16+
"kubernetes",
17+
"kubectl",
18+
"warp",
19+
"rsync"
20+
],
21+
"author": "Erno Aapa <[email protected]>",
22+
"license": "MIT",
23+
"bugs": {
24+
"url": "https://github.com/ernoaapa/kubectl-warp/issues"
25+
},
26+
"homepage": "https://github.com/ernoaapa/kubectl-warp#readme",
27+
"dependencies": {
28+
"nodemon": "^1.18.9"
29+
}
30+
}

0 commit comments

Comments
 (0)