Skip to content

Commit

Permalink
MANTA-3552 create Triton Prometheus image
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Davis committed Apr 9, 2019
1 parent 290aca3 commit c75f9dd
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,4 +8,5 @@
/npm-debug.log
/sdcadm-*.sh
/tmp
/etc/sdcadm.completion
man/man1/sdcadm.1
5 changes: 5 additions & 0 deletions CHANGES.md
Expand Up @@ -10,6 +10,11 @@

# sdcadm Changelog

## 1.26.0

- MANTA-3552 Add `sdcadm post-setup prometheus` to setup a core Triton
Prometheus service.

## 1.25.3

- TRITON-1349 Subcommand `sdcadm post-setup kbmapi` using AddServiceProcedure
Expand Down
3 changes: 2 additions & 1 deletion etc/defaults.json
Expand Up @@ -46,7 +46,8 @@
"dockerlogger": "dockerlogger",
"volapi": "volapi",
"logarchiver": "logarchiver",
"kbmapi": "kbmapi"
"kbmapi": "kbmapi",
"prometheus": "prometheus"
},
"svcMinImages": {
"binder": "20140731T211135Z",
Expand Down
3 changes: 2 additions & 1 deletion lib/post-setup/index.js
Expand Up @@ -27,7 +27,7 @@ function PostSetupCLI(top) {
name: 'sdcadm post-setup',
desc: 'Common post-setup procedures.\n' +
'\n' +
'The default setup of a SmartDataCenter headnode is somewhat\n' +
'The default setup of a Triton Data Center headnode is somewhat\n' +
'minimal. "Everything up to adminui." Practical usage of\n' +
'SDC -- whether for production, development or testing --\n' +
'involves a number of common post-setup steps. This command\n' +
Expand Down Expand Up @@ -78,6 +78,7 @@ PostSetupCLI.prototype.do_cns = require('./cns').do_cns;
PostSetupCLI.prototype.do_volapi = require('./volapi').do_volapi;
PostSetupCLI.prototype.do_logarchiver = require('./logarchiver').do_logarchiver;
PostSetupCLI.prototype.do_kbmapi = require('./kbmapi').do_kbmapi;
PostSetupCLI.prototype.do_prometheus = require('./prometheus').do_prometheus;

// --- exports

Expand Down
139 changes: 139 additions & 0 deletions lib/post-setup/prometheus.js
@@ -0,0 +1,139 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

/*
* Copyright (c) 2019, Joyent, Inc.
*/

/*
* The 'sdcadm post-setup prometheus' CLI subcommand.
*/

var errors = require('../errors');
var AddServiceProc = require('../procedures/add-service').AddServiceProcedure;
var runProcs = require('../procedures').runProcs;

function do_prometheus(subcmd, opts, args, cb) {
var self = this;
if (opts.help) {
this.do_help('help', {}, [subcmd], cb);
return;
} else if (args.length > 0) {
cb(new errors.UsageError('too many args: ' + args));
return;
}

const svcName = 'prometheus';
const procOpts = {
svcName: svcName,
packageName: 'sdc_1024',
delegatedDataset: true,
networks: [
{name: 'admin'},
// Prometheus needs to be on the external to properly work with
// CMON's Triton service discovery and CNS -- at least until CNS
// support split horizon DNS to provide separate records on the
// admin network.
//
// Triton's Prometheus instances will therefore have a NIC on CMON's
// non-admin network. Currently by default that is the "external"
// network.
//
// A firewall will be setup on prometheus0 so that by default no
// inbound requests are allowed on that interface.
{name: 'external', primary: true}
],
firewallEnabled: true
};

if (opts.image) {
procOpts.image = opts.image;
}

if (opts.channel) {
procOpts.channel = opts.channel;
}

if (opts.server) {
procOpts.server = opts.server;
}

const proc = new AddServiceProc(procOpts);

runProcs({
log: self.log,
procs: [proc],
sdcadm: self.sdcadm,
ui: self.ui,
dryRun: opts.dry_run,
skipConfirm: opts.yes
}, cb);
}

do_prometheus.options = [
{
names: ['help', 'h'],
type: 'bool',
help: 'Show this help.'
},
{
names: ['yes', 'y'],
type: 'bool',
help: 'Answer yes to all confirmations.'
},
{
names: ['dry-run', 'n'],
type: 'bool',
help: 'Do a dry-run.'
},
{
names: ['server', 's'],
type: 'string',
help: 'Either hostname or uuid of the server on which to create' +
' the instance. (By default the headnode will be used.)',
helpArg: 'SERVER'
},
{
group: 'Image selection (by default latest image on default ' +
'channel)'
},
{
names: ['image', 'i'],
type: 'string',
help: 'Specifies which image to use for the first instance. ' +
'Use "latest" (the default) for the latest available on ' +
'updates.joyent.com, "current" for the latest image already ' +
'in the datacenter (if any), or an image UUID or version.'
},
{
names: ['channel', 'C'],
type: 'string',
help: 'The updates.joyent.com channel from which to fetch the ' +
'image. See `sdcadm channel get` for the default channel.'
}

];

do_prometheus.help = [
'Create the "prometheus" service and a first instance.',
'',
'Usage:',
' {{name}} prometheus',
'',
'{{options}}',
'The "prometheus" service monitors Triton components using the ' +
'Prometheus time-series database.'
].join('\n');

do_prometheus.logToFile = true;

// --- exports

module.exports = {
do_prometheus: do_prometheus
};

// vim: set softtabstop=4 shiftwidth=4:
1 change: 1 addition & 0 deletions lib/procedures/download-images.js
Expand Up @@ -30,6 +30,7 @@ function DownloadImages(options) {
assert.arrayOfObject(options.images, 'options.images');
assert.optionalString(options.channel, 'options.channel');
this.images = options.images;
this.channel = options.channel;
}
util.inherits(DownloadImages, Procedure);

Expand Down
3 changes: 2 additions & 1 deletion lib/procedures/index.js
Expand Up @@ -204,7 +204,8 @@ function coordinatePlan(opts, cb) {
var simpleServices = [
'amon', 'amonredis', 'assets', 'cnapi', 'cns', 'dhcpd',
'docker', 'fwapi', 'kbmapi', 'logarchiver', 'manta', 'napi',
'rabbitmq', 'redis', 'sdc', 'ufds', 'vmapi', 'volapi'
'prometheus', 'rabbitmq', 'redis', 'sdc', 'ufds', 'vmapi',
'volapi'
].concat(HA_READY_SIMPLE_SVCS);
var handle = [];
var remaining = [];
Expand Down
4 changes: 3 additions & 1 deletion lib/sdcadm.js
Expand Up @@ -3720,13 +3720,15 @@ SdcAdm.prototype.checkHealth = function checkHealth(opts, cb) {
vmapi: '/ping',
volapi: '/ping',
workflow: '/ping',
prometheus: '/-/healthy',
// agents
firewaller: '/status'
};

var pingPorts = {
cloudapi: 443,
firewaller: 2021
firewaller: 2021,
prometheus: 9090
};

// We can ping instances either when we checked for svcs health using
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "sdcadm",
"description": "Administer a SmartDataCenter (SDC) standup",
"version": "1.25.3",
"description": "Administer a Triton Data Center",
"version": "1.26.0",
"author": "Joyent (joyent.com)",
"private": true,
"dependencies": {
Expand Down
2 changes: 2 additions & 0 deletions tools/rsync-to
Expand Up @@ -41,3 +41,5 @@ for name in $toSync; do
fi
done
rsync -av ${TOP}/tools/rotate-logs.sh $NODE:$BASEDIR/tools/ $extraOpts

ssh $NODE "$BASEDIR/bin/sdcadm completion > $BASEDIR/etc/sdcadm.completion"

0 comments on commit c75f9dd

Please sign in to comment.