使用 YAML 的 k3 集群上的 Node Red 不工作
Node Red on my k3 cluster using YAML not working
我正在尝试将一个简单的 node-red 应用程序部署到我的 k3s 容器。背景我有两个 pi 4 作为我的服务器和 3B+ 作为我的工人。
对于我得到的错误
NAME READY STATUS RESTARTS AGE
nodered-559875dbbd-mn474 0/1 CrashLoopBackOff 11 36m
这是我的 yaml 文件
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.service: nodered
name: nodered
namespace: nodered
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: nodered
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.service: nodered
spec:
containers:
- image: nodered/node-red
name: nodered
ports:
- containerPort: 1880
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 2
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 2
periodSeconds: 10
resources: {}
volumeMounts:
- mountPath: /data
name: nodered-claim0
restartPolicy: Always
securityContext:
runAsUser: 0
volumes:
- name: nodered-claim0
persistentVolumeClaim:
claimName: nodered-claim0
status: {}
---
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.service: nodered
name: nodered
namespace: nodered
spec:
ports:
- name: "1880"
port: 80
targetPort: 1880
selector:
io.kompose.service: nodered
status:
loadBalancer: {}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: nodered-claim0
name: nodered-claim0
namespace: nodered
spec:
storageClassName: longhorn
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
status: {}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nodered-ingress
namespace: nodered
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
spec:
rules:
- host: nodered.local
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: nodered
port:
number: 80
这是我在键入描述节点时遇到的错误
Name: nodered-559875dbbd-mn474
Namespace: nodered
Priority: 0
Node: masternode/192.168.1.120
Start Time: Tue, 27 Apr 2021 10:38:28 -0400
Labels: io.kompose.service=nodered
pod-template-hash=559875dbbd
Annotations: kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
Status: Running
IP: 10.42.1.197
IPs:
IP: 10.42.1.197
Controlled By: ReplicaSet/nodered-559875dbbd
Containers:
nodered:
Container ID: containerd://af3290fa34138a3361d5d73b7c1872eb1c523cefb0b8c17195db5d99c609f9fb
Image: nodered/node-red
Image ID: docker.io/nodered/node-red@sha256:f16e1ec7265829bcc381009dec175d9fbbc050ab6a1c42c4c906e689ff3bcf6b
Port: 1880/TCP
Host Port: 0/TCP
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Tue, 27 Apr 2021 10:38:52 -0400
Finished: Tue, 27 Apr 2021 10:38:52 -0400
Ready: False
Restart Count: 2
Liveness: http-get http://:80/ delay=2s timeout=1s period=10s #success=1 #failure=3
Readiness: http-get http://:80/ delay=2s timeout=1s period=10s #success=1 #failure=3
Environment: <none>
Mounts:
/data from nodered-claim0 (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-j2f7l (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
nodered-claim0:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: nodered-claim0
ReadOnly: false
default-token-j2f7l:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-j2f7l
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 37s default-scheduler Successfully assigned nodered/nodered-559875dbbd-mn474 to masternode
Normal Pulled 33s kubelet Successfully pulled image "nodered/node-red" in 495.427449ms
Normal Pulled 32s kubelet Successfully pulled image "nodered/node-red" in 504.720641ms
Normal Pulling 14s (x3 over 34s) kubelet Pulling image "nodered/node-red"
Normal Pulled 14s kubelet Successfully pulled image "nodered/node-red" in 506.632077ms
Normal Created 13s (x3 over 33s) kubelet Created container nodered
Normal Started 13s (x3 over 33s) kubelet Started container nodered
Warning BackOff 6s (x5 over 30s) kubelet Back-off restarting failed container
最终日志显示如下:
internal/modules/cjs/loader.js:800
throw err;
^
SyntaxError: /usr/local/lib/node_modules/npm/package.json: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Object.Module._extensions..json (internal/modules/cjs/loader.js:797:27)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
我似乎无法追溯我的日志问题,或者至少不确定去哪里找。欢迎任何帮助
对于那些想知道我让这个工作的人。由于某种原因,它与节点 js 的安装发生冲突......不知道为什么。卸载了 nodejs 并重新安装,一切正常。因此,对于那些想要使用它的人来说,上面的配置文件没有任何问题。将配置绑定到卷后,您也可以添加身份验证。
我正在尝试将一个简单的 node-red 应用程序部署到我的 k3s 容器。背景我有两个 pi 4 作为我的服务器和 3B+ 作为我的工人。
对于我得到的错误
NAME READY STATUS RESTARTS AGE
nodered-559875dbbd-mn474 0/1 CrashLoopBackOff 11 36m
这是我的 yaml 文件
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.service: nodered
name: nodered
namespace: nodered
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: nodered
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.service: nodered
spec:
containers:
- image: nodered/node-red
name: nodered
ports:
- containerPort: 1880
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 2
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 2
periodSeconds: 10
resources: {}
volumeMounts:
- mountPath: /data
name: nodered-claim0
restartPolicy: Always
securityContext:
runAsUser: 0
volumes:
- name: nodered-claim0
persistentVolumeClaim:
claimName: nodered-claim0
status: {}
---
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.service: nodered
name: nodered
namespace: nodered
spec:
ports:
- name: "1880"
port: 80
targetPort: 1880
selector:
io.kompose.service: nodered
status:
loadBalancer: {}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: nodered-claim0
name: nodered-claim0
namespace: nodered
spec:
storageClassName: longhorn
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
status: {}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nodered-ingress
namespace: nodered
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
spec:
rules:
- host: nodered.local
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: nodered
port:
number: 80
这是我在键入描述节点时遇到的错误
Name: nodered-559875dbbd-mn474
Namespace: nodered
Priority: 0
Node: masternode/192.168.1.120
Start Time: Tue, 27 Apr 2021 10:38:28 -0400
Labels: io.kompose.service=nodered
pod-template-hash=559875dbbd
Annotations: kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
Status: Running
IP: 10.42.1.197
IPs:
IP: 10.42.1.197
Controlled By: ReplicaSet/nodered-559875dbbd
Containers:
nodered:
Container ID: containerd://af3290fa34138a3361d5d73b7c1872eb1c523cefb0b8c17195db5d99c609f9fb
Image: nodered/node-red
Image ID: docker.io/nodered/node-red@sha256:f16e1ec7265829bcc381009dec175d9fbbc050ab6a1c42c4c906e689ff3bcf6b
Port: 1880/TCP
Host Port: 0/TCP
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Tue, 27 Apr 2021 10:38:52 -0400
Finished: Tue, 27 Apr 2021 10:38:52 -0400
Ready: False
Restart Count: 2
Liveness: http-get http://:80/ delay=2s timeout=1s period=10s #success=1 #failure=3
Readiness: http-get http://:80/ delay=2s timeout=1s period=10s #success=1 #failure=3
Environment: <none>
Mounts:
/data from nodered-claim0 (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-j2f7l (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
nodered-claim0:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: nodered-claim0
ReadOnly: false
default-token-j2f7l:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-j2f7l
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 37s default-scheduler Successfully assigned nodered/nodered-559875dbbd-mn474 to masternode
Normal Pulled 33s kubelet Successfully pulled image "nodered/node-red" in 495.427449ms
Normal Pulled 32s kubelet Successfully pulled image "nodered/node-red" in 504.720641ms
Normal Pulling 14s (x3 over 34s) kubelet Pulling image "nodered/node-red"
Normal Pulled 14s kubelet Successfully pulled image "nodered/node-red" in 506.632077ms
Normal Created 13s (x3 over 33s) kubelet Created container nodered
Normal Started 13s (x3 over 33s) kubelet Started container nodered
Warning BackOff 6s (x5 over 30s) kubelet Back-off restarting failed container
最终日志显示如下:
internal/modules/cjs/loader.js:800
throw err;
^
SyntaxError: /usr/local/lib/node_modules/npm/package.json: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Object.Module._extensions..json (internal/modules/cjs/loader.js:797:27)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
我似乎无法追溯我的日志问题,或者至少不确定去哪里找。欢迎任何帮助
对于那些想知道我让这个工作的人。由于某种原因,它与节点 js 的安装发生冲突......不知道为什么。卸载了 nodejs 并重新安装,一切正常。因此,对于那些想要使用它的人来说,上面的配置文件没有任何问题。将配置绑定到卷后,您也可以添加身份验证。