Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set up alternative protocol hosting system #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions protocol-hosting/protocol-hosting-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: file-storage
labels:
app: file-storage
spec:
selector:
matchLabels:
app: file-storage
strategy:
type: Recreate
template:
metadata:
labels:
app: file-storage
spec:
containers:
- name: file-storage-container
image: openresty/openresty
ports:
- containerPort: 80
name: file-server
volumeMounts:
- name: file-storage-volume
mountPath: "/usr/share/nginx/html"
- name: nginx-config
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
imagePullPolicy: Always
resources: {}
volumes:
- name: file-storage-volume
persistentVolumeClaim:
claimName: protocols-storage-pvc
- name: nginx-config
configMap:
name: nginx-configmap
---

kind: Service
apiVersion: v1
metadata:
labels:
app: file-storage
name: file-storage
spec:
ports:
- name: http
port: 80
selector:
app: file-storage
status:
loadBalancer: {}
---

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: nginx-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
tls:
- hosts:
- api.faang.org
secretName: tls-secret
rules:
- host: api.faang.org
http:
paths:
- path: /protocols
backend:
serviceName: file-storage
servicePort: 80
---

apiVersion: v1
kind: ConfigMap
metadata:
name: "nginx-configmap"
data:
nginx.conf: |
server {
listen 80;
listen [::]:80;
server_name api.faang.org;
add_header Allow "GET, POST" always;
location /protocols {
root /usr/share/nginx/html;
index index.html;
autoindex on;
}

location /protocols_upload {
# http_filename (request header) : original filename (eg. "test.pdf")
# http_temploc (proxy header) : temp filename and path (eg. "/usr/share/nginx/html/protocols/samples/00000001")
# http_protocol (proxy header) : protocol type (eg. "samples")
content_by_lua_block {
os.rename(ngx.var.http_temploc, "/usr/share/nginx/html/protocols/" .. ngx.var.http_protocol .. "/" .. ngx.var.http_filename);
}
}

location /protocols/samples/upload {
limit_except POST { deny all; }
client_body_temp_path /usr/share/nginx/html/protocols/samples;
client_body_in_file_only on;
client_body_buffer_size 128K;
client_max_body_size 50M;
proxy_pass_request_headers on;
proxy_set_header content-type "text/html";
proxy_set_header temploc $request_body_file;
proxy_set_header protocol "samples";
proxy_set_body $request_body_file;
proxy_pass http://api.faang.org/protocols_upload;
proxy_redirect off;
}

location /protocols/experiments/upload {
limit_except POST { deny all; }
client_body_temp_path /usr/share/nginx/html/protocols/experiments;
client_body_in_file_only on;
client_body_buffer_size 128K;
client_max_body_size 50M;
proxy_pass_request_headers on;
proxy_set_header content-type "text/html";
proxy_set_header temploc $request_body_file;
proxy_set_header protocol "experiments";
proxy_set_body $request_body_file;
proxy_pass http://api.faang.org/protocols_upload;
proxy_redirect off;
}

location /protocols/analyses/upload {
limit_except POST { deny all; }
client_body_temp_path /usr/share/nginx/html/protocols/analyses;
client_body_in_file_only on;
client_body_buffer_size 128K;
client_max_body_size 50M;
proxy_pass_request_headers on;
proxy_set_header content-type "text/html";
proxy_set_header temploc $request_body_file;
proxy_set_header protocol "analyses";
proxy_set_body $request_body_file;
proxy_pass http://api.faang.org/protocols_upload;
proxy_redirect off;
}
}
11 changes: 11 additions & 0 deletions protocol-hosting/pvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: protocols-storage-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 3Gi
storageClassName: nfs-client