Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
94e4cfa
Work in progress
mshah0722 Jul 14, 2022
291d30c
Begin with mock env
uhryniuk Jul 15, 2022
84c7f87
Cleaning files and folder structure
uhryniuk Jul 22, 2022
c517f68
Game functioning within kubernetes
uhryniuk Jul 28, 2022
835d6b2
Adding secrets for ICR access.
uhryniuk Aug 2, 2022
e1d300b
Removing exposed secrets
uhryniuk Aug 2, 2022
060f5a3
Expose Grafana
uhryniuk Aug 11, 2022
9734afb
Cleaning up
uhryniuk Aug 12, 2022
9c26268
Removing ICR secret
uhryniuk Aug 12, 2022
9b23456
Adding image build scripts, run from local images by default
uhryniuk Aug 18, 2022
78767b2
Grammar in Kubernetes README
uhryniuk Aug 18, 2022
4a77c64
More grammar changes for kubernetes README
uhryniuk Aug 18, 2022
6d68a4e
Fixing MongoDB
uhryniuk Aug 22, 2022
ad9e4df
Fixing bash build scripts
uhryniuk Aug 22, 2022
6f2d228
Adding confige information
uhryniuk Aug 22, 2022
3505a0c
Add Mongo secret, downgrade Node and Mongo, update docs for M1 support
kabicin Feb 7, 2023
549ecc1
Expose Prometheus Service
kabicin Feb 7, 2023
42a4eb5
Revert client Node version
kabicin Feb 7, 2023
84fd184
adding unlimited log size for space rover logs and leaderboard logs (…
jacobwdv Jul 19, 2022
ecbf855
update architecture diagram (#106)
jimmy1wu Aug 9, 2022
bb17622
updating base images to java 11 (Semeru) and OL v22.0.0.8 (#115)
jacobwdv Aug 24, 2022
abb74d1
don't send keyboard cmds unless in-game (#116)
jimmy1wu Sep 1, 2022
f53740e
only progressing to connect hardware when valid messages are recieved…
jacobwdv Sep 8, 2022
bc7cc11
Update README.md
hlhoots Oct 11, 2022
f94b993
adding addresses for sun damage on gameboard 3
jacobwdv Oct 19, 2022
23944ca
adding copyright (#123)
jacobwdv Oct 26, 2022
347645e
Jd reducelatency (#124)
jacobwdv Oct 31, 2022
e368721
Adding Rover V3 Code
pgunapal Oct 19, 2022
31e3b25
Update SpaceRover_Teensy.ino
pgunapal Nov 10, 2022
801e5ae
fixing venv to be in project root instead of /tmp (#126)
jacobwdv Nov 11, 2022
8752e81
adding battery percentage metric
jacobwdv Nov 11, 2022
cdb9e50
persisting prometheus data and updating logging for websockets to hel…
jacobwdv Nov 23, 2022
8d4f0ff
adding battery message sent to GUI after rover responds from ACK (#131)
jacobwdv Feb 3, 2023
58a639d
sending a stop message on every change in direction from the hand (#130)
jacobwdv Feb 3, 2023
ae7a356
Set gameservice port to use 9080
kabicin Mar 10, 2023
10726e5
Set leaderboard to use port 9070
kabicin Mar 15, 2023
6684cac
Merge branch 'main' into issue_100
kabicin Mar 15, 2023
d9cdd98
Add k8s/mock directory to enable mockrover and mockboard with mpConfi…
kabicin Mar 15, 2023
d71c3e4
Update README.md
kabicin Mar 15, 2023
4c3034d
Update README.md
pgunapal Mar 17, 2023
6254d8d
Resolve leaderboard port conflict for docker-compose
kabicin Mar 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions documentation/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ The following instructions detail how to setup the Mini PC used to run the game

* **Webapp** => localhost:3000/
<br>&nbsp; ![Webapp Play Page](../images/four-tab-game-page.png)
* **Game Service Health** => localhost:9070/health
* **Game Service Health** => localhost:9080/health
<br><br>&nbsp; ![Game Service Health](../images/four-tab-game-server-health.png)
* **Leaderboard Health** => localhost:9080/health
* **Leaderboard Health** => localhost:9070/health
<br><br>&nbsp; ![Leaderboard Health](../images/four-tab-leaderboard-health.png)
* **Grafana** => localhost:3010/
* There are two dashboards: Liberty Metrics Dashboard and Space Rover Mission statistics Dashboard
Expand Down
4 changes: 2 additions & 2 deletions gestures/openCV_implementation/src/GestureRecognitionCVv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import sys

print("Starting to connect")
#uri = "ws://192.168.0.101:9070/roversocket"
URI = "ws://localhost:9070/roversocket"
#uri = "ws://192.168.0.101:9080/roversocket"
URI = "ws://localhost:9080/roversocket"


# Asynchronously try to connect to the server
Expand Down
116 changes: 116 additions & 0 deletions kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Using Kubernetes with the Space Rover
This document covers the process of configuring the OpenLiberty Space rover to user Kubernetes to manage it's services.

## Getting started with Kubernetes
One of the easiest ways to work with Kubernetes locally is with Docker Desktop. In your Docker Desktop settings, you can enable a local Kubernetes cluster.

## Building your Images for Kubernetes
When running the Open Liberty Space Rover with Docker Compose, the service images are created in a build step within the Docker Compose file. This implies that to use the images for Kubernetes you will have to build all the images manually. You are welcome to do this by hand if you have customizations you wish to make, otherwise we recommend you use the `buildServices.bat` or `buildServices.sh` scripts to build all of the images.

Users on Mac with Apple Silicon need to enable "Use Rosetta for x86/amd64 emulation on Apple Silicon" in Docker Desktop settings and build images with the `export DOCKER_DEFAULT_PLATFORM=linux/amd64` flag set.

If you decide to use the build scripts, ensure you run the script from the `kubernetes` directory.

After running the scripts you should see the following to indcate that you images are created.
```
Your images are complete!
You can now apply your kubernetes files.
```

## Configuring your Kubernetes Files
By default, the Kubernetes files are configured to run from the local images you just built. Alternatively, you can place these images in a container registry such as OpenShift Container Registry.

### Configure MongoDB
Ensure that the device running the Kubernetes cluster provides an available location to allocate it's persistent volume and configure it so in the `mongo-pv.yaml` file. To do this, navigate to `services\k8s\mongo-pv.yaml` and provide an path to a folder on your device that you wish to allocate, as seen below. In addition, folder must already exist at runtime if you specify it.
```
hostPath:
# Provide the existing directory below to use as Persistent Volume.
path: /opt/data/mongo
```

Additionally, create a Secret for the database credentials.
```
kubectl create secret generic mongo-secret \
--from-literal=MONGO_INITDB_ROOT_USERNAME=<user> \
--from-literal=MONGO_INITDB_ROOT_PASSWORD=<password>
```

## Applying you Kubernetes Files to your Cluster
After your images are built and you have configured repo to your use case, you can apply them to your cluster. Firstly, ensure that your cluster is operating properly with the following command:
```
kubectl get nodes
```

You should see the following:
```
NAME STATUS ROLES AGE VERSION
docker-desktop Ready control-plane 22h v1.24.2
```

Next, it is time to apply the `.yaml` files by navigating to the `services` directory and executing the following command:
```
kubectl apply -f ./k8s
```

It takes roughly 20-30 seconds for the Kubernetes to create all the pods and the containers, so be patient. To check on their status you are able to run the following command:
```
kubectl get pods
```

Once all of your pods are in `Running` status and your ouput looks like the following, then you are able to move onto testing your cluster.
```
NAME READY STATUS RESTARTS AGE
client-76bc76b7b4-9qzm2 1/1 Running 0 20s
gameservice-66857669fc-h24rr 1/1 Running 0 20s
grafana-6d6c864f76-859hs 1/1 Running 0 20s
leaderboard-5cd7c966c5-9jvr9 1/1 Running 0 20s
mongo-0 1/1 Running 0 19s
prometheus-74799df65-4nbxl 1/1 Running 0 19s
```

To run the `mockboard` and `mockrover` services, use files in the `services/k8s/mock` with a recursive apply command:
```
kubectl apply -R -f ./k8s
```

## Testing your Cluster
At this point you should be able to navigate to [Client WebApp](http://localhost:3000) to play the game!

## Shutting Down your Cluster
After you are done testing out your cluster, you are able to shut it down with the executing the following command from the `services/` directory:
```
kubectl delete -f ./k8s
```
The output should be similar to the following:
```
deployment.apps "client" deleted
service "client" deleted
deployment.apps "gameservice" deleted
service "gameservice" deleted
deployment.apps "grafana" deleted
service "grafana" deleted
deployment.apps "leaderboard" deleted
service "leaderboard" deleted
deployment.apps "mockboard" deleted
service "mockboard" deleted
deployment.apps "mockrover" deleted
service "mockrover" deleted
deployment.apps "mongo" deleted
persistentvolume "mongo-data-pv" deleted
persistentvolumeclaim "mongo-pvc-0" deleted
service "mongo" deleted
deployment.apps "prometheus" deleted
service "prometheus" deleted
```

Then, you can run the following command to verify all your containers are down:
```
kubectl get pods
```

Which should give you the following:
```
No resources found in default namespace.
```


33 changes: 33 additions & 0 deletions kubernetes/buildServices.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@echo off
:: Build all the images

:: client
START /B /WAIT docker build -t space-rover/client ^
--build-arg GAME_URL=http://localhost:9080/game ^
--build-arg GAME_SOCKET_URL=ws://localhost:9080/roversocket ^
--build-arg GAME_DURATION_SECONDS=120 ^
--build-arg LEADERBOARD_URL=http://localhost:9070/mongo/leaderboard ../services/client

:: gameservice
START /B /WAIT docker build -t space-rover/gameservice ../services/game

:: leaderboard
START /B /WAIT docker build -t space-rover/leaderboard ../services/leaderboard

:: mockboard (if applicable)
START /B /WAIT docker build -t space-rover/mockboard ../services/mock/board

:: mockrover (if applicable)
START /B /WAIT docker build -t space-rover/mockrover ../services/mock/rover

:: mongo
START /B /WAIT docker build -t space-rover/mongo ../services/leaderboard/assets

:: prometheus
START /B /WAIT docker build -t space-rover/prometheus ../services/prometheus

:: grafana
START /B /WAIT docker build -t space-rover/grafana ../services/grafana

echo Your Images are Complete!
echo You can now apply your kubernetes files.
32 changes: 32 additions & 0 deletions kubernetes/buildServices.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# Build all the images
# client
docker build -t space-rover/client \
--build-arg GAME_URL=http://localhost:9080/game \
--build-arg GAME_SOCKET_URL=ws://localhost:9080/roversocket \
--build-arg GAME_DURATION_SECONDS=120 \
--build-arg LEADERBOARD_URL=http://localhost:9070/mongo/leaderboard ../services/client

# gameservice
docker build -t space-rover/gameservice ../services/game

# leaderboard
docker build -t space-rover/leaderboard ../services/leaderboard

# mockboard (if applicable)
docker build -t space-rover/mockboard ../services/mock/board

# mockrover (if applicable)
docker build -t space-rover/mockrover ../services/mock/rover

# mongo
docker build -t space-rover/mongo ../services/leaderboard/assets

# prometheus
docker build -t space-rover/prometheus ../services/prometheus

# grafana
docker build -t space-rover/grafana ../services/grafana

echo Your Images are Complete!
echo You can now apply your kubernetes files.
4 changes: 2 additions & 2 deletions services/client/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REACT_APP_GAME_SOCKET_URL=ws://localhost:9070/roversocket
REACT_APP_GAME_SOCKET_URL=ws://localhost:9080/roversocket
REACT_APP_GAME_DURATION_SECONDS=300
REACT_APP_LEADERBOARD_URL=http://localhost:9080/mongo/leaderboard
REACT_APP_LEADERBOARD_URL=http://localhost:9070/mongo/leaderboard
2 changes: 1 addition & 1 deletion services/client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.14-alpine AS builder
FROM node:14.17.5 AS builder

WORKDIR /usr/src/app

Expand Down
19 changes: 14 additions & 5 deletions services/docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,28 @@ services:
leaderboard:
build: ./leaderboard
ports:
- "9080:9080"
- "9070:9080"
gameservice:
build: ./game
environment:
- io.openliberty.leaderboard.hostname=leaderboard
- io.openliberty.leaderboard.port=9080
- io.openliberty.server.hostname=gameservice
- io.openliberty.server.port=9080
- io.openliberty.spacerover.ip=mockrover
- io.openliberty.spacerover.port=5045
- io.openliberty.gameboard.ip=mockboard
- io.openliberty.gameboard.port=5045
ports:
- "9070:9080"
- "9080:9080"
client:
build:
context: ./client
args:
- GAME_URL=http://localhost:9070/game
- GAME_SOCKET_URL=ws://localhost:9070/roversocket
- GAME_URL=http://localhost:9080/game
- GAME_SOCKET_URL=ws://localhost:9080/roversocket
- GAME_DURATION_SECONDS=120
- LEADERBOARD_URL=http://localhost:9080/mongo/leaderboard
- LEADERBOARD_URL=http://localhost:9070/mongo/leaderboard
ports:
- "3000:80"
mockrover:
Expand Down
19 changes: 14 additions & 5 deletions services/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,27 @@ services:
leaderboard:
build: ./leaderboard
ports:
- "9080:9080"
- "9070:9080"
gameservice:
build: ./game
environment:
- io.openliberty.leaderboard.hostname=leaderboard
- io.openliberty.leaderboard.port=9080
- io.openliberty.server.hostname=gameservice
- io.openliberty.server.port=9080
- io.openliberty.spacerover.ip=192.168.0.115
- io.openliberty.spacerover.port=5045
- io.openliberty.gameboard.ip=192.168.0.117
- io.openliberty.gameboard.port=5045
ports:
- "9070:9080"
- "9080:9080"
client:
build:
context: ./client
args:
- GAME_URL=http://localhost:9070/game
- GAME_SOCKET_URL=ws://localhost:9070/roversocket
- GAME_URL=http://localhost:9080/game
- GAME_SOCKET_URL=ws://localhost:9080/roversocket
- GAME_DURATION_SECONDS=120
- LEADERBOARD_URL=http://localhost:9080/mongo/leaderboard
- LEADERBOARD_URL=http://localhost:9070/mongo/leaderboard
ports:
- "3000:80"
2 changes: 1 addition & 1 deletion services/game/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COPY src src

RUN mvn -o package -DskipTests

FROM icr.io/appcafe/websphere-liberty:22.0.0.8-full-java11-openj9-ubi
FROM icr.io/appcafe/websphere-liberty:22.0.0.12-full-java11-openj9-ubi

COPY --chown=1001:0 --from=builder /usr/src/app/target/*.war /config/apps

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
io.openliberty.leaderboard.hostname=leaderboard
io.openliberty.leaderboard.port=9080
io.openliberty.leaderboard.port=9070
io.openliberty.server.hostname=gameservice
io.openliberty.server.port=9080

Expand All @@ -10,7 +10,7 @@ io.openliberty.gameboard.ip=192.168.0.117
io.openliberty.gameboard.port=5045

# Test
#io.openliberty.spacerover.ip=mockrover
#io.openliberty.spacerover.port=5045
#io.openliberty.gameboard.ip=mockboard
#io.openliberty.gameboard.port=5045
# io.openliberty.spacerover.ip=mockrover
# io.openliberty.spacerover.port=5045
# io.openliberty.gameboard.ip=mockboard
# io.openliberty.gameboard.port=5045
6 changes: 6 additions & 0 deletions services/grafana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM grafana/grafana:7.3.7

COPY --chown=1000:0 ./datasources.yml /etc/grafana/provisioning/datasources/datasources.yml
COPY --chown=1000:0 ./dashboards.yml /etc/grafana/provisioning/dashboards/dashboards.yml
COPY --chown=1000:0 ./dashboards/open-liberty_rev5.json /var/lib/grafana/dashboards/open-liberty_rev5.json
COPY --chown=1000:0 ./dashboards/space-rover-rev1.json /var/lib/grafana/dashboards/space-rover-rev1.json
27 changes: 27 additions & 0 deletions services/k8s/client-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.service: client
name: client
spec:
replicas: 1
selector:
matchLabels:
app.service: client
strategy: {}
template:
metadata:
labels:
app.service: client
spec:
containers:
# - image: ca.icr.io/space-rover/client-test
- image: space-rover/client
name: client
ports:
- containerPort: 80
resources: {}
# Change Pull Policy for Remote Registry
imagePullPolicy: Never
status: {}
16 changes: 16 additions & 0 deletions services/k8s/client-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
labels:
app.service: client
name: client
spec:
type: LoadBalancer
ports:
- name: "3000"
port: 3000
targetPort: 80
selector:
app.service: client
status:
loadBalancer: {}
28 changes: 28 additions & 0 deletions services/k8s/gameservice-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.service: gameservice
name: gameservice
spec:
replicas: 1
selector:
matchLabels:
app.service: gameservice
strategy: {}
template:
metadata:
labels:
app.service: gameservice
spec:
containers:
# - image: ca.icr.io/space-rover/gameservice-test
- image: space-rover/gameservice
name: gameservice
ports:
- containerPort: 9080
resources: {}
# Change Pull Policy for Remote Registry
imagePullPolicy: Never
restartPolicy: Always
status: {}
Loading