edgexfoundry / edgex-examples

Apache License 2.0
51 stars 52 forks source link

helm deployment: edgex-ui CrashLoopBackOff #159

Closed jsparter closed 1 year ago

jsparter commented 1 year ago

I followed deployment/helm README.md to deploy edgex over my k8s cluster,everything is going well except pod edge-ui,I got CrashLoopBackOff and all edge-ui logs I can see are as follow:

[root@k8s-master-xxx ~]# kubectl logs -f -n edgex edgex-ui-6c6c7c84f5-z5gtc
level=INFO ts=2022-12-07T10:20:02.023721073Z app=edgex-ui-service source=config.go:392 msg="Loaded service configuration from res/docker/configuration.toml"
level=INFO ts=2022-12-07T10:20:02.027470947Z app=edgex-ui-service source=config.go:556 msg="Using local configuration from file (0 envVars overrides applied)"
level=INFO ts=2022-12-07T10:20:02.036156832Z app=edgex-ui-service source=httpserver.go:133 msg="Web server starting (localhost:4000)"
level=INFO ts=2022-12-07T10:20:02.036272605Z app=edgex-ui-service source=message.go:50 msg="Service dependencies resolved..."
level=INFO ts=2022-12-07T10:20:02.036299363Z app=edgex-ui-service source=message.go:51 msg="Starting edgex-ui-service 2.3.0 "
level=INFO ts=2022-12-07T10:20:02.036318586Z app=edgex-ui-service source=message.go:55 msg="edgex-ui-go service started"
level=INFO ts=2022-12-07T10:20:02.036339094Z app=edgex-ui-service source=message.go:58 msg="Service started in: 16.30664ms"
level=INFO ts=2022-12-07T10:20:31.811516853Z app=edgex-ui-service source=httpserver.go:158 msg="Web server stopped"
level=INFO ts=2022-12-07T10:20:31.813073451Z app=edgex-ui-service source=httpserver.go:130 msg="Web server shut down"

There are two ping test get error response: Ping edgex-support-ruleengine curl http://localhost:59861/ got 404 page not found Ping edgex-ui curl http://localhost:4000/ got curl: (7) Failed to connect to ::1: No route to host

The related release is v2.3.0 What's happened and how to fix it?

jsparter commented 1 year ago

I change to use main branch and tried again, pod is running, but still curl http://localhost:4000/ got curl: (7) Failed to connect to ::1: No route to host, and use lsof -i:4000 didn't get anything

jsparter commented 1 year ago

I change to use main branch and tried again, pod is running, but still curl http://localhost:4000/ got curl: (7) Failed to connect to ::1: No route to host, and use lsof -i:4000 didn't get anything

bnevis-i commented 1 year ago

@jsparter

The service definition for edgex-ui is missing.

Please get the "main" branch of this repo, and apply the following patch:

diff --git a/deployment/helm/templates/edgex-ui/edgex-ui-service.yaml b/deployment/helm/templates/edgex-ui/edgex-ui-service.yaml
new file mode 100644
index 0000000..c12adf2
--- /dev/null
+++ b/deployment/helm/templates/edgex-ui/edgex-ui-service.yaml
@@ -0,0 +1,17 @@
+# Copyright (C) 2022 Intel Corporation
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+apiVersion: v1
+kind: Service
+metadata:
+  labels:
+    org.edgexfoundry.service: {{.Values.edgex.app.ui}}
+  name: {{.Values.edgex.app.ui}}
+spec:
+  ports:
+  - name: "http"
+    port: {{.Values.edgex.port.ui}}
+  selector:
+    org.edgexfoundry.service: {{.Values.edgex.app.ui}}
+  type: {{.Values.expose.type}}

(basically save the above to a file, and send it to the patch command to create the file)

Let me know how it goes.

bnevis-i commented 1 year ago

After the change, you should be able to hit edgex-ui at its service address:

$ kubectl get svc edgex-ui
NAME       TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
edgex-ui   ClusterIP   10.110.128.49   <none>        4000/TCP   10m

firefox http://<edgex-ui-cluster-ip>:4000 or firefox http://10.110.128.49:4000

Also, localhost doesn't usually work in Kubernetes. For compatibility with the docker implementation (for now), the default settings of the helm chart assume a single node Kubernetes cluster. But with hostport mounts, you need to hit the IP of the node the pod is running on. This is a hack. The proper way to expose the service outside of the cluster is to make it a NodePort or LoadBalancer service. (There are settings in values.yaml to change the default from ClusterIP to some other type of service.)

$ kubectl get pods -o wide | grep edgex-ui
edgex-ui-7b8cf4c966-27bmt                           1/1     Running   0          14m   10.244.2.17   f35-k8s-edgex-w2       <none>           <none>
$ kubectl get nodes -o wide
NAME                   STATUS   ROLES                         AGE    VERSION   INTERNAL-IP       EXTERNAL-IP   OS-IMAGE                                KERNEL-VERSION            CONTAINER-RUNTIME
f35-k8s-edgex          Ready    control-plane,master,worker   342d   v1.21.0   192.168.122.205   <none>        Fedora Linux 35 (Workstation Edition)   5.15.18-200.fc35.x86_64   cri-o://1.21.3
f35-k8s-edgex-w2       Ready    <none>                        58d    v1.21.0   192.168.122.79    <none>        Fedora Linux 35 (Workstation Edition)   5.15.18-200.fc35.x86_64   cri-o://1.21.3
f35-k8s-edgex-worker   Ready    <none>                        257d   v1.21.0   192.168.122.184   <none>        Fedora Linux 35 (Workstation Edition)   5.15.18-200.fc35.x86_64   cri-o://1.21.3

According to the above, firefox http://192.168.122.79:4000 should do the trick.

Lastly, the helm charts are undergoing extremely rapid change right now. Contributions are appreciated.

bnevis-i commented 1 year ago

This fix has been merged. Reopen if this doesn't resolve your issue.