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

Add k8s stuff, update reqs. #285

Open
wants to merge 8 commits into
base: develop
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
dist/
tmp/

sa-dashboard/dist/

# dependencies
node_modules/
bower_components/
Expand All @@ -19,7 +21,7 @@ package-lock.json
testem.log



.python-version

!.gitkeep
# DB / Migrations
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# SHARE Analytics Dashboard

[![Gitter](https://badges.gitter.im/cos-labs/share-analytics.svg)](https://gitter.im/cos-labs/share-analytics?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Expand Down
623 changes: 0 additions & 623 deletions \

This file was deleted.

31 changes: 31 additions & 0 deletions deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: share-analytics-deployment
labels:
app: share-analytics
spec:
replicas: 1
selector:
matchLabels:
app: share-analytics
template:
metadata:
labels:
app: share-analytics
spec:
containers:
- name: share-analytics-dashboard
image: share-analytics-dashboard
imagePullPolicy: Never
ports:
- containerPort: 80
- name: share-analytics-bulkagentget
image: share-analytics-bulkagentget
imagePullPolicy: Never
ports:
- containerPort: 4200
#- name: elastic
# image: elasticsearch:latest
# ports:
# - containerPort: 9200
17 changes: 17 additions & 0 deletions ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: share-analytics-ingress
spec:
rules:
- host: tritonshare.local
http:
paths:
- path: /
backend:
serviceName: share-analytics-static
servicePort: 80
- path: /bulkagentget
backend:
serviceName: bulkagentget
servicePort: 80
70 changes: 0 additions & 70 deletions package.json

This file was deleted.

5 changes: 5 additions & 0 deletions sa-bulkagentget/.ebextensions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
3 changes: 3 additions & 0 deletions sa-bulkagentget/.ebextensions/nodecommand.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
option_settings:
aws:elasticbeanstalk:container:nodejs:
NodeCommand: "node app.js"
77 changes: 77 additions & 0 deletions sa-bulkagentget/.ebextensions/proxy.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
files:
/etc/nginx/conf.d/proxy.conf:
mode: "000644"
owner: root
group: root
content: |
upstream nodejs {
server 127.0.0.1:9000;
keepalive 256;
}

server {
listen 8080;

if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
access_log /var/log/nginx/access.log main;


location /test_network {
proxy_pass http://google.com;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /bulk_get_agents {
proxy_pass http://nodejs;
#proxy_set_header Connection "";
#proxy_http_version 1.1;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location / {
#proxy_pass https://search-dev-labs-es-dp4hrexo76bt3sae4g3kvlj764.us-east-1.es.amazonaws.com;
#proxy_pass https://search-tritonshare-me7ebfktbk6jd7tssx4j52oazq.us-east-1.es.amazonaws.com;
proxy_pass https://vpc-tritonshare-vpc-42l37f74bf3putl5imbvvvmw6i.us-east-1.es.amazonaws.com;
client_max_body_size 20M;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

gzip on;
gzip_comp_level 4;
gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

location /static {
alias /var/app/current/static;
}

}

/opt/elasticbeanstalk/hooks/configdeploy/post/99_kill_default_nginx.sh:
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash -xe
rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
service nginx stop
service nginx start

container_commands:
removeconfig:
command: "rm -f /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf"
5 changes: 5 additions & 0 deletions sa-bulkagentget/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
6 changes: 6 additions & 0 deletions sa-bulkagentget/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:alpine
LABEL maintainer="Joshua Bird ([email protected])"

COPY app.js /srv/tritonshare/app.js

CMD node --experimental-modules /srv/tritonshare/app.js
117 changes: 117 additions & 0 deletions sa-bulkagentget/app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import http from "http";
import https from "https";


const PORT=9000;


const requestAgent = agentId => {

return new Promise(resolve => {

console.log("sending request");
console.log(agentId)

const subreq = https.request({
hostname: "share.osf.io",
method: "GET",
path: "/api/v2/search/agents/" + agentId
}, subresp => {
console.log("response");
var body = ""; // var intentional.

subresp.on("data", chunk => {
console.log("data")
if (chunk) {
body += chunk;
}
});

subresp.on("end", () => {
console.log(body);
if (!body) {
console.error();
return;
}
resolve(JSON.parse(body));
});
});

subreq.on("error", (e) => {
console.log("got error: " + e.message);
resolve({});
});

subreq.end();

});

};

const requestAgentDetails = agentIds => {

return Promise.all(agentIds.map(

item => new Promise(async resolve => {

const agentId = item.key;
console.log("Requesting: " + agentId);

const agent = await requestAgent(agentId);
console.log("agent");
console.log(agent)

if (!agent._source) {
agent._source = {
name: "",
id: agentId,
sources: [],
location: "",
identifiers: [],
type: "",
types: []
};
}

agent._source.number = item.doc_count;
if (item.awards) {
agent._source.awards = item.awards;
}

resolve(agent._source);

})

));

};

http.createServer((req, resp) => {

if (req.method == "POST") {

var body = "";

req.on("data", data => {
body += data;
if (body.length > 1e6) { // Too much POST data, kill the connection!
req.connection.destroy();
}
});

req.on("end", async () => {
const agentIds = JSON.parse(body);
const agentDetails = await requestAgentDetails(agentIds);
resp.end(JSON.stringify(agentDetails));
});

} else {
resp.end("It Works!! Path Hit: " + req.url);
}

}).listen(PORT, () => {

console.log("Server listening on: http://localhost:%s", PORT);

});

1 change: 1 addition & 0 deletions sa-dashboard-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This backend to store and persist dashboard layouts is under development.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading