Coder Social home page Coder Social logo

hardillb / multi-tenant-node-red-k8s Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 5.0 66 KB

A collection of parts to run a Multi Tenant Node-RED service on Kubernetes

Home Page: https://www.hardill.me.uk/wordpress/2020/12/27/multi-tenant-node-red-with-kubernetes/

License: Apache License 2.0

Dockerfile 2.08% JavaScript 93.19% Shell 4.73%
node-red kubernetes

multi-tenant-node-red-k8s's Introduction

Multi Tenant Node-RED Kubernetes

A collection of Containers and definition files that will implement a Multi Tenant Node-RED environment on Kubernetes.

Deprecated

This project is now deprecated, there will be no more updates and no support for anybody triyng to use it. If you are looking for a Multi Tenant Node-RED solution I suggest you look at FlowForge.

Download

$ git clone --recurse-submodules https://github.com/hardillb/multi-tenant-node-red-k8s.git

Pre-reqs

Creating secrets and setting domain

Running ./setup.sh in the root directory of the project will generate a deployment/registry-conf.yml file that holds the details for securing the registry and and the private container registry in settings.js for the management app.

The script takes 2 arguments

  • The first is the root domain that will be instance names will be appended to
  • The second is the host (and optional port) for the local container repository
$ ./setup.sh example.com private.example.com:5000

Build Containers

The Custom Node-RED, Management App and Catalogue containers need building and pushing to your local private container registry.

$ docker build -t private.example.com:5000/custom-node-red ./custom-node-red
...
$ docker push private.example.com:5000/custom-node-red

and

$ docker build -t private.example.com:5000/k8s-manager ./manager
...
$ docker push private.example.com:5000/k8s-manager

and

$ docker build -t private.example.com:5000/catalogue ./catalogue
...
$ docker push private.example.com:5000/catalogue

Regstiry Container

When running on a AMD64 based host everything should be fine, but if you want to run on ARM64 then you will need to rebuild the verdaccio/verdaccio container as they only ship AMD64 versions. You will then need to modify the deployment/deployment.yml by hand to point to the local build on your private container registry.

      - name: registry
        image: private.example.com:5000/verdaccio
        ports:
        - containerPort: 4873
        volumeMounts:
        - name: registry-data
          mountPath: /verdaccio/storage
        - name: registry-conf
          mountPath: /verdaccio/conf

Deploying

$ kubectl apply -f ./deployment

DNS

You will need to configure your DNS server to point a wildcard A/AAAA record at the Ingress IP address for your cluster.

To test you add entries for to the /etc/hosts file as follows:

192.168.1.100   manager.example.com  r1.example.com  r2.example.com

Where 192.168.1.100 is the IP address of the Ingress node.

Private Node Repository

npm

The npm repository is available on registry.example.com. You can publish new nodes to this repo under the scope of @private using the username admin and the password password

To add the scope to your local npm config run the following:

npm login --registry=http://registry.example.com --scope=@private

Once this is setup you can publish any package with the scope @private to that repository with the normal npm publish command

You can access the web front end for the repository on http://registry.example.com.

Catalogue

You can edit the catalogue.json file in the catalogue directory as required using the build-catalogue.js in the manager directory.

node build-catalogue.js registry.example.com [keyword filter] > ../catalogue/catalogue.json

Where the first argument is the hostname of the docker host and [keyword filter] (defaults to node-red) is the name of the keyword to filter the entries in the repository on.

multi-tenant-node-red-k8s's People

Contributors

hardillb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

multi-tenant-node-red-k8s's Issues

kubeconfig issue

Hi Ben!

First of all congrats, awesome work! I was trying to deploy the workloads in AWS EKS and found it was quite challenging. On the README file it says:

Running ./setup.sh in the root directory of the project will generate a deployment/secret.yml file that holds the details for connecting to the Kubernetes API and and the settings.js for the management app.

I ran the script but no secret.yml was generated. In the nodered-manager pod I get these error log:

internal/fs/utils.js:269
    throw err;
    

Error: ENOENT: no such file or directory, open '~/.kube/config'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at KubeConfig.loadFromFile (/usr/src/app/node_modules/@kubernetes/client-node/dist/config.js:65:32)
    at Object.<anonymous> (/usr/src/app/index.js:21:12)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '~/.kube/config'
}

Any help is much appreciated!

Best regards,

Mauricio

Manager issue: kubeconfig is not defined

Hi Ben, I have downloaded the code with the latest changes including the submodules as you indicated. This time the container node-red-manager is not starting cause kubeconfig is not defined. Here is the log:


k logs pod/node-red-multi-tenant-9b7488646-xmfzt node-red-manager
/usr/src/app/index.js:27
kubeconfig.loadFromCluster()
^

ReferenceError: kubeconfig is not defined
    at Object.<anonymous> (/usr/src/app/index.js:27:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47

Is the manager supposed to copy the .kube/config file from my local machine?

Thanks!

Mauricio

Manager: INFO pods is forbidden: User "system:serviceaccount:mt-nodered:create-pod" cannot create resource "pods" in API group "" in the namespace "default"

Ben,

App Manager is up but I get error 403 when trying to create a nodered pod:

`19:20:36.279 INFO App listening on 0.0.0.0:3000!
19:20:39.365 INFO Connected to the DB mongodb://mongo/nodered
181.116.218.63 - admin [28/Sep/2021:19:20:55 +0000] "GET /new.html HTTP/1.1" 200 2847 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"
181.116.218.63 - admin [28/Sep/2021:19:20:56 +0000] "GET /picnic.min.css HTTP/1.1" 200 39024 "https://manager.mt-nodered.slot1.io/new.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"
181.116.218.63 - admin [28/Sep/2021:19:20:59 +0000] "GET /style.css HTTP/1.1" 200 156 "https://manager.mt-nodered.slot1.io/new.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"
19:21:12.369 INFO pods is forbidden: User "system:serviceaccount:mt-nodered:create-pod" cannot create resource "pods" in API group "" in the namespace "default"
{"code":403,"statusCode":403}
Error: pods is forbidden: User "system:serviceaccount:mt-nodered:create-pod" cannot create resource "pods" in API group "" in the namespace "default"
at /usr/src/app/node_modules/kubernetes-client/backends/request/client.js:231:25
at Request._callback (/usr/src/app/node_modules/kubernetes-client/backends/request/client.js:168:14)
at Request.self.callback (/usr/src/app/node_modules/request/request.js:185:22)
at Request.emit (events.js:314:20)
at Request. (/usr/src/app/node_modules/request/request.js:1154:10)
at Request.emit (events.js:314:20)
at IncomingMessage. (/usr/src/app/node_modules/request/request.js:1076:12)
at Object.onceWrapper (events.js:420:28)
at IncomingMessage.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
181.116.218.63 - admin [28/Sep/2021:19:21:12 +0000] "POST /instance HTTP/1.1" 500 75 "https://manager.mt-nodered.slot1.io/new.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"
manager403

`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.