-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow_refresh.sh Script failed in Sidecar Container #236
Comments
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 |
Hey @dirien |
awesome @hinrichd! Let's see what the answer is! |
Hi @dirien,
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... |
UPDATE: Now, there is a new version of the k8s-sidecar release called 1.24.0. In this version the Meanwhile I rewrite the --> Script Output from Sidecar Container
--> Node-Red Log Output
flow_refresh.py
#!/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) |
@hinrichd many thanks for the contribution! |
What happened?
I try to import a flow from Config File via the Sidecar Container but the flow_refresh.sh script is failing. The flow will not imported via the API Refresh.
Actually I am using pv/pvc and install flows and nodes manually via web interface. Thought I would be a good way to use a sidecar like kubernetes microservice style.
How can we reproduce this?
Connecting to the sidecar shell and checking the flow_refresh script:
The k8s-sidecar container is missing curl and jq binary!
Is this the common behaviour?
Helm Chart version
Search
Code of Conduct
Additional context
No response
The text was updated successfully, but these errors were encountered: