Browse Source

[k8s] Adding daphne properties

Avoid daphne No module named 'asgiref.compatibility'

https://github.com/django/daphne/issues/256
Romain 5 years ago
parent
commit
341b2e80ce

+ 13 - 0
desktop/core/src/desktop/asgi.py

@@ -0,0 +1,13 @@
+"""
+ASGI entrypoint. Configures Django and then runs the application
+defined in the ASGI_APPLICATION setting.
+"""
+
+import os
+import django
+from channels.routing import get_default_application
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "desktop.settings")
+django.setup()
+application = get_default_application()
+

+ 1 - 1
tools/kubernetes/helm/hue/templates/deployment-daphne.yaml

@@ -19,7 +19,7 @@ spec:
         - name: daphne-websocket
           image: {{ .Values.image.registry }}/hue:{{ .Values.image.tag }}
           imagePullPolicy: {{ .Values.image.pullPolicy }}
-          command: ['./build/env/bin/daphne', '-p', '8001', 'core.asgi:application']
+          command: ['./build/env/bin/daphne', '-p', '8001', 'desktop.asgi:application']
           resources:
             requests:
               # memory: "64Mi"

+ 4 - 0
tools/kubernetes/helm/hue/templates/ingress-https.yaml

@@ -26,6 +26,10 @@ spec:
           serviceName: hue-balancer
           servicePort: 80
         path: /
+        - backend:
+          serviceName: daphne-websocket
+          servicePort: 8001
+        path: /(ws/.*)
   {{- range .Values.ingress.extraHosts }}
   - host: {{ . | quote }}
     http:

+ 2 - 2
tools/kubernetes/helm/hue/templates/service-daphne.yaml

@@ -2,10 +2,10 @@
 apiVersion: v1
 kind: Service
 metadata:
-  name: dahpne-websocket
+  name: daphne-websocket
 spec:
   selector:
-    pod: dahpne-websocket
+    pod: daphne-websocket
   ports:
   - port: 8001
   type: ClusterIP