-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from komminarlabs/tk/node-red
added node-red pack
- Loading branch information
Showing
9 changed files
with
228 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 0.1.0 | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Node-RED | ||
|
||
This pack uses Docker driver to deploy Node-RED in Nomad. | ||
|
||
## Variables | ||
|
||
- `docker_env_vars` (map of string) - Environment variables to pass to Docker container. | ||
- `node_pool` (string) - The node_pool where the job should be placed. | ||
- `nodered_task_resources` (object) - The resource to assign to the Node-RED service task. | ||
- `constraints` (list of object) - Constraints to apply to the entire job. | ||
- `data_volume` (object) - The dedicated data volume you want Node-RED to use. | ||
- `namespace` (string) - The namespace where the job should be placed. | ||
- `nodered_version_tag` (string) - The docker image version. | ||
- `region` (string) - The region where the job should be placed. | ||
- `consul_service` (object) - The consul service for Node-RED. | ||
- `datacenters` (list of string) - A list of datacenters in the region which are eligible for task placement. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
app { | ||
url = "https://nodered.org/" | ||
author = "Node-RED" | ||
} | ||
|
||
pack { | ||
name = "node-red" | ||
description = "Low-code programming for event-driven applications." | ||
url = "https://github.com/komminarlabs/nomad-pack-registry/node-red" | ||
version = "0.1.0" | ||
} | ||
|
||
integration { | ||
identifier = "nomad/komminarlabs/node-red" | ||
name = "Node-RED" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Congrats on deploying [[ meta "pack.name" . ]]. | ||
|
||
There are [[ var "app_count" . ]] instances of your job now running on Nomad. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
data_volume = { | ||
name = "nodered_data_volume" | ||
type = "host" | ||
} | ||
|
||
docker_env_vars = { | ||
"NODE_VERSION" : "20", | ||
"NODE_RED_VERSION" : "4.0.2", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
job "node-red" { | ||
region = "[[ var "region" . ]]" | ||
datacenters = [[ (var "datacenters" .) | toStringList ]] | ||
node_pool = "[[ var "node_pool" . ]]" | ||
type = "service" | ||
[[- if var "namespace" . ]] | ||
namespace = "[[ var "namespace" . ]]" | ||
[[- end ]] | ||
[[- if var "constraints" . ]][[ range $idx, $constraint := var "constraints" . ]] | ||
constraint { | ||
[[- if ne $constraint.attribute "" ]] | ||
attribute = "[[ $constraint.attribute ]]" | ||
[[- end ]] | ||
[[- if ne $constraint.value "" ]] | ||
value = "[[ $constraint.value ]]" | ||
[[- end ]] | ||
[[- if ne $constraint.operator "" ]] | ||
operator = "[[ $constraint.operator ]]" | ||
[[- end ]] | ||
} | ||
[[- end ]] | ||
[[- end ]] | ||
|
||
group "node-red" { | ||
count = 1 | ||
network { | ||
port "http" { | ||
static = 1880 | ||
} | ||
} | ||
|
||
[[- if var "consul_service.register" . ]] | ||
|
||
service { | ||
name = "[[ var "consul_service.name" . ]]" | ||
[[- if ne (len (var "consul_service.tags" .)) 0 ]] | ||
tags = [[ (var "consul_service.tags" .) | toStringList ]] | ||
[[- end ]] | ||
port = "http" | ||
check { | ||
name = "alive" | ||
type = "tcp" | ||
interval = "10s" | ||
timeout = "2s" | ||
} | ||
} | ||
[[- end ]] | ||
|
||
[[- if var "data_volume" . ]] | ||
volume "[[ var "data_volume.name" . ]]" { | ||
type = "[[ var "data_volume.type" . ]]" | ||
read_only = false | ||
source = "[[ var "data_volume.name" . ]]" | ||
} | ||
[[- end ]] | ||
|
||
task "node-red" { | ||
driver = "docker" | ||
[[- if var "data_volume" . ]] | ||
volume_mount { | ||
volume = "[[ var "data_volume.name" . ]]" | ||
destination = "/data" | ||
read_only = false | ||
} | ||
[[- end ]] | ||
|
||
config { | ||
image = "nodered/node-red:[[ var "nodered_version_tag" . ]]" | ||
ports = ["http"] | ||
} | ||
|
||
resources { | ||
cpu = [[ var "nodered_task_resources.cpu" . ]] | ||
memory = [[ var "nodered_task_resources.memory" . ]] | ||
} | ||
|
||
[[- if ne (len (var "docker_env_vars" .)) 0 ]] | ||
|
||
env { | ||
[[- range $key, $var := var "docker_env_vars" . ]] | ||
[[if ne (len $var) 0 ]][[ $key | upper ]] = [[ $var | quote ]][[ end ]] | ||
[[- end ]] | ||
} | ||
[[- end ]] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
variable "constraints" { | ||
description = "Constraints to apply to the entire job." | ||
type = list(object({ | ||
attribute = string | ||
operator = string | ||
value = string | ||
})) | ||
default = [ | ||
{ | ||
attribute = "$${attr.kernel.name}", | ||
value = "(linux|darwin)", | ||
operator = "regexp", | ||
}, | ||
] | ||
} | ||
|
||
variable "consul_service" { | ||
description = "The consul service for Node-RED." | ||
type = object({ | ||
name = string | ||
register = bool | ||
tags = list(string) | ||
}) | ||
default = { | ||
name = "nodered", | ||
register = true, | ||
tags = [], | ||
} | ||
} | ||
|
||
variable "data_volume" { | ||
description = "The dedicated data volume you want Node-RED to use." | ||
type = object({ | ||
type = string | ||
source = string | ||
}) | ||
} | ||
|
||
variable "datacenters" { | ||
description = "A list of datacenters in the region which are eligible for task placement." | ||
type = list(string) | ||
default = ["dc1"] | ||
} | ||
|
||
variable "docker_env_vars" { | ||
type = map(string) | ||
description = "Environment variables to pass to Docker container." | ||
default = {} | ||
} | ||
|
||
variable "namespace" { | ||
description = "The namespace where the job should be placed." | ||
type = string | ||
default = "default" | ||
} | ||
|
||
variable "node_pool" { | ||
description = "The node_pool where the job should be placed." | ||
type = string | ||
default = "default" | ||
} | ||
|
||
variable "nodered_task_resources" { | ||
description = "The resource to assign to the Node-RED service task." | ||
type = object({ | ||
cpu = number | ||
memory = number | ||
}) | ||
default = { | ||
cpu = 500, | ||
memory = 256, | ||
} | ||
} | ||
|
||
variable "nodered_version_tag" { | ||
description = "The docker image version." | ||
type = string | ||
default = "4.0.2-22" | ||
} | ||
|
||
variable "region" { | ||
description = "The region where the job should be placed." | ||
type = string | ||
default = "global" | ||
} |