From 83f6b1cda2d40428dfdce74c99fedf8972e44344 Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Tue, 6 Feb 2024 09:20:15 +0000 Subject: [PATCH 1/3] Add log passthrough support part of FlowFuse/flowfuse#3324 --- README.md | 2 ++ kubernetes.js | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index a46afdd..0a3a980 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ driver: certManagerIssuer: lets-encrypt k8sDelay: 1000 k8sRetries: 10 + logPassthrough: true ``` - `registry` is the Docker Registry to load Stack Containers from @@ -32,6 +33,7 @@ AWS EKS specific annotation for ALB Ingress. - `certManagerIssuer` name of the ClusterIssuer to use to create HTTPS certs for instances (default not set) - `k8sRetries` how many times to retry actions against the K8s API - `k8sDelay` how long to wait (in ms) between retries to the K8s API +- `logPassthrough` Have Node-RED logs printed in JSON format to container stdout (default false) Expects to pick up K8s credentials from the environment diff --git a/kubernetes.js b/kubernetes.js index d23e9f9..7e0ba17 100644 --- a/kubernetes.js +++ b/kubernetes.js @@ -282,6 +282,10 @@ const createDeployment = async (project, options) => { localPod.spec.containers[0].env.push({ name: 'FORGE_NR_SECRET', value: credentialSecret }) } + if (this._logPassthrough) { + localPod.spec.containers[0].env.push({ name: "FORGE_LOG_PASSTHROUGH", value: "true" }) + } + if (this._app.config.driver.options.projectSelector) { localPod.spec.nodeSelector = this._app.config.driver.options.projectSelector } @@ -606,6 +610,7 @@ module.exports = { this._k8sDelay = this._app.config.driver.options.k8sDelay || 1000 this._k8sRetries = this._app.config.driver.options.k8sRetries || 10 this._certManagerIssuer = this._app.config.driver.options.certManagerIssuer + this._logPassthrough = this._app.config.driver.options.logPassthrough || false const kc = new k8s.KubeConfig() From 570333dc6f232f719db30b3a6edd8eda83898cd6 Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Tue, 6 Feb 2024 09:31:50 +0000 Subject: [PATCH 2/3] lint --- kubernetes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes.js b/kubernetes.js index 7e0ba17..79766b8 100644 --- a/kubernetes.js +++ b/kubernetes.js @@ -283,7 +283,7 @@ const createDeployment = async (project, options) => { } if (this._logPassthrough) { - localPod.spec.containers[0].env.push({ name: "FORGE_LOG_PASSTHROUGH", value: "true" }) + localPod.spec.containers[0].env.push({ name: 'FORGE_LOG_PASSTHROUGH', value: 'true' }) } if (this._app.config.driver.options.projectSelector) { From 3cb2c99bbf2132444df9038cbdb45d446bbbe09c Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Mon, 12 Feb 2024 10:01:06 +0000 Subject: [PATCH 3/3] Protect against no options set --- kubernetes.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kubernetes.js b/kubernetes.js index 79766b8..427a3a5 100644 --- a/kubernetes.js +++ b/kubernetes.js @@ -606,11 +606,11 @@ module.exports = { this._projects = {} this._options = options - this._namespace = this._app.config.driver.options.projectNamespace || 'flowforge' - this._k8sDelay = this._app.config.driver.options.k8sDelay || 1000 - this._k8sRetries = this._app.config.driver.options.k8sRetries || 10 - this._certManagerIssuer = this._app.config.driver.options.certManagerIssuer - this._logPassthrough = this._app.config.driver.options.logPassthrough || false + this._namespace = this._app.config.driver.options?.projectNamespace || 'flowforge' + this._k8sDelay = this._app.config.driver.options?.k8sDelay || 1000 + this._k8sRetries = this._app.config.driver.options?.k8sRetries || 10 + this._certManagerIssuer = this._app.config.driver.options?.certManagerIssuer + this._logPassthrough = this._app.config.driver.options?.logPassthrough || false const kc = new k8s.KubeConfig()