Skip to content

Commit

Permalink
Merge pull request #34 from alexuvarovskyi/HW9_PR4
Browse files Browse the repository at this point in the history
HW9 PR4
  • Loading branch information
alexuvarovskyi authored Nov 2, 2024
2 parents dec1f42 + 38c1f95 commit b5a12ee
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
19 changes: 18 additions & 1 deletion serving/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,21 @@ docker run -it --rm -p 8000:8000 fastapi_app:latest
How to make a request:
```bash
curl -X POST "http://localhost:8000/predict/" -F "image=@/path/to/image.jpg" -F "threshold=0.5"
```
```


## Kubernetes Deployment

Add secrets to the cluster:
```bash
kubectl create secret generic aws-secret \
--from-literal=aws_access_key_id=key \
--from-literal=aws_secret_access_key="secret_key"
```

```bash
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl port-forward <pod_name> 8000:8000
```
And then use API as described above.
39 changes: 39 additions & 0 deletions serving/fastapi_server/k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: fastapi-deployment
labels:
app: fastapi
spec:
replicas: 1
selector:
matchLabels:
app: fastapi
template:
metadata:
labels:
app: fastapi
spec:
containers:
- name: fastapi-container
image: alexuvarovskii/fastapi_app:latest
ports:
- containerPort: 8000
env:
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: aws-secret
key: aws_access_key_id
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: aws-secret
key: aws_secret_access_key
resources:
requests:
memory: "4096Mi"
cpu: "2"
limits:
memory: "10Gi"
cpu: "4"
11 changes: 11 additions & 0 deletions serving/fastapi_server/k8s/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: fastapi-service
spec:
type: LoadBalancer
ports:
- port: 8000
targetPort: 8000
selector:
app: fastapi

0 comments on commit b5a12ee

Please sign in to comment.