Comments (6)
Yepp @hinrichd, thats what we got asked here too: #149
The issue is, I am not sure if this project should take the semi-ownership of the https://github.com/kiwigrid/k8s-sidecar project.
Maybe worth to file a feature-request there and ask to add curl
and jq
to the base image?
from node-red-chart.
Hey @dirien
I have opened a ticket in the k8s-sidecar project .
Let´s see what they can do.
from node-red-chart.
@hinrichd many thanks for the contribution!
from node-red-chart.
awesome @hinrichd! Let's see what the answer is!
from node-red-chart.
Hi @dirien,
here is the answer for the sidecar project...
Adding more binaries to the image does not really match the philosophy of the project having a minimal image and hence minimal attack surface.
But we're building upon a generic python image and already do have the python requests package installed. So I think it should be possible to use python instead of separate binaries to perform the requests and parse JSON responses.
I totally agree with this comment. To fit best into the sidecar the flowrefresh script should be using python and the request package/module as dependency.
I am only the mac and bash guy and not python. Will have a look at psf requests in some days, it says it is for humans...
✌️
from node-red-chart.
UPDATE: Now, there is a new version of the k8s-sidecar release called 1.24.0. In this version the SCRIPT
Environment Variable will execute python scripts as well by respecting the script´s shebang. Before, the script was directly called by sh command and you had to run python from within the script as subprocess. This has some downsides to stdin/out. See this FR related to the original issue.
Meanwhile I rewrite the flow_refresh.sh
script to flow_refresh.py
due to dependencies of the python based image.
Executing manually the flow_refresh.py
with .\flow_refresh.py
inside the sidecar will reload the node-red flows:
--> Script Output from Sidecar Container
/tmp $ hostname
node-red-54d6679cb-m9qfr
/tmp $ vi flow_refresh.py
/tmp $ chmod 755 flow_refresh.py
/tmp $ ./flow_refresh.py
node-red flow refresh api via k8s-sidecar
Sidecar sleeping for 5 seconds...
node-red flow refresh api response code = 200
--> Node-Red Log Output
8 May 12:47:30 - [warn] Verschlüsselte Credentials nicht gefunden
8 May 12:47:30 - [info] Flows werden gestoppt
8 May 12:47:30 - [info] Flows sind gestoppt
8 May 12:47:30 - [info] Flows werden gestartet
8 May 12:47:30 - [info] Flows sind gestartet
flow_refresh.py
- Default Chart
SLEEP_TIME_SIDECAR
must be integer not string (5s) - retry and retry delay not supported
- flow_refresh.py has to be executable, otherwise it will be executed be sh an will fail.
#!/usr/bin/env python
import time
import os
import requests
import json
import sys
# SET VARIABLES FROM CONTAINER ENVIRONMENT
SLEEP_TIME_SIDECAR = 5 if os.getenv("SLEEP_TIME_SIDECAR") is None else int(os.getenv("SLEEP_TIME_SIDECAR"))
USERNAME = os.getenv("USERNAME")
PASSWORD = os.getenv("PASSWORD")
URL = os.getenv("URL")
print('node-red flow refresh api via k8s-sidecar')
print('Sidecar sleeping for', SLEEP_TIME_SIDECAR, 'seconds...')
time.sleep(SLEEP_TIME_SIDECAR)
# GET NODE RED BEARER TOKEN
PAYLOAD_TOKEN = {"client_id": "node-red-admin", "grant_type": "password", "scope": "*", "username": USERNAME, "password": PASSWORD}
r_token = requests.post(URL + '/auth/token', data=PAYLOAD_TOKEN, timeout=30, verify=False)
token = (json.loads(r_token.text)["access_token"])
# FLOW REFRESH/RELOAD FLOWS FROM SECRET/CONFIGMAP
PAYLOAD_FLOW_REFRESH = "{\"flows\": [{\"type\": \"tab\"}]}"
HEADERS_FLOW_REFRESH={
'Authorization': 'Bearer' + ' ' + token,
'content-type': 'application/json; charset=utf-8',
'Node-RED-Deployment-Type': 'reload',
'Node-RED-API-Version': 'v2'
}
r_flow_refresh = requests.post(URL + '/flows', headers=HEADERS_FLOW_REFRESH, data=PAYLOAD_FLOW_REFRESH, timeout=30, verify=False)
if r_flow_refresh.status_code == requests.codes.ok:
print('node-red flow refresh api respoonse code =', r_flow_refresh.status_code)
sys.exit(0)
else:
sys.exit('Error-Code', r_flow_refresh.status_code)
from node-red-chart.
Related Issues (20)
- initContainer breaking access to repositories when using Projects HOT 2
- additional pod labels HOT 5
- Update node-red to 3.0 HOT 1
- Missing curl in sidecar image HOT 4
- Is HA possible? HOT 3
- npm installs fail if hardlinks not supported on file system HOT 2
- npm install from values file HOT 7
- persistence: Keep pvc when uninstalling helm chart HOT 6
- Build a cool static web page on github pages
- Readiness for built-in https scheme support HOT 1
- Sidecar API: ApiException when calling kubernetes HOT 4
- helmfile: Failed to render chart HOT 3
- Implement computed annotations for HOT 4
- Nodered Projects Feature + flow_refresh sidecar HOT 3
- Error when enabling certificate and rendering templates HOT 3
- Cannot GET /metrics HOT 1
- Persisence-related chart values not being respected HOT 2
- Make it possible to disable creating role/rolebinding
- Rollback chart to version 0.7.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-red-chart.