aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.dockerignore2
-rw-r--r--README.md15
-rw-r--r--k8s/db.yaml8
-rw-r--r--k8s/mi.yaml68
-rw-r--r--mi-gateway/Dockerfile14
-rw-r--r--mi-gateway/package.json11
-rw-r--r--mi-gateway/server.js31
-rw-r--r--mi-processor/Dockerfile14
-rw-r--r--mi-processor/package.json11
-rw-r--r--mi-processor/server.js16
10 files changed, 190 insertions, 0 deletions
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..93f1361
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,2 @@
+node_modules
+npm-debug.log
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..2e748e3
--- /dev/null
+++ b/README.md
@@ -0,0 +1,15 @@
+ gcloud init
+ gcloud container clusters get-credentials standard-cluster-1
+
+ docker build -t trygvis/mi-gateway mi-gateway
+ docker push trygvis/mi-gateway
+ kubectl set image deployment mi-gateway-deployment mi-gateway=$(docker inspect --format='{{index .RepoDigests 0}}' trygvis/mi-gateway)
+
+ docker build -t trygvis/mi-processor mi-processor
+ docker push trygvis/mi-processor
+ kubectl set image deployment mi-processor-deployment mi-processor=$(docker inspect --format='{{index .RepoDigests 0}}' trygvis/mi-processor)
+
+Secrets
+
+ echo -n $password | base64
+ kubectl exec -it mi-gateway-pod -- /bin/bash
diff --git a/k8s/db.yaml b/k8s/db.yaml
new file mode 100644
index 0000000..e62ff52
--- /dev/null
+++ b/k8s/db.yaml
@@ -0,0 +1,8 @@
+---
+apiVersion: v1
+kind: Secret
+metadata:
+ name: membership-import-admin
+data:
+ username: cG9zdGdyZXM=
+ password: ZGlxODJ5REQ3b3hFSVA1Zw==
diff --git a/k8s/mi.yaml b/k8s/mi.yaml
new file mode 100644
index 0000000..2d1dcb7
--- /dev/null
+++ b/k8s/mi.yaml
@@ -0,0 +1,68 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: mi-processor-deployment
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: mi-processor-pod
+ template:
+ metadata:
+ labels:
+ app: mi-processor-pod
+ spec:
+ containers:
+ - name: mi-processor
+ image: trygvis/mi-processor:latest
+ ports:
+ - containerPort: 8080
+ volumeMounts:
+ - name: pgpass
+ mountPath: /secret/pgpass
+ volumes:
+ - name: pgpass
+ secret:
+ secretName: membership-import-admin
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: mi-gateway-deployment
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: mi-gateway-pod
+ template:
+ metadata:
+ labels:
+ app: mi-gateway-pod
+ spec:
+ containers:
+ - name: mi-gateway
+ image: trygvis/mi-gateway:latest
+ ports:
+ - containerPort: 8080
+ volumeMounts:
+ - name: pgpass
+ mountPath: /secret/pgpass
+ volumes:
+ - name: pgpass
+ secret:
+ secretName: membership-import-admin
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: mi-gateway-service
+spec:
+ selector:
+ app: mi-gateway-pod
+ type: LoadBalancer
+ ports:
+ - protocol: TCP
+ port: 80
+ targetPort: 8080
diff --git a/mi-gateway/Dockerfile b/mi-gateway/Dockerfile
new file mode 100644
index 0000000..d657cc3
--- /dev/null
+++ b/mi-gateway/Dockerfile
@@ -0,0 +1,14 @@
+FROM node:8
+
+WORKDIR /opt
+
+COPY package*.json ./
+
+RUN npm install
+# If you are building your code for production
+# RUN npm ci --only=production
+
+COPY . .
+
+EXPOSE 8080
+CMD [ "npm", "start" ]
diff --git a/mi-gateway/package.json b/mi-gateway/package.json
new file mode 100644
index 0000000..2deee39
--- /dev/null
+++ b/mi-gateway/package.json
@@ -0,0 +1,11 @@
+{
+ "name": "mi-gateway",
+ "version": "1.0.0",
+ "main": "server.js",
+ "scripts": {
+ "start": "node server.js"
+ },
+ "dependencies": {
+ "express": "^4.16.1"
+ }
+}
diff --git a/mi-gateway/server.js b/mi-gateway/server.js
new file mode 100644
index 0000000..4d2546f
--- /dev/null
+++ b/mi-gateway/server.js
@@ -0,0 +1,31 @@
+'use strict';
+
+const express = require('express');
+
+const PORT = 8080;
+const HOST = '0.0.0.0';
+
+const app = express();
+app.get('/', (req, res) => {
+ res.send('mi-gateway 2\n');
+});
+
+app.listen(PORT, HOST);
+console.log(`Running on http://${HOST}:${PORT}`);
+
+var keys = [];
+for(var key in process.env) {
+ if (key.startsWith("npm")) {
+ continue;
+ }
+
+ keys[keys.length] = key;
+}
+keys.sort()
+
+console.log("ENV");
+for (var idx in keys) {
+ const key = keys[idx];
+ const value = process.env[key];
+ console.log(" " + key + "=" + value);
+}
diff --git a/mi-processor/Dockerfile b/mi-processor/Dockerfile
new file mode 100644
index 0000000..d657cc3
--- /dev/null
+++ b/mi-processor/Dockerfile
@@ -0,0 +1,14 @@
+FROM node:8
+
+WORKDIR /opt
+
+COPY package*.json ./
+
+RUN npm install
+# If you are building your code for production
+# RUN npm ci --only=production
+
+COPY . .
+
+EXPOSE 8080
+CMD [ "npm", "start" ]
diff --git a/mi-processor/package.json b/mi-processor/package.json
new file mode 100644
index 0000000..2deee39
--- /dev/null
+++ b/mi-processor/package.json
@@ -0,0 +1,11 @@
+{
+ "name": "mi-gateway",
+ "version": "1.0.0",
+ "main": "server.js",
+ "scripts": {
+ "start": "node server.js"
+ },
+ "dependencies": {
+ "express": "^4.16.1"
+ }
+}
diff --git a/mi-processor/server.js b/mi-processor/server.js
new file mode 100644
index 0000000..b739070
--- /dev/null
+++ b/mi-processor/server.js
@@ -0,0 +1,16 @@
+'use strict';
+
+const express = require('express');
+
+const PORT = 8080;
+const HOST = '0.0.0.0';
+
+const app = express();
+app.get('/', (req, res) => {
+ res.send('mi-server\n');
+});
+
+app.listen(PORT, HOST);
+console.log(`Running on http://${HOST}:${PORT}`);
+
+console.log('Environment', process.env)