diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e0d3627
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,73 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# nyc test coverage
+.nyc_output
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directories
+node_modules/
+jspm_packages/
+
+# TypeScript v1 declaration files
+typings/
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Optional REPL history
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn Integrity file
+.yarn-integrity
+
+# dotenv environment variables file
+.env
+
+# parcel-bundler cache (https://parceljs.org/)
+.cache
+
+# next.js build output
+.next
+
+# nuxt.js build output
+.nuxt
+
+# vuepress build output
+.vuepress/dist
+
+# Serverless directories
+.serverless
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..e69de29
diff --git a/Dockerfile-dev b/Dockerfile-dev
new file mode 100644
index 0000000..bb7795c
--- /dev/null
+++ b/Dockerfile-dev
@@ -0,0 +1,10 @@
+FROM node:8
+WORKDIR /usr/src/app
+ADD package.json .
+
+RUN npm install
+RUN npm install -g nodemon
+
+EXPOSE 3000
+
+ENTRYPOINT ["nodemon", "server.js"]
\ No newline at end of file
diff --git a/config.js b/config.js
new file mode 100644
index 0000000..636ae5f
--- /dev/null
+++ b/config.js
@@ -0,0 +1,6 @@
+module.exports = {
+ HOST: process.env.HOST || "0.0.0.0",
+ PORT: process.env.PORT || 3000,
+ REDIS_URI: process.env.REDIS_URI,
+ ENV: process.env.ENV || "dev",
+}
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..89ed5e9
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,25 @@
+version: "3"
+networks:
+ chat:
+
+services:
+ # Redis for socket.io message broker
+ redis:
+ image: redis
+ ports:
+ - 6379:6379
+
+ # The application image
+ app:
+ depends_on:
+ - redis
+ build:
+ context: .
+ dockerfile: Dockerfile-dev
+ volumes:
+ - .:/usr/src/app
+ environment:
+ ENV_NAME: dev
+ REDIS_URI: redis
+ ports:
+ - 3000:3000
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..e1af72d
--- /dev/null
+++ b/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "rtn-k8s",
+ "version": "1.0.0",
+ "description": "",
+ "main": "index.js",
+ "dependencies": {
+ "express": "^4.16.3",
+ "socket.io": "^2.1.1"
+ },
+ "devDependencies": {},
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1;"
+ },
+ "author": "Ahmad Faiyaz",
+ "license": "MIT"
+}
diff --git a/public/index.html b/public/index.html
new file mode 100644
index 0000000..2120605
--- /dev/null
+++ b/public/index.html
@@ -0,0 +1,62 @@
+
+
+
+
+
+ Real Time Notification - K8S
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
You are Danger connected to server!
+
+
You have {{ notification_count }} new notifications
+
+
+
+
+
+
+
+
+ Some extra information
+ |
+
+
+
+
+
+ User Id |
+ {{ user_id }} |
+
+
+ Server hostname |
+ {{ server_hostname }} |
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/main.css b/public/main.css
new file mode 100644
index 0000000..e69de29
diff --git a/public/main.js b/public/main.js
new file mode 100644
index 0000000..6f9bc45
--- /dev/null
+++ b/public/main.js
@@ -0,0 +1,45 @@
+
+var app = new Vue({
+ el: "#app",
+ data: {
+ connection_status: null,
+ user_id: null,
+ server_hostname : null,
+ notification_count : 0,
+ },
+ methods: {
+ markAllRead: function(){
+ this.notification_count = 0;
+ },
+ generateNotification: function(){
+ axios.post('/notify', {
+ user_id: this.user_id
+ }).then(function(data){
+ toastr["success"]("Notification generated!");
+ });
+ },
+ updateData(data){
+ if(data.user_id == this.user_id){
+ return;
+ }
+ this.notification_count += 1;
+ toastr["info"]("from user: " + data.user_id, "New notification!");
+ }
+ }
+});
+
+var notification_channel = 'notification_channel';
+var socket = io();
+
+socket.on('connect', () => {
+ app.connection_status = socket.connected;
+ app.user_id = socket.id;
+});
+
+socket.on('initial_data', function(data){
+ app.server_hostname = data.server_hostname;
+});
+
+socket.on(notification_channel, function(data){
+ app.updateData(data);
+});
\ No newline at end of file
diff --git a/server.js b/server.js
new file mode 100644
index 0000000..d7a8f44
--- /dev/null
+++ b/server.js
@@ -0,0 +1,60 @@
+// Setup basic express server
+var os = require('os')
+var bodyParser = require('body-parser');
+var express = require('express');
+var path = require('path');
+
+var config = require('./config');
+
+var app = express();
+app.use(bodyParser.json()); // for parsing application/json
+
+
+var server = require('http').createServer(app);
+var io = require('socket.io')(server);
+
+// for serving the static client files
+app.use(express.static(path.join(__dirname, 'public')));
+
+app.get('/', function (req, res) {
+ res.sendfile(__dirname + 'public/index.html');
+});
+
+
+var notification_channel = 'notification_channel';
+
+io.on('connection', function(socket) { // new user connected
+ var data = {
+ "server_hostname": os.hostname()
+ }
+
+ socket.emit("initial_data", data);
+});
+
+app.post('/notify', function(req, res){
+ console.log("Got a request from client to notify");
+
+ var dt = new Date();
+ var utcDate = dt.toUTCString();
+
+ var emit_data = {
+ user_id: req.body.user_id,
+ server_timestamp: utcDate,
+ }
+ io.sockets.emit(notification_channel,emit_data);
+
+ res.send("done!");
+});
+
+
+server.listen(config.PORT, config.HOST, function() {
+ console.log('Server listening at %s:%d', config.HOST, config.PORT);
+});
+
+process.on('SIGTERM', function() {
+ console.log('Received SIGTERM, shutting down server');
+ server.close();
+ process.exit(0);
+});
+
+