Skip to content

Commit

Permalink
Configurable FastAPI endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
abaranovskis-redsamurai committed Dec 10, 2021
1 parent 110cc59 commit 03ebb61
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
12 changes: 12 additions & 0 deletions api/api-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ data:
RABBITMQ_BROKER: pyamqp://skipper:[email protected]//
RABBITMQ_HOST: rabbitmq-0.rabbitmq.rabbits.svc.cluster.local
RABBITMQ_PORT: '5672'
BOSTON_ENABLED: 'y'
MOBILENET_ENABLED: 'y'

---

Expand Down Expand Up @@ -78,6 +80,16 @@ spec:
configMapKeyRef:
name: api-config
key: RABBITMQ_PORT
- name: BOSTON_ENABLED
valueFrom:
configMapKeyRef:
name: api-config
key: BOSTON_ENABLED
- name: MOBILENET_ENABLED
valueFrom:
configMapKeyRef:
name: api-config
key: MOBILENET_ENABLED
- name: RABBITMQ_USER
valueFrom:
secretKeyRef:
Expand Down
10 changes: 8 additions & 2 deletions api/endpoint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from api.routers import skipper, boston, mobilenet
import os

app = FastAPI(openapi_url="/api/v1/skipper/tasks/openapi.json",
docs_url="/api/v1/skipper/tasks/docs")
Expand All @@ -13,6 +14,11 @@
allow_credentials=True,
)

boston_enabled = os.getenv('BOSTON_ENABLED', 'y')
mobilenet_enabled = os.getenv('MOBILENET_ENABLED', 'y')

app.include_router(skipper.router, prefix='/api/v1/skipper/tasks')
app.include_router(boston.router, prefix='/api/v1/skipper/tasks')
app.include_router(mobilenet.router, prefix='/api/v1/skipper/tasks')
if boston_enabled == 'y':
app.include_router(boston.router, prefix='/api/v1/skipper/tasks')
if mobilenet_enabled == 'y':
app.include_router(mobilenet.router, prefix='/api/v1/skipper/tasks')
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ services:
- RABBITMQ_PORT=5672
- RABBITMQ_USER=skipper
- RABBITMQ_PASSWORD=welcome1
- BOSTON_ENABLED=y
- MOBILENET_ENABLED=y
networks:
- network1
depends_on:
Expand Down

0 comments on commit 03ebb61

Please sign in to comment.