-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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://<dask-scheduler>: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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |