Giter Club home page Giter Club logo

fleetctl-ssh's Introduction

fleet-ssh

A Node.js API for CoreOS's fleetctl tool, implemented by simply remotely executing fleetctl over SSH. This means it will work within a Docker container on CoreOS, providing you have a host and key for your host machine, or any other node in the CoreOS cluster.

Inspired by the CoreOS scheduler in the Deis platform.

All commands in fleetctrl 0.5.0 are implemented with the exception of 'ssh', 'version' and 'help', and each command name maps directly to a method name in the API. Commands that have a hyphen are camel-cased (e.g. debug-info -> debugInfo).

All commands return a Node.js ChildProcess object, so you can easily pipe the results somewhere.

If you pass a callback it will buffer the stdout and return it in the first non-error argument. If you don't pass a callback to each API call, it will return the child process object so you can stream the I/O yourself.

Usage

To run against a CoreOS Vagrant cluster on your local machine:

var FleetAPI = require('fleet-ssh');
var fleet = new FleetAPI('127.0.0.1', {
  key: '/Users/lbond/.vagrant.d/insecure_private_key',
  port: 2222
};
fleet.cat('my-service').stdout.pipe(process.stdout);

fleetctl-ssh now supports the debug module. To get some debug output set the envvar DEBUG to fleetctl when you run your program that uses this module.

API

.cat(unitName)
Output the contents of a submitted unit.

.debugInfo()
Print out debug information.

.destroy(unitName)
Destroy one or more units in the cluster.

.journal(unitName, options)
Print the journal of a unit in the cluster to stdout.
Options:

  • follow Continuously print new entries as they are appended to the journal.
  • lines Number of recent log lines to return

.listMachines()
Enumerate the current hosts in the cluster.

.listUnits()
Enumerate units loaded in the cluster.

.load(unitName, options)
Schedule one or more units in the cluster, first submitting them if necessary. You must supply either one of the unitFile or unitFileData options, below.
Options:

  • unitFile The path to the unit file to load.
  • unitFileData The contents of the unit file itself, base64-encoded.
  • blockAttempts Wait until the jobs are loaded, performing up to N attempts before giving up. A value of 0 indicates no limit.
  • noBlock Do not wait until the jobs have been loaded before exiting.
  • sign Sign unit file signatures and verify submitted units using local SSH identities.

.start(unitName, options)
Instruct systemd to start one or more units in the cluster, first submitting and loading if necessary. You must supply either one of the unitFile or unitFileData options, below.
Options:

  • unitFile The path to the unit file to start.
  • unitFileData The contents of the unit file itself, base64-encoded.
  • blockAttempts Wait until the jobs are launched, performing up to N attempts before giving up. A value of 0 indicates no limit.
  • noBlock Do not wait until the jobs have been launched before exiting.
  • sign Sign unit file signatures using local SSH identities.

.status(unitFile)
Output the status of one or more units in the cluster

.stop(unitFile)
Instruct systemd to stop one or more units in the cluster.
Options:

  • blockAttempts Wait until the jobs are stopped, performing up to N attempts before giving up. A value of 0 indicates no limit.
  • noBlock Do not wait until the jobs have stopped before exiting.

.submit(unitFile, options)
Upload one or more units to the cluster without starting them. You must supply either one of the unitFile or unitFileData options, below.
Options:

  • unitFile The path to the unit file to submit.
  • unitFileData The contents of the unit file itself, base64-encoded.
  • sign Sign unit files units using local SSH identities

.unload(unitFile, options)
Unschedule one or more units in the cluster.
Options:

  • blockAttempts Wait until the jobs are inactive, performing up to N attempts before giving up. A value of 0 indicates no limit.
  • noBlock Do not wait until the jobs have become inactive before exiting.

.verify(unitFile)
Verify unit file signatures using local SSH identities.

Licence

MIT

fleetctl-ssh's People

Contributors

lukebond avatar sublimino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fleetctl-ssh's Issues

Start function do not work when working with a pool of CoreOs behind load-balancer(F5).

Hi Luke,
We have use your library in many cases and we are very pleased with the result.

All our development were done on a relative small setup in which we have access the remote Fleet directly.
We are deploying our product on large production setup with multiple CoreOS machines in the Fleet.
In order to provide redundancy in the Fleet we can not access any CoreOS machine directly and we need to use load balancer like F5.

In the large setup we have notice that sometimes the Start command is failing without any obvious reason.
When debugging the library we have notice that the Start fleet command was separated to 2 parts:

  1. scp command - copy the unit file to the remote machine.
  2. ssh & fleet start - start the unit file we have just copied.

because we work with load-balancer, we can not promise that these two commands will run on a same CoreOS machine. The use-case is as follow:
the unit-file was copied to one machine, and start command for this service were run on another machine ==> the unit-file wasn't found.

We have change the code to run the two commands in single SSH connection.

here is our change on our forked repository:
att-innovate@107b079
We would like you to add it to your library.

best regards,
Yehudit Shternfeld
Edan Shavit

Start shouldn't require local unit file

Forcing the use of fleetctl submit unitFile and fleetctl start unit for the start method is too limiting for my use. For my use case I need to be able to stop/start units without submitting a new unit file.
Would you be cool with a PR to add an option to bypass the submit step?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.