Skip to content

Instantly share code, notes, and snippets.

@simon-mo
Created October 27, 2022 22:34
Show Gist options
  • Save simon-mo/2a02cda6d04a20823d2b68379f573469 to your computer and use it in GitHub Desktop.
Save simon-mo/2a02cda6d04a20823d2b68379f573469 to your computer and use it in GitHub Desktop.
kind: ConfigMap
apiVersion: v1
metadata:
name: app-py-script
data:
app.py: |
from fastapi import FastAPI
import asyncio
app = FastAPI()
@app.get("/")
async def f():
await asyncio.sleep(0.1)
return "hi"
---
apiVersion: v1
kind: Service
metadata:
name: fastapi-service
spec:
type: LoadBalancer
selector:
app: fastapi
ports:
- protocol: TCP
port: 8000
targetPort: 8000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fastapi-deployment
labels:
app: fastapi
spec:
replicas: 3
selector:
matchLabels:
app: fastapi
template:
metadata:
labels:
app: fastapi
spec:
volumes:
- name: script
configMap:
name: app-py-script
containers:
- name: fastapi
image: rayproject/ray
env: [{"name": "version", "value": "C"}]
command: ["uvicorn", "--host", "0.0.0.0", "--port", "8000", "app:app"]
ports:
- containerPort: 8000
volumeMounts:
- name: script
mountPath: /home/ray/app.py
subPath: app.py
import time
from locust import HttpUser, task
class QuickstartUser(HttpUser):
@task
def hello_world(self):
self.client.get("/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment