diff --git a/dask_config.yaml b/dask_config.yaml index f2b54ac..88ec6ad 100644 --- a/dask_config.yaml +++ b/dask_config.yaml @@ -74,6 +74,8 @@ kubernetes: - scheduler - --port - "8786" + - -bokeh-prefix + - daskboard - --bokeh-port - "8787" resources: diff --git a/kube/nginx_proxy.yaml b/kube/nginx_proxy.yaml new file mode 100644 index 0000000..d51c2bb --- /dev/null +++ b/kube/nginx_proxy.yaml @@ -0,0 +1,80 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-conf +data: + nginx.conf: | + user nginx; + worker_processes 2; + error_log /var/log/nginx/error.log; + events { + worker_connections 10240; + } + http { + + server { + listen 8080; + server_name localhost; + location ^~ /daskboard/ { + proxy_pass http://:8787; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Real-IP $remote_addr; + proxy_http_version 1.1; + proxy_redirect off; + proxy_buffering off; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_read_timeout 86400; + } + } + } +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: n4dask + labels: + app: nginx +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:latest + ports: + - containerPort: 8080 + volumeMounts: + - name: nginx-conf + mountPath: /etc/nginx # mount nginx-conf volume to /etc/nginx + resources: + requests: + cpu: "1" + memory: "1Gi" + limits: + cpu: "2" + memory: "2Gi" + volumes: + - name: nginx-conf + configMap: + name: nginx-conf +--- +apiVersion: v1 +kind: Service +metadata: + name: n4dask +spec: + type: NodePort + ports: + - port: 80 + targetPort: 8080 + nodePort: 30001 + selector: + app: nginx diff --git a/kube/tests/foo.vtc b/kube/tests/foo.vtc new file mode 100644 index 0000000..a11b1b6 --- /dev/null +++ b/kube/tests/foo.vtc @@ -0,0 +1,36 @@ +varnishtest "Testing URL rewriting, for real" + +server s1 { +# rxreq +# txresp +# expect req.url == "/content/articles/my_post.html" + + rxreq + txresp + expect req.url == "/servicexxx.af-jupyter/status" +} -start + +varnish v1 -vcl+backend { + + import std; + sub vcl_recv { + + if (req.url ~ "/cmsa/post/") { + set req.url = regsuball(req.url, "/cmsa/post/", "/content/articles/"); + } + if (req.url ~ "/dask-service/") { + set req.http.x-fuck = regsub(req.url, "^/dask-service/([a-zA-Z0-9 -]*).af-jupyter/(.*)", "\1"); + set req.url = regsub(req.url, "/dask-service/([a-zA-Z0-9 -]*).af-jupyter/", "/"); + set req.http.x-fuck=req.http.x-fuck+".af-jupyter"; + } + } + +} -start + +client c1 { +# txreq -url "/cmsa/post/my_post.html" +# rxresp + + txreq -url "/dask-service/servicexxx.af-jupyter/status/asdf" + rxresp +} -run \ No newline at end of file diff --git a/kube/varnish_proxy.yaml b/kube/varnish_proxy.yaml new file mode 100644 index 0000000..ff22077 --- /dev/null +++ b/kube/varnish_proxy.yaml @@ -0,0 +1,84 @@ +# to test: +# docker run --rm -it -P -v .\tests\foo.vtc:/etc/varnish/tests/foo.vtc varnish:latest varnishtest /etc/varnish/tests/foo.vtc +apiVersion: v1 +kind: ConfigMap +metadata: + name: v4dask + namespace: af-jupyter + labels: + k8s-app: v4dask +data: + default.vcl: |- + vcl 4.1; + import std; + import goto; + + # import dynamic; + # import directors; + + backend default none; + + sub vcl_recv { + if (req.url ~ "/dask-service/") { + set req.http.x-dask-service = regsub(req.url, "^/dask-service/([a-zA-Z0-9 -]*).af-jupyter/(.*)", "\1"); + set req.http.x-dask-service = req.http.x-dask-service + ".af-jupyter"; + set req.url = regsub(req.url, "/dask-service/([a-zA-Z0-9 -]*).af-jupyter/", "/"); + } + } + + sub vcl_backend_fetch { + set bereq.backend = goto.dns_backend(req.http.x-dask-service); + } + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: varnish4dask + namespace: af-jupyter + labels: + k8s-app: v4dask +spec: + replicas: 1 + selector: + matchLabels: + k8s-app: v4dask + template: + metadata: + labels: + k8s-app: v4dask + spec: + containers: + - name: v4dask + image: varnish:latest + # args: ["-t", "3600"] + command: ["varnishd"] + args: + [ + "-F", + "-f", + "/etc/varnish/default.vcl", + "-a", + "http=:6081,HTTP", + "-p", + "feature=+http2", + "-s", + "malloc,$VARNISH_SIZE", + ] + ports: + - containerPort: 6081 + hostPort: 8787 + volumeMounts: + - name: config-volume + mountPath: /etc/varnish/ + resources: + requests: + cpu: "1" + memory: "1Gi" + limits: + cpu: "2" + memory: "2Gi" + volumes: + - name: config-volume + configMap: + name: v4dask