During the play.node() conf earlier this week in Korea, Charlie took the stage and released our newest open source module. We're excited to introduce pkgcloud!
Pkgcloud is a node.js module that allows interaction with multiple cloud service providers. With the help of this module, you're able to manage a variety of cloud resources from within your application. You can provision compute, storage or database instances with ease.
IaaS providers have each chosen their own vocabulary for describing the resources they provide, leading to inconsistencies in terminology from one to the next. One of the objectives of pkgcloud is to maintain a unified vocabulary and use a regular terminology for applications without users needing to know which term was chosen by which provider. This is part of our ongoing efforts to be Infrastructure Agnostic.
Complete Docs
You can check out the full pkgcloud documentation on Github right here.
Looking for an overview? Keep scrolling.
Vocabulary
Here's how the unified vocabulary for pkgcloud breaks down.
Compute
| pkgcloud | OpenStack | Joyent | Amazon |
|---|---|---|---|
| Server | Server | Machine | Instance |
| Image | Image | Dataset | AMI |
| Flavor | Flavor | Package | InstanceType |
Storage
| pkgcloud | OpenStack | Amazon |
|---|---|---|
| Container | Container | Bucket |
| File | StorageObject | Object |
Getting Started
First install the library from NPM
npm install pkgcloud
Once it is installed, you can use it from your code.
var pkgcloud = require('pkgcloud');
At present pkgcloud supports: compute, storage and database as available resources. You can create a client to provision and control resources from your favorite provider. For client initialization, you will need the authentication info used by your provider, like username and password.
Compute
var joyentOpts = {
provider: 'joyent',
username: 'daniel',
password: '1234'
// Also you can use key/keyId as authentication
};
var rackspaceOpts = {
provider: 'rackspace',
auth: 'yourTokenForRackspace'
};
var amazonOpts = {
provider: 'amazon',
keyId: 'YourKeyId',
key: 'yourkey'
};
//
// Now you can create your client with your config
//
var joyentClient = pkgcloud.compute.createClient(joyentOpts), // Joyent CloudAPI client
rackspaceClient = pkgcloud.compute.createClient(rackspaceOpts), // Rackspace Cloud Servers client
amazonClient = pkgcloud.compute.createClient(amazonOpts); // AWS EC2 client
Storage
You could also use the same config for storage resources
var amazonClient = pkgcloud.storage.createClient(amazonOpts), // AWS S3 client
rackspaceClient = pkgcloud.storage.createClient(rackspaceOpts); // Rackspace Cloud Files client
After creating the client, depending on the chosen provider, pkgcloud will offer some methods for interaction. For detailed information about those methods, please see the complete documentation on github.
Databases
Database Providers supported:
- IrisCouch (Couchdb and redis databases)
- MongoLab (Mongodb databases)
- MongoHQ (Mongodb databases)
- RedisToGo (Redis databases)
- Rackspace (MySQL databases)
As in the previous examples, you will just need to define a few options that include the provider's name in the provider field and the necessary authentication fields.
var client = pkgcloud.database.createClient(options);
Pleease refer to github for further information about which methods are available for which provider.
A realistic example
Using the newly created joyentClient, we will provision some compute instances.
var flavor, image;
joyentClient.getFlavors(function (err, flavors) {
// Choose the flavor (memory, disk, swap)
flavor = flavors.shift();
joyentClient.getImages(function (err, images) {
// Choose the pre-build image
image = images.shift();
// Provision a new machine called 'test-server'
joyentClient.createServer({
flavor: flavor,
image: image,
name: 'test-server'
}, function (err, server) {
// Now look the details of your new provisioned server
console.log(server);
});
});
});
Roadmap
- Backport latest fixes from
node-cloudfilesandnode-cloudservers - Include
CDNandDNSservices. - Implement
fscompatible file API. - Support additional service providers.
Thinking about Contributing?
We welcome contributions to pkgcloud by any and all individuals or organizations.
Before contributing, please take a look at the Contribution Guidelines. We are pretty flexible about these guidelines, but the more closely you follow them, the more likely we are to merge your pull-request.
SO COME ON, WHAT ARE YOU WAITING FOR?