Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Commit 03ed146

Browse files
committed
added django channels service and deployment
1 parent a9c7393 commit 03ed146

File tree

6 files changed

+104
-2
lines changed

6 files changed

+104
-2
lines changed

backend/backend/settings/minikube.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,26 @@
1212
'PORT': os.environ.get('POSTGRES_SERVICE_PORT', 5432), # noqa
1313
}
1414
}
15+
16+
# Django Channels
17+
18+
CHANNEL_LAYERS = {
19+
'default': {
20+
'BACKEND': 'channels_redis.core.RedisChannelLayer',
21+
'CONFIG': {
22+
"hosts": [
23+
(
24+
os.environ.get("REDIS_SERVICE_HOST"), # noqa
25+
6379
26+
)
27+
],
28+
},
29+
},
30+
}
31+
32+
# Celery Configuration
33+
34+
CELERY_BROKER_URL = \
35+
f"redis://{os.environ.get('REDIS_SERVICE_HOST')}/6379" # noqa
36+
CELERY_RESULT_BACKEND = \
37+
f"redis://{os.environ.get('REDIS_SERVICE_HOST')}/6379" # noqa

compose/minikube.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
- HTTP_PROTOCOL=http
1616

1717
backend:
18-
image: backend:10
18+
image: backend:11
1919
build:
2020
context: ../backend/
2121
dockerfile: scripts/dev/Dockerfile

kubernetes/channels/deployment.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
apiVersion: apps/v1beta2
2+
kind: Deployment
3+
metadata:
4+
name: django-channels
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: django-channels-container
10+
template:
11+
metadata:
12+
labels:
13+
app: django-channels-container
14+
spec:
15+
containers:
16+
- name: backend
17+
imagePullPolicy: IfNotPresent
18+
image: backend:11
19+
command: ["daphne", "backend.asgi:application", "--bind", "0.0.0.0", "--port", "9000"]
20+
# livenessProbe:
21+
# httpGet:
22+
# path: /healthz
23+
# port: 9000
24+
# readinessProbe:
25+
# # an http probe
26+
# httpGet:
27+
# path: /readiness
28+
# port: 9000
29+
# initialDelaySeconds: 20
30+
# timeoutSeconds: 5
31+
ports:
32+
- containerPort: 9000
33+
env:
34+
- name: DJANGO_SETTINGS_MODULE
35+
value: 'backend.settings.minikube'
36+
37+
- name: SECRET_KEY
38+
value: "my-secret-key"
39+
40+
- name: POSTGRES_NAME
41+
value: postgres
42+
43+
- name: POSTGRES_USER
44+
valueFrom:
45+
secretKeyRef:
46+
name: postgres-credentials
47+
key: user
48+
49+
- name: POSTGRES_PASSWORD
50+
valueFrom:
51+
secretKeyRef:
52+
name: postgres-credentials
53+
key: password
54+
55+
# volumeMounts:
56+
# - name: postgres-volume-mount
57+
# mountPath: /var/lib/busybox
58+
59+
# volumes:
60+
# - name: postgres-volume-mount
61+
# persistentVolumeClaim:
62+
# claimName: postgres-pvc
63+

kubernetes/channels/service.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: kubernetes-django-channels-service
5+
spec:
6+
selector:
7+
app: django-channels-container
8+
ports:
9+
- protocol: TCP
10+
port: 9000
11+
targetPort: 9000
12+
type: NodePort

kubernetes/django/deployment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
containers:
1616
- name: backend
1717
imagePullPolicy: IfNotPresent
18-
image: backend:10
18+
image: backend:11
1919
command: ["./manage.py", "runserver", "0.0.0.0:8000"]
2020
livenessProbe:
2121
httpGet:

kubernetes/ingress.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ spec:
1919
backend:
2020
serviceName: kubernetes-django-service
2121
servicePort: 8000
22+
- path: /ws/
23+
backend:
24+
serviceName: kubernetes-django-channels-service
25+
servicePort: 9000
2226
- path: /
2327
backend:
2428
serviceName: kubernetes-frontend-service

0 commit comments

Comments
 (0)