Web GUI – Administrating A Kubernetes Cluster I am working on a Web GUI to Administrate a Kubernetes Cluster. this includes all manipulation i.e. stats lookups, add, modify, deletes. all manipulations are using the official Kubernetes API’s. Details as well as the full code is available on my Github repository. In the next few weeks […]
Tag: nodejs
How to build nodejs on Solaris 11/12
1 2 3 4 5 |
env CC=gcc ./configure --prefix=/opt/node-v6.3.0 # for 8 cpu's gmake -j 8 gmake install |
Solaris NodeJS zone install and configuration
Solaris NodeJS zone install and configuration First, lets Compile NodJS from source, get the source from the NodeJS website. Something like the below should work to compile.
1 2 3 4 5 |
env CC=gcc ./configure --prefix=/opt/node-v6.2.2 # for 8 cpu's gmake -j 8 gmake install |
Next, lets modify the zone properties and distribute the compiled bundle to all the Solaris zones. Something like the below will work on 9 zones (from a […]
NodeJS and mongoose
npm install mongoose app.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
var express = require('express'); var os = require('os'); // Mongoose import var mongoose = require('mongoose'); // Mongoose connection to MongoDB (ted/ted is readonly) mongoose.connect('mongodb://127.0.0.1/users', function (error) { if (error) { console.log(error); } }); // Mongoose Schema definition var Schema = mongoose.Schema; var UserSchema = new Schema({ hostname: String, loadavrg: String, totalmem: String, freemem: String /* totalnetio: String, reacivenetio: String, transmitnetio: String, totaldiskio: String, readdiskio: String, writediskio: String */ }, {versionKey: false} ); // Mongoose Model definition var User = mongoose.model('users', UserSchema); function updateMonitor() { var os_monitor = new User({ hostname: os.hostname(), loadavrg: os.loadavg(), totalmem: os.totalmem(), freemem: os.freemem() }); os_monitor.save(function (err, os_monitor) { if (err) return console.error(err); console.dir(os_monitor); }); } var tid = setInterval(updateMonitor, 3000); // Bootstrap express var app = express(); // URLS management app.get('/', function (req, res) { res.send("<a href='/users'>Show Users</a>"); }); app.get('/users', function (req, res) { User.find({}, function (err, docs) { //console.log(docs); res.json(docs); }); }); app.get('/users/:email', function (req, res) { if (req.params.email) { User.find({email: req.params.email}, function (err, docs) { res.json(docs); }); } }); // Start the server app.listen(3000); |
References http://blog.modulus.io/getting-started-with-mongoose Getting Started with Mongoose and Node.js – A Sample Comments System https://www.airpair.com/javascript/complete-expressjs-nodejs-mongodb-crud-skeleton OS Monitor https://github.com/lfortin/node-os-monitor Better OS utility https://github.com/oscmejia/os-utils
Node JS and express
Bootstrap + nodejs http://lresende.blogspot.com/2015/01/nodejs-building-html-site-template.html
1 2 |
Express using EJS (not jade the default) express --ejs node_app2 |
In the Views > headers.ejs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <title><%= title %></title> <link rel='stylesheet' href='/stylesheets/style.css' /> <!-- Stylesheets --> <link href="/stylesheets/bootstrap.min.css" rel="stylesheet" type="text/css"/> <!-- Optional theme --> <link href="/stylesheets/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="../../assets/js/html5shiv.js"></script> <script src="../../assets/js/respond.min.js"></script> <![endif]--> </head> |
In the index.ejs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
<!DOCTYPE html> <html lang="en"> <% include header %> <body> <% include navbar %> <!-- Main jumbotron for a primary marketing message or call to action --> <div class="jumbotron"> <div class="container"> <h1>Hello, world!</h1> <p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p> <p> <a class="btn btn-primary btn-lg" role="button">Learn more »</a> </p> </div> </div> <div class="container"> <% include content %> <hr> <% include footer %> </div> <!-- /container --> <script type="text/javascript"> $(document).ready(function() { $('#home').addClass("active"); }); </script> <!-- Bootstrap core JavaScript ================================================== --> <!-- JavaScript --> <script src="/javascripts/jquery.min.js" type="text/javascript"></script> <script src="/javascripts/bootstrap.min.js" type="text/javascript"></script> </body> </html> |
in the navbar.ejs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<div class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#"><%= title %></a> </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li id="home"><a href="/">Home</a></li> <li id="about"><a href="/about">About</a></li> </ul> </div> <!--/.navbar-collapse --> </div> </div> |
In the content.ejs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<!-- Example row of columns --> <div class="row"> <div class="col-md-4"> <h2>Heading</h2> <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p> <p> <a class="btn btn-default" href="#" role="button">View details »</a> </p> </div> <div class="col-md-4"> <h2>Heading</h2> <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p> <p> <a class="btn btn-default" href="#" role="button">View details »</a> </p> </div> <div class="col-md-4"> <h2>Heading</h2> <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p> <p> <a class="btn btn-default" href="#" role="button">View details »</a> </p> </div> </div> |
In the footer.ejs
1 |
<footer>© Company 2015</footer> |
Reference NodeJS bootstrap howto Nodejs and express HowTo
Nodejs install
Download from linux binary from https://nodejs.org/download/ Extract node in /data/node
Nodejs Bootstrap and Express project
Configuring NodeJS, Express, and Bootstrap
1 |
npm install --save express-partials |
Initialize /install NodeJS express Module
1 |
npm install -g express-generator |
Create all need structure with express
1 |
express --ejs bootstrap/ |
Finally, install NodeJS modules
1 |
npm install |
Next, start NodeJS
1 |
npm start |
Note: If you are using Netbeans, to be able to start from within Netbeans, add the below to the package.json.
1 2 3 4 |
}, "main" : "bin/www", "dependencies" : { |
Auto-detect change module, used for auto […]
Setting Node JS / NPM Proxy
To make node js or npm work behind a firewall Get node compiled for Solaris from http://www.petertribble.co.uk/Solaris/node.html Note: after pkgadd, move Node to node. also modify this file /opt/node/lib/node_modules/npm/bin/npm-cli.js Disable strict ssl use
1 |
npm config set strict-ssl false |
Set the regstry to non https
1 |
npm config set registry http://registry.npmjs.org/ |
Verfy with npm config list Then to install
1 |
npm --proxy http://username:password@proxy.doamin.com:8080 install packagename |
Or by setting the proxy […]
How To Install Parsoid Module For MediaWiki
How to Install Parsoid module for MediaWiki Note: This article is kind of old. As of today any version of NodeJS should work – for Solairs you might need to compile from source, for details how to Buil NodeJS on Solaris click here. Must use node js versin 10.20 (not 10.28) Add make (or GNUmake) […]
How to configure mediawiki and VisualEditor with Parsoid
Configuring MediaWiki to use NodeJS and Parsoid Note: This post references an old version of NodeJS. You can install the latest version of NodeJS and self compile it. to do so, for full details just follow this post. First you need to download NodesJS, download from
1 |
http://nodejs.org/dist/v0.10.20/node-v0.10.20-sunos-x64.tar.gz |
Extract to /opt/node and add node to the […]