Skip to content

Commit

Permalink
Adjust K8s config to the refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
spyker77 committed May 23, 2023
1 parent 5d49ca6 commit c46d3ed
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 2 deletions.
File renamed without changes.
12 changes: 12 additions & 0 deletions deploy/redis/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: redis
namespace: jelly
spec:
selector:
app: redis
ports:
- protocol: TCP
port: 6379
targetPort: 6379
39 changes: 39 additions & 0 deletions deploy/redis/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis
namespace: jelly
spec:
serviceName: redis
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:7-alpine
ports:
- containerPort: 6379
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "1Gi"
cpu: "1"
volumeMounts:
- name: redis-storage
mountPath: /data
volumeClaimTemplates:
- metadata:
name: redis-storage
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
4 changes: 3 additions & 1 deletion deploy/secrets.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
apiVersion: v1
kind: Secret
metadata:
name: web
name: app
namespace: jelly
type: Opaque
data:
MONGODB_DATABASE: amVsbHk=
MONGODB_URL: bW9uZ29kYjovL3Jvb3Q6c2VjcmV0QG1vbmdvLmplbGx5LnN2Yy5jbHVzdGVyLmxvY2FsOjI3MDE3
ELASTICSEARCH_URL: aHR0cDovL2VsYXN0aWNzZWFyY2guamVsbHkuc3ZjLmNsdXN0ZXIubG9jYWw6OTIwMA==
REDIS_HOST: cmVkaXMuamVsbHkuc3ZjLmNsdXN0ZXIubG9jYWw=
REDIS_PORT: NjM3OQ==
---
apiVersion: v1
kind: Secret
Expand Down
13 changes: 12 additions & 1 deletion deploy/web/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,20 @@ spec:
containers:
- name: web
image: spyker77/jelly
command:
[
"gunicorn",
"-b",
"0.0.0.0",
"-w",
"4",
"-k",
"uvicorn.workers.UvicornWorker",
"app.main:app",
]
envFrom:
- secretRef:
name: web
name: app
ports:
- containerPort: 8000
resources:
Expand Down
37 changes: 37 additions & 0 deletions deploy/worker/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: worker
namespace: jelly
spec:
replicas: 1
selector:
matchLabels:
app: worker
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
app: worker
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
containers:
- name: worker
image: spyker77/jelly
command: ["python", "-m", "app.worker"]
envFrom:
- secretRef:
name: app
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"
19 changes: 19 additions & 0 deletions deploy/worker/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: worker
namespace: jelly
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: worker
minReplicas: 1
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50

0 comments on commit c46d3ed

Please sign in to comment.