Skip to content

Commit

Permalink
Make port 30101 work everywhere (#134)
Browse files Browse the repository at this point in the history
This PR changes edge-endpoints default port to 30101 so that the view
from outside k3s is the same as the view from direct-to-docker. I've
also updated comments, readmes, etc.
  • Loading branch information
tomfaulhaber authored Nov 26, 2024
1 parent befdcbb commit 9d282ca
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
# This is the token associated with "prod-biggies" (with shared credentials on 1password)
GROUNDLIGHT_API_TOKEN: ${{ secrets.GROUNDLIGHT_API_TOKEN }}
# This is the NGINX proxy endpoint
GROUNDLIGHT_ENDPOINT: http://localhost:6717
GROUNDLIGHT_ENDPOINT: http://localhost:30101

jobs:
test-general-edge-endpoint:
Expand Down Expand Up @@ -79,13 +79,13 @@ jobs:
container_id=$(docker run \
-e LOG_LEVEL=DEBUG \
-e EDGE_CONFIG \
-d -p 6717:6717 \
-d -p 30101:30101 \
groundlight-edge)
echo "::set-output name=container_id::$container_id"
- name: Run Unit Tests (that do require docker)
run: |
GROUNDLIGHT_ENDPOINT=http://localhost:6717
GROUNDLIGHT_ENDPOINT=http://localhost:30101
source test/setup_plain_test_env.sh
poetry run pytest -k "_live"
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
container_id=$(docker run \
-e LOG_LEVEL=DEBUG \
-e EDGE_CONFIG \
-d -p 6717:6717 \
-d -p 30101:30101 \
groundlight-edge)
echo "::set-output name=container_id::$container_id"
Expand Down
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Build args
ARG NGINX_PORT=6717
ARG NGINX_PORT=30101
ARG NGINX_PORT_OLD=6717
ARG UVICORN_PORT=6718
ARG APP_ROOT="/groundlight-edge"
ARG POETRY_HOME="/opt/poetry"
Expand All @@ -23,12 +24,12 @@ ARG POETRY_VERSION
# since they are required by OpenCV
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bash \
curl \
nginx \
libglib2.0-0 \
libgl1-mesa-glx \
sqlite3 \
bash \
curl \
nginx \
libglib2.0-0 \
libgl1-mesa-glx \
sqlite3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sSL https://install.python-poetry.org | python -
Expand Down Expand Up @@ -95,4 +96,4 @@ RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
CMD nginx && poetry run uvicorn --workers 8 --host 0.0.0.0 --port ${APP_PORT} --proxy-headers app.main:app

# Document the exposed port, which is configured in nginx.conf
EXPOSE ${NGINX_PORT}
EXPOSE ${NGINX_PORT} ${NGINX_PORT_OLD}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export GROUNDLIGHT_ENDPOINT=http://localhost:30101
To find the correct port, run `kubectl get services` and you should see an entry like this:
```
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/edge-endpoint-service NodePort 10.43.141.253 <none> 6717:30101/TCP 23m
service/edge-endpoint-service NodePort 10.43.141.253 <none> 30101:30101/TCP 23m
```

The port is the second number listed under ports for the `edge-endpoint-service` (in this case, 30101).
Expand Down
3 changes: 2 additions & 1 deletion configs/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ http {
access_log /var/log/nginx/access.log custom_combined;

server {
listen 6717;
listen 30101;
listen 6717; # This is the old port, which we should take out once we are sure that folks are all using the new port.
client_max_body_size 10M; # a bit more than enough for a large json of a 14MP image

location / {
Expand Down
9 changes: 2 additions & 7 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ The edge endpoint runs under kubernetes, typically on a single-node cluster, whi

The instructions below are fairly opinionated, optimized for single-node cluster setup, using k3s, on an Ubuntu/Debian-based system. If you want to set it up with a different flavor of kubernetes, that should work, but you'll have to figure out how to do that yourself.

## Dependencies
Edge Endpoint requires `curl` and `jq` which are likely already on your system, but if you have a minimal Linux distribution, they might not be. To make sure you have them, run:

```shell
sudo apt update && sudo apt install -y jq curl
```

## Setting up Single-Node Kubernetes with k3s

If you don't have [k3s](https://docs.k3s.io/) installed, there are two scripts which can install it depending on whether you have a CUDA GPU or not. If you don't set up a GPU, the models will run more slowly on CPU.
Expand All @@ -26,6 +19,8 @@ If you don't have [k3s](https://docs.k3s.io/) installed, there are two scripts w
./deploy/bin/install-k3s-nvidia.sh
```

(Note: these scripts depend on the Linux utilities `curl` and `jq`. If these aren't on your system, the scripts will install them for you.)

You might want to customize the [edge config file](../configs/edge-config.yaml) to include the detector ID's you want to run. Adding detector ID's to the config file will cause inference pods to be initialized automatically for each detector. Even if they aren't configured in the config file,
edge inference will be set up for each detector ID for which the Groundlight service receives requests (note that it
takes some time for each inference pod to become available for the first time).
Expand Down
8 changes: 4 additions & 4 deletions deploy/k3s/edge_deployment/edge_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
ports:
- protocol: TCP
# Service port for NGINX
port: 6717
port: 30101
nodePort: 30101
type: NodePort
---
Expand Down Expand Up @@ -54,7 +54,7 @@ spec:
image: *edgeEndpointImage
imagePullPolicy: Always
ports:
- containerPort: 6717
- containerPort: 30101
env:
- name: LOG_LEVEL
value: "INFO"
Expand All @@ -75,14 +75,14 @@ spec:
startupProbe:
httpGet:
path: /health/live # Checks if the server is up
port: 6717
port: 30101
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 6 # Wait for up to 1 min
readinessProbe:
httpGet:
path: /health/ready # Checks if the server is ready to serve requests
port: 6717
port: 30101
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 6 # Wait for up to 1 min
Expand Down
2 changes: 1 addition & 1 deletion test/api/test_image_queries_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Tests in this file require a live edge-endpoint server and GL Api token in order to run.
# Not ideal for unit-testing.
TEST_ENDPOINT = "http://localhost:6717"
TEST_ENDPOINT = "http://localhost:30101"
MAX_WAIT_TIME_S = 60

# Detector ID associated with the detector with parameters
Expand Down
2 changes: 1 addition & 1 deletion test/setup_plain_test_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# > docker run --name groundlight-edge \
# -e LOG_LEVEL=DEBUG \
# -e EDGE_CONFIG \
# --rm -it -p 6717:6717 edge-endpoint
# --rm -it -p 30101:30101 edge-endpoint

# Then in another terminal, run the tests:
# > make test-with-docker
Expand Down

0 comments on commit 9d282ca

Please sign in to comment.