9.1.22 • Published 4 years ago

kit-deployer v9.1.22

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

kit-deployer

DEPRECATED Thanks for using this package, but we will no longer support it.

Codeship Status for InVisionApp/kit-deployer Build Status Docker Repository on Quay npm version Dependency Status devDependency Status

Use this service to deploy files to multiple Kubernetes clusters. You just have to organize your manifest files into directories that match the names of your clusters (the name defined in your kubeconfig files). Then you just provide a directory of kubeconfig files and the kit-deployer will asynchronously send all manifests up to their corresponding clusters.

There is also support for namespaces. Simply provide a directory with namespaces that are grouped into folders that match the name of the kubeconfig cluster you want them deployed to.

The kit-deployer service was designed to work for a CI type service like Codeship where it can be run as a docker image as part of your automated workflow. However, you can also use it as an npm module or as a CLI tool directly.

Use as Docker Image

docker run quay.io/invision/kit-deployer --help

We recommend using kit components with Codeship's Docker Infrastructure, however you are free to run this tool however way you wish. Anything that has Docker can run this image.

Using as CLI

You can run the ./src/deployer --help to see how it works.

Note this method requires node and was tested on version 5.5.0.

Using as npm module

Use npm to install kit-deployer:

$ npm install kit-deployer --save

Then require it and use it like so:

var Deployer = require("kit-deployer").Deployer;

var options = {
	sha: "c6350f4c2709708b8f784408a440030e704b2b9a",
	dryRun: true,
	diff: true,
	github: {
		token: "<OAUTH_TOKEN_HERE>",
		user: "chesleybrown",
		repo: "my-app"
	}
};

var deployer = new Deployer(options);

// setup logging of events
deployer.on("info", function(message) {
	console.log(message);
});
deployer.on("warn", function(message) {
	console.log(message);
});
deployer.on("error", function(message) {
	console.log(message);
});
deployer.on("fatal", function(message) {
	console.log(message);
});
deployer.on("status", function(status) {
	console.log(status);
});
deployer.on("progress", function(progress) {
	console.log(progress);
});

deployer
	.deploy("/configs/**/kubeconfig", "/manifests", "/namespaces")
	.then(console.log)
	.catch(console.error)
	.done();

Note this method requires node and was tested on version 5.5.0.

Progress

The progress event emits whenever a cluster was successfully deployed to or failed deploying. It will tell you how many clusters are left, how many had issues being deployed to and what these clusters were. This is what the object looks like. Information is purposely made redundant for easier logging where needed.

{
  "percent": 0.5,
  "clusters": {
    "total": 4,
    "completed": 2,
    "found": [
      "cluster-1",
      "cluster-2",
      "cluster-3",
      "cluster-4"
    ],
    "remaining": [
      "cluster-2",
      "cluster-3"
    ],
    "successful": [
      "cluster-1",
      "cluster-2"
    ],
    "failed": []
  }
}

Namespaces

To create a Namespace within a given cluster, simply provide the namespace files within a directory matching the name of the cluster. So if you had a cluster called my-cluster, you could place the following contents into a file called ./namespaces/my-cluster/example-namespace.yaml.

apiVersion: v1
kind: Namespace
metadata:
  name: example

Manifests

All manifest files should be placed into directories corresponding to the name of the cluster + namespace they are for. So for example, if you wanted to deploy manifests to a cluster called my-cluster, you could place all the manifest files into ./manifests/my-cluster/**/*.yaml.

Reserved Labels

The following labels are dynamically generated and managed by kit for all manifests. They should not be manually set and if they are an error will be thrown halting the deploy.

  • id
  • strategy

Required Labels

The following labels must be set on Deployment manifests and on the labels for the pod template within the Deployment manifest.

  • name

Supported Types

Currently we only properly support the following types to be used as manifests. Any other type used will not be deployed and will display a warning:

  • Deployment
  • Job
  • Secret
  • Service
  • DaemonSet
  • PersistentVolumeClaim

Order of Deploys (beta)

NOTE: this feature is a work in progress and may not function correctly

By default, all manifests are deployed to a given cluster at the same time. If however you require manifests to be deployed in a specific order you can utilize the "dependency-selector". By specifying a manifest with dependencies on other resources, the deployer will only deploy that manifest once those other services are fully available on the cluster.

You can specify dependencies using a metadata annotation called kit-deployer/dependency-selector. It should be a valid label selector. For example:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: proxy-deployment
  annotations:
    kit-deployer/dependency-selector: database=mongo,env=prod

Supported Dependency Types

Currently we only properly support the following types to be used as dependencies:

  • Deployment
  • Job
  • Secret
  • Service

Manifest backup

With BACKUP_ENABLED set to true each manifest will be backed up to the specified S3 bucket with the path /AWS_BUCKET/cluster-name/manifest after the manifest has been deployed. By default files can be backed up as yaml or json format - yaml is the default.

Expected environment variables

The following environment variables are used by this service.

VariableDescriptionRequiredDefault
API_VERSIONThe kubernetes api version to useyesv1
CI_COMMIT_IDThe commit sha that we are deploying. Needed if GITHUB_ENABLED=truenoempty
SELECTORSelector (label query) to filter onnoempty
CONFIGSSet the pattern to search for cluster config filesyes/configs/**/kubeconfig
NAMESPACES_DIRSet the directory where all the namespace files are. They should be grouped in folders matching the metadata.name of the cluster that you want them deployed toyes/namespaces
MANIFESTS_DIRSet the directory where all the manifest files are. They should be grouped in folders matching the metadata.name of the cluster that you want them deployed toyes/manifests
DRY_RUNWill only show the diff and will not push anything to the clusteryestrue
UUIDA UUID to be used in webhooks and API requestsfalseempty
DEPLOY_IDA unique id to be used in deploymentsfalseempty
STRATEGYThe deployment strategy to use. Currently supports rolling-update, fast-rollback.falserolling-update
RESOURCEThe resource name for the manifests being deployedfalseempty
DEBUGA boolean flag to enable debug modeyesfalse
IS_ROLLBACKA boolean flag that is passed in the available payload postyesfalse
DIFFWill show a diffyesfalse
FORCEWill push all changes even if there are no differencesyesfalse
CREATE_ONLYWill only create resources that don't already exist. Will not perform any updates or removals.yesfalse
RAWWill not perform any alterations to the manifest and simply deploy them as isyesfalse
BACKOFF_FAIL_AFTERMaximum number of backoffs before the call is abortedyes10
BACKOFF_INITIAL_DELAYThe initial delay when starting to backoff in msyes1000
BACKOFF_MAX_DELAYThe maximum delay when doing a backoff in msyes30000
AVAILABLE_ENABLEDWill check if deployed service is available, but will only affect if deployment is considered successful or not if --available-required is also enabledyesfalse
AVAILABLE_POLLING_INTERVALThe number of seconds to wait between status checking API requestsyesfalse
AVAILABLE_HEALTH_CHECKWill monitor for issues during the deploymentyestrue
AVAILABLE_HEALTH_CHECK_GRACE_PERIODThe amount of time in seconds that the health check will wait for a deployment to self-heal before triggering a failureyes10
AVAILABLE_HEALTH_CHECK_THRESHOLDThe number times a particular error event can occur before triggering a failureyes0
AVAILABLE_HEALTH_CHECK_IGNORED_ERRORSErrors that the built in healthchecker will ignoreyesempty
AVAILABLE_WEBHOOKThe URL you want to send the status payload of the deployment progress to. You can provide multiple endpoints by using a JSON array of URLsnoempty
AVAILABLE_ALLWhen enabled it will check if all manifests are available even if no differences were deployedyesfalse
AVAILABLE_REQUIREDWill only finish once the manifest is considered available in the clusteryesfalse
AVAILABLE_KEEP_ALIVEWill print the status of the available check every AVAILABLE_KEEP_ALIVE_INTERVAL seconds (useful for CI tools that require log output to prevent timeouts)yesfalse
AVAILABLE_KEEP_ALIVE_INTERVALDetermines the interval at which the keep alive message will be printedyes30
AVAILABLE_TIMEOUTThe number of seconds to wait for a given manifest to be availableyes600
DEPENDENCY_WAITThe number of seconds to wait between status check attempts for a dependencyyes3
DEPENDENCY_TIMEOUTThe number of seconds to wait before timing out waiting for a dependency to be availableyes600
GITHUB_ENABLEDIf true, will check the date of the commit against github and will only deploy if the commit is newer than what is on the cluster.yestrue
GITHUB_AUTH_TOKENYour github token to the repo we are deploying (used to retrieve additional info on the commit)yesempty
GITHUB_USERThe github user that the repo belongs toyesempty
GITHUB_REPOThe github repo nameyesempty
BACKUP_ENABLEDEnable Backups to AWS S3nofalse
SAVE_FORMATFormat to save backup manifest as (jsonyaml)noyaml
AWS_BUCKETAWS s3 bucket name to save toyesempty
AWS_ACCESS_KEY_IDAWS User key to useyesempty
AWS_SECRET_ACCESS_KEYAWS User Secret to useyesempty

Contributing

See the Contributing guide for steps on how to contribute to this project.

9.1.22

4 years ago

9.1.21

5 years ago

9.1.20

5 years ago

9.1.19

5 years ago

9.1.18

5 years ago

9.1.17

5 years ago

9.1.16

6 years ago

9.1.15

6 years ago

9.1.14

6 years ago

9.1.13

6 years ago

9.1.12

6 years ago

9.1.11

6 years ago

9.1.10

6 years ago

9.1.9

6 years ago

9.1.8

6 years ago

9.1.7

6 years ago

9.1.6

6 years ago

9.1.5

6 years ago

9.1.4

6 years ago

9.1.3

6 years ago

9.1.2

6 years ago

9.1.1

6 years ago

9.1.0

6 years ago

9.0.0

6 years ago

8.10.1

6 years ago

8.10.0

6 years ago

8.9.0

7 years ago

8.8.5

7 years ago

8.8.4

7 years ago

8.8.3

7 years ago

8.8.2

7 years ago

8.8.1

7 years ago

8.8.0

7 years ago

8.7.0

7 years ago

8.6.2

7 years ago

8.6.1

7 years ago

8.6.0

7 years ago

8.5.0

7 years ago

8.4.1

7 years ago

8.4.0

7 years ago

8.3.3

7 years ago

8.3.2

7 years ago

8.3.1

7 years ago

8.3.0

7 years ago

8.2.0

7 years ago

8.1.0

7 years ago

8.0.1

7 years ago

8.0.0

7 years ago

7.15.2

7 years ago

7.15.1

7 years ago

7.15.0

7 years ago

7.14.1

7 years ago

7.14.0

7 years ago

7.13.2

7 years ago

7.13.1

7 years ago

7.13.0

7 years ago

7.12.1

7 years ago

7.12.0

7 years ago

7.11.1

7 years ago

7.11.0

7 years ago

7.10.7

7 years ago

7.10.6

7 years ago

7.10.5

7 years ago

7.10.4

7 years ago

7.10.3

7 years ago

7.10.2

7 years ago

7.10.1

7 years ago

7.10.0

7 years ago

7.9.0

7 years ago

7.8.1

7 years ago

7.8.0

7 years ago

7.7.1

7 years ago

7.7.0

7 years ago

7.6.0

7 years ago

7.5.4

7 years ago

7.5.3

7 years ago

7.5.2

7 years ago

7.5.1

7 years ago

7.5.0

7 years ago

7.4.4

7 years ago

7.4.3

7 years ago

7.4.2

7 years ago

7.4.1

7 years ago

7.4.0

7 years ago

7.3.0

7 years ago

7.2.2

7 years ago

7.2.1

7 years ago

7.2.0

7 years ago

7.1.0

7 years ago

7.0.2

7 years ago

7.0.1

7 years ago

7.0.0

8 years ago

6.9.1

8 years ago

6.9.0

8 years ago

6.8.0

8 years ago

6.7.0

8 years ago

6.6.1

8 years ago

6.6.0

8 years ago

6.5.0

8 years ago

6.4.0

8 years ago

6.3.1

8 years ago

6.3.0

8 years ago

6.2.5

8 years ago

6.2.4

8 years ago

6.2.3

8 years ago

6.2.2

8 years ago

6.2.1

8 years ago

6.2.0

8 years ago

6.1.0

8 years ago

6.0.9

8 years ago

6.0.8

8 years ago

6.0.7

8 years ago

6.0.6

8 years ago

6.0.5

8 years ago

6.0.4

8 years ago

6.0.3

8 years ago

6.0.2

8 years ago

6.0.1

8 years ago

6.0.0

8 years ago

1.0.0

8 years ago