From 2fe7c33c3ca7186b8ae0d3800dfcf62ff0d96649 Mon Sep 17 00:00:00 2001 From: Charayaphan Nakorn Boon Han Date: Fri, 25 Feb 2022 00:21:37 +0800 Subject: [PATCH 1/4] fix example deployment Signed-off-by: Charayaphan Nakorn Boon Han --- example-deployment/README.md | 13 +++++-- example-deployment/build-builder.sh | 1 - example-deployment/deploy.sh | 2 +- .../docker/dashboard.Dockerfile | 2 - .../docker/dashboard.dockerfile | 39 ------------------- .../docker/reporting-server.Dockerfile | 1 - .../docker/reporting.Dockerfile | 2 - .../docker/rmf-server.Dockerfile | 7 ++-- .../docker/rmf-server.build.Dockerfile | 1 - .../k8s/base/rmf-server/rmf-server.yaml | 19 +++++++++ .../k8s/example-full/rmf_server_config.py | 2 +- example-deployment/kustomize-env.sh | 5 +++ 12 files changed, 39 insertions(+), 55 deletions(-) delete mode 100644 example-deployment/docker/dashboard.dockerfile diff --git a/example-deployment/README.md b/example-deployment/README.md index dcb17088d..bdc667b05 100644 --- a/example-deployment/README.md +++ b/example-deployment/README.md @@ -36,7 +36,7 @@ others: For this example we will be using [rmf_demos](https://github.com/open-rmf/rmf_demos) as a local "deployment" of RMF, check that you have a working installation with ```bash -ros2 launch rmf_demos_gz office.launch.xml +RMW_IMPLEMENTATION=rmw_fastrtps_cpp ros2 launch rmf_demos_gz office.launch.xml ``` ## kubernetes @@ -276,9 +276,10 @@ The jobs we will run in this example can be found at `k8s/example-full/cronjobs. ## Test the deployment If not done so already, launch the office demo +NOTE: Due to DDS challenging behavior with minikube over NAT, we will use `rmw_fastrtps_cpp` to bypass NAT traversal using sharede memory transport. ```bash -ros2 launch rmf_demos_gz office.launch.xml headless:=true +RMW_IMPLEMENTATION=rmw_fastrtps_cpp ros2 launch rmf_demos_gz office.launch.xml headless:=1 use_sim_time:=false server_uri:=ws://example.com:8001 ``` Go to https://example.com/dashboard, if everything works, you should see a log in screen, use user=example, password=example. @@ -292,7 +293,7 @@ It can be very useful to automate everything mentioned above and instantly deplo Before you run the script, first you have to obtain the source. Refer to the above instructions if you don't know how to do it. You should have a git repo for rmf-web and a colcon workspace for rmf, then just run ```bash -./deploy.sh --rmf-ws --rmf-web-ws +./deploy.sh ``` Note: If you followed the above instructions to obtain the source, your rmf workspace will be in `ws/rmf`, and your rmf-web workspace will be in `ws/rmf-web`. So you will run it with `./deploy.sh --rmf-ws ws/rmf --rmf-web-ws ws/rmf`. @@ -399,7 +400,11 @@ If you can connect to rmf, there is a chance that there is some discovery issues ## Some containers crashes at first startup -Some deployments like the rmf-server may crash on the first startup, this is often due to the database not being ready yet. This is normal and kubernetes will automatically restart the container. +Some deployments like the rmf-server may crash on the first startup, this is often due to the database not being ready yet. This is normal and kubernetes will automatically restart the container. Alternatively, you can forcefully terminate the rmf-server to force a restart: +``` +kubectl get pods +kubectl delete pods [rmf-server-xxxx] +``` One solution is to add an init container to probe for the readiness of the database, but this comes at a small cost which is not normally expected to happen in an actual deployment. It is also not fail proof as there is no guarantee that diff --git a/example-deployment/build-builder.sh b/example-deployment/build-builder.sh index c55128171..2f1a7c31d 100755 --- a/example-deployment/build-builder.sh +++ b/example-deployment/build-builder.sh @@ -13,7 +13,6 @@ cd $root_dir mkdir -p build/builder/ cd $1 -cp lerna.json "$root_dir/build/builder/" find . -name node_modules -prune -o -name build -prune -o \ \(\ -name 'package*.json' -o \ diff --git a/example-deployment/deploy.sh b/example-deployment/deploy.sh index 9c612aae0..2c0622ece 100755 --- a/example-deployment/deploy.sh +++ b/example-deployment/deploy.sh @@ -71,7 +71,7 @@ echo '🗒 setting up apps and users' try() { "$@" || (sleep 1 && "$@") || (sleep 5 && "$@") } -try node keycloak-tools/bootstrap-keycloak.js +try node keycloak-tools/bootstrap-keycloak.js || true # persistent keycloak database might fail this script if it has already been run before try node keycloak-tools/get-cert.js > k8s/example-full/keycloak/keycloak.pem openssl x509 -in k8s/example-full/keycloak/keycloak.pem -pubkey -noout -out k8s/example-full/keycloak/jwt-pub-key.pub echo '✅ successfully setup keycloak' diff --git a/example-deployment/docker/dashboard.Dockerfile b/example-deployment/docker/dashboard.Dockerfile index 59718f7d2..ee9f95cd0 100644 --- a/example-deployment/docker/dashboard.Dockerfile +++ b/example-deployment/docker/dashboard.Dockerfile @@ -2,8 +2,6 @@ ARG BUILDER_TAG FROM rmf-web/builder:$BUILDER_TAG COPY . /root/rmf-web -RUN cd /root/rmf-web && \ - lerna run prepare --include-dependencies --scope=rmf-dashboard ARG PUBLIC_URL ARG REACT_APP_TRAJECTORY_SERVER diff --git a/example-deployment/docker/dashboard.dockerfile b/example-deployment/docker/dashboard.dockerfile deleted file mode 100644 index 2272dca8f..000000000 --- a/example-deployment/docker/dashboard.dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -FROM rmf-web/builder -COPY . /root/rmf-web -SHELL ["bash", "-c"] - -RUN . /opt/rmf/setup.bash && npm config set unsafe-perm && cd /root/rmf-web && \ - CI=1 npm install -g lerna@4 && lerna bootstrap --scope=rmf-dashboard - -RUN cd /root/rmf-web/packages/dashboard && \ - PUBLIC_URL='/dashboard' \ - REACT_APP_TRAJECTORY_SERVER='ws://localhost:8006' \ - REACT_APP_RMF_SERVER='https://example.com/rmf/api/v1' \ - REACT_APP_AUTH_PROVIDER='keycloak' \ - REACT_APP_KEYCLOAK_CONFIG='{ "realm": "rmf-web", "clientId": "dashboard", "url": "https://example.com/auth" }' \ - npm run build - -### - -FROM nginx:stable -COPY --from=0 /root/rmf-web/packages/dashboard/build /usr/share/nginx/html/dashboard -SHELL ["bash", "-c"] -RUN echo -e 'server {\n\ - listen 80;\n\ - server_name localhost;\n\ -\n\ - location / {\n\ - root /usr/share/nginx/html;\n\ - index index.html index.htm;\n\ - try_files $uri /dashboard/index.html;\n\ - }\n\ -\n\ - location /dashboard/static/ {\n\ - expires 30d;\n\ - }\n\ -\n\ - error_page 500 502 503 504 /50x.html;\n\ - location = /50x.html {\n\ - root /usr/share/nginx/html;\n\ - }\n\ -}\n' > /etc/nginx/conf.d/default.conf diff --git a/example-deployment/docker/reporting-server.Dockerfile b/example-deployment/docker/reporting-server.Dockerfile index 1608cc7db..37780dc0a 100644 --- a/example-deployment/docker/reporting-server.Dockerfile +++ b/example-deployment/docker/reporting-server.Dockerfile @@ -3,7 +3,6 @@ FROM rmf-web/builder:$BUILDER_TAG COPY . /root/rmf-web RUN cd /root/rmf-web && \ - lerna run prepare --include-dependencies --scope=reporting-server && \ cd packages/reporting-server && \ npm run prepack diff --git a/example-deployment/docker/reporting.Dockerfile b/example-deployment/docker/reporting.Dockerfile index a083b44c9..7f050b34e 100644 --- a/example-deployment/docker/reporting.Dockerfile +++ b/example-deployment/docker/reporting.Dockerfile @@ -2,8 +2,6 @@ ARG BUILDER_TAG FROM rmf-web/builder:$BUILDER_TAG COPY . /root/rmf-web -RUN cd /root/rmf-web && \ - lerna run prepare --include-dependencies --scope=reporting ARG PUBLIC_URL ARG REACT_APP_REPORTING_SERVER diff --git a/example-deployment/docker/rmf-server.Dockerfile b/example-deployment/docker/rmf-server.Dockerfile index c2ecd781f..c54a231a8 100644 --- a/example-deployment/docker/rmf-server.Dockerfile +++ b/example-deployment/docker/rmf-server.Dockerfile @@ -1,6 +1,6 @@ FROM rmf-web/rmf-server:build as stage0 -FROM ros:foxy-ros-base-focal +FROM ros:galactic SHELL ["bash", "-c"] @@ -15,7 +15,8 @@ COPY rmf/rmf_internal_msgs/rmf_traffic_msgs /root/rmf_ws/src/rmf_traffic_msgs COPY rmf/rmf_internal_msgs/rmf_workcell_msgs /root/rmf_ws/src/rmf_workcell_msgs COPY rmf/rmf_building_map_msgs /root/rmf_ws/src/rmf_building_map_msgs -RUN . /opt/ros/foxy/setup.bash && cd /root/rmf_ws && \ +RUN apt update && apt install -y ros-galactic-rmw-fastrtps-cpp +RUN . /opt/ros/galactic/setup.bash && cd /root/rmf_ws && \ colcon build --merge-install --install-base /opt/rmf --cmake-args -DCMAKE_BUILD_TYPE=Release && \ rm -rf /root/rmf_ws @@ -27,6 +28,6 @@ RUN cd /root/rmf-server && \ RUN echo -e '#!/bin/bash\n\ . /opt/rmf/setup.bash\n\ - exec rmf_api_server "$@"\n\ + rmf_api_server "$@"\n\ ' > /docker-entry-point.sh && chmod +x /docker-entry-point.sh ENTRYPOINT ["/docker-entry-point.sh"] diff --git a/example-deployment/docker/rmf-server.build.Dockerfile b/example-deployment/docker/rmf-server.build.Dockerfile index 04c5f6f4f..2ea193a4f 100644 --- a/example-deployment/docker/rmf-server.build.Dockerfile +++ b/example-deployment/docker/rmf-server.build.Dockerfile @@ -3,6 +3,5 @@ FROM rmf-web/builder:$BUILDER_TAG COPY . /root/rmf-web RUN cd /root/rmf-web && \ - lerna run prepare --include-dependencies --scope=api-server && \ cd packages/api-server && \ npm run prepack diff --git a/example-deployment/k8s/base/rmf-server/rmf-server.yaml b/example-deployment/k8s/base/rmf-server/rmf-server.yaml index d7bac4d33..54995195c 100644 --- a/example-deployment/k8s/base/rmf-server/rmf-server.yaml +++ b/example-deployment/k8s/base/rmf-server/rmf-server.yaml @@ -80,6 +80,23 @@ spec: ports: - protocol: TCP port: 8000 + +--- +apiVersion: v1 +kind: Service +metadata: + name: rmf-server-ws + labels: + app: rmf-server-ws + tier: app +spec: + selector: + app: rmf-server + tier: app + ports: + - protocol: TCP + port: 8001 + --- apiVersion: apps/v1 kind: Deployment @@ -107,6 +124,8 @@ spec: env: - name: RMF_API_SERVER_CONFIG value: /rmf-server-config/rmf_server_config.py + - name: RMW_IMPLEMENTATION + value: rmw_fastrtps_cpp volumeMounts: - mountPath: /rmf-server-config name: rmf-server-config diff --git a/example-deployment/k8s/example-full/rmf_server_config.py b/example-deployment/k8s/example-full/rmf_server_config.py index 367745d24..df2c0874b 100644 --- a/example-deployment/k8s/example-full/rmf_server_config.py +++ b/example-deployment/k8s/example-full/rmf_server_config.py @@ -4,7 +4,7 @@ config = deepcopy(default_config) config["host"] = "0.0.0.0" -config["port"] = 8000 +config["base_port"] = 8000 config["db_url"] = "postgres://rmf-server:rmf-server@rmf-server-db/rmf-server" config["public_url"] = "https://example.com/rmf/api/v1" config["log_level"] = "INFO" diff --git a/example-deployment/kustomize-env.sh b/example-deployment/kustomize-env.sh index 691945f66..eaa8c2d2a 100755 --- a/example-deployment/kustomize-env.sh +++ b/example-deployment/kustomize-env.sh @@ -1,4 +1,9 @@ #!/bin/bash set -e +kubectl() { + .bin/minikube kubectl -- "$@" +} +export -f kubectl + kubectl kustomize "$1" | envsubst From 85824b1974cdf2325ebae99cc53f6d223020c13f Mon Sep 17 00:00:00 2001 From: Charayaphan Nakorn Boon Han Date: Fri, 25 Feb 2022 00:47:58 +0800 Subject: [PATCH 2/4] fix routing for reporting server Signed-off-by: Charayaphan Nakorn Boon Han --- example-deployment/docker/reporting.Dockerfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/example-deployment/docker/reporting.Dockerfile b/example-deployment/docker/reporting.Dockerfile index 7f050b34e..c4d53aff4 100644 --- a/example-deployment/docker/reporting.Dockerfile +++ b/example-deployment/docker/reporting.Dockerfile @@ -29,10 +29,6 @@ RUN echo -e 'server {\n\ index index.html index.htm;\n\ try_files $uri /reporting/index.html;\n\ }\n\ -\n\ - location /reporting/static/ {\n\ - expires 30d;\n\ - }\n\ \n\ error_page 500 502 503 504 /50x.html;\n\ location = /50x.html {\n\ From 274ee18d85220a02a047f456ab44085ff17dd86f Mon Sep 17 00:00:00 2001 From: Mohamad Date: Sat, 26 Feb 2022 09:46:39 +0100 Subject: [PATCH 3/4] fix reporting front end compilation error Signed-off-by: Mohamad --- packages/reporting/src/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/reporting/src/index.tsx b/packages/reporting/src/index.tsx index 57645e1f1..cc6498293 100644 --- a/packages/reporting/src/index.tsx +++ b/packages/reporting/src/index.tsx @@ -2,10 +2,14 @@ import React from 'react'; import ReactDOM from 'react-dom'; import App from './components/app'; import * as serviceWorker from './serviceWorker'; +import LocalizationProvider from '@mui/lab/LocalizationProvider'; +import AdapterDateFns from '@mui/lab/AdapterDateFns'; ReactDOM.render( - + + + , document.getElementById('root'), ); From 971b2f510499dc2ad8b6753840a1e6f38bf30c0f Mon Sep 17 00:00:00 2001 From: Charayaphan Nakorn Boon Han Date: Wed, 2 Mar 2022 00:14:42 +0800 Subject: [PATCH 4/4] Partially working reporting server Signed-off-by: Charayaphan Nakorn Boon Han --- example-deployment/k8s/base/reporting-server/fluentd.yaml | 8 ++++---- package-lock.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/example-deployment/k8s/base/reporting-server/fluentd.yaml b/example-deployment/k8s/base/reporting-server/fluentd.yaml index 57d2c56a6..5b25f2918 100644 --- a/example-deployment/k8s/base/reporting-server/fluentd.yaml +++ b/example-deployment/k8s/base/reporting-server/fluentd.yaml @@ -5,7 +5,7 @@ metadata: --- # to set permission and groups apiVersion: rbac.authorization.k8s.io/v1 -kind: Role +kind: ClusterRole metadata: name: fluentd namespace: default @@ -20,12 +20,12 @@ rules: - list - watch --- -kind: RoleBinding +kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: fluentd roleRef: - kind: Role + kind: ClusterRole name: fluentd apiGroup: rbac.authorization.k8s.io subjects: @@ -96,4 +96,4 @@ spec: path: /var/log - name: varlibdockercontainers hostPath: - path: /var/lib/docker/containers \ No newline at end of file + path: /var/lib/docker/containers diff --git a/package-lock.json b/package-lock.json index 90414e597..68ac26ec3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -69394,7 +69394,7 @@ "@types/react-router": "^5.1.7", "@types/react-router-dom": "^5.1.7", "@types/reactour": "^1.17.1", - "ajv": "*", + "ajv": "^8.10.0", "api-client": "file:../api-client", "api-server": "file:../api-server", "axios": "^0.21.1",