Orchestration is a set of utilities for Gulp that help you build and deploy versioned containers into clusters on cloud providers.
npm install orchestrationnpm install --save-dev to install:
package.json in your app. The name and version of package.json will be used for deployment.
orchestration.json file, which describes the files to include and the services that your application exposes:
javascript
{
"services": {
"development": [],
"production": [
{
"type": "LoadBalancer",
/ The external IP of the load balancer; reserve a static IP in your GCP console /
"ipAddress": "1.1.1.1",
"protocol": "TCP",
/ Unique name for the exposed service in your cluster /
"name": "my-service",
"containerPort": 8080,
"publicPort": 80
}
]
},
"files": [
/* Will be used in a future version, lists the files in your
app to copy to a Docker container */
"folder",
"file",
{ "env": "environment-name", "name": "environment-specific-file" },
]
}
`
Configuring your cluster
Create a cluster.json file, which describes the target cluster on Google Cloud:
`javascript
{
/ Type of deployment, only Kubernetes on Google Cloud is supported for now /
"type": "google-cloud-kubernetes",
/ List of side-by-side deployment environments to support /
"environments": {
"development": {
/ The GCP project for this environment /
"project": "example-dev",
/ The name of the GCP cluster for this environment /
"clusterName": "example-dev",
/ The zone of the GCP cluster for this environment /
"clusterZone": "us-central1-f",
/ The Docker image prefix to use for this environment /
"dockerImagePrefix": "gcr.io/example-dev/"
},
"production": {
"project": "example",
"clusterName": "example",
"clusterZone": "us-central1-f",
"dockerImagePrefix": "gcr.io/example/"
}
}
}
`
The AWS CloudFormation provider makes use of CloudFormation templates, and does not use cluster.json.
Usage
======
`javascript
var configuration = require('orchestration-configuration');
var swagger = require('orchestration-swagger');
var docker = require('orchestration-docker');
var node = require('orchestration-node');
var kubernetes = require('orchestration-kubernetes');
// IMPORTANT: Don't forget to add this line to your Gulp file!
var config = configuration.getConfiguration();
// e.g. to generate sdks based on presence of .json files in sdks/ folder:
gulp.task('swagger-sdks', function(callback) {
swagger.generateAllSdks(callback);
});
// e.g. to build a Docker container from the current folder:
gulp.task('build-docker', function(callback) {
// targets the 'development' environment
docker.build(config, 'development', callback);
});
// e.g. to run your Node.js app from within a Docker container:
gulp.task('test-docker', ['build-docker'], function(callback) {
// test in dev with 8080 mapped to 8001
// targets the 'development' environment
docker.testLocal(config, 'development', { 8001: 8080 }, callback);
});
// e.g. to run your Node.js app on your host machine:
gulp.task('test-host', ['build'], function(callback) {
node.test(callback);
});
// e.g. to deploy your Node.js app to a Kubernetes cluster in Google Cloud
gulp.task('deploy-prod', ['push-docker-prod'], function(callback) {
// targets the 'production' environment
kubernetes.deployToCluster(config, 'production', callback);
});
``