@atomist/k8-automation
Automations for deploying, updating, and removing resources in Kubernetes
Last updated a year ago by atomist .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @atomist/k8-automation 
SYNC missed versions from official npm registry.

@atomist/k8-automation

npm version Docker Pulls

This repository contains automations for deploying applications to Kubernetes using the Atomist API. Currently, deploying Docker images as deployments with optional services and ingress rules is supported.

This project uses the @atomist/automation-client and @atomist/sdm node modules to implement a local client that connects to the Atomist API and executes goals on behalf of a software delivery machine.

Prerequisites

Below are brief instructions on how to get started running this project yourself. If you just want to use the functionality this project provides, see the Atomist documentation.

Atomist workspace

You need an Atomist workspace. If you do not already have an Atomist workspace, you can sign up with Atomist at https://app.atomist.com/. See the Atomist User Guide for detailed instructions on how to sign up with Atomist.

Kubernetes

This automation works with Kubernetes, so you need a Kubernetes cluster with a functioning ingress controller, such as ingress-nginx.

If you do not have access to a Kubernetes cluster, you can create one on your local system using minikube. Once you have minikube running, you can create an ingress controller in the cluster using the ingress add-on.

$ minikube start
$ minikube addons enable ingress

Configuration

You can run k8-automation in either "cluster-wide" mode or "namespace-scoped" mode. In cluster-wide mode, k8-automation is able to deploy and update applications in any namespace but it requires a user with cluster-admin role privileges to install it. If you only have access to admin role privileges in a namespace, you can install k8-automation in namespace-scoped mode, where it will only be able to deploy and update resources in that namespace.

Running

See the Atomist Kubernetes documentation for detailed instructions on using Atomist with Kubernetes. Briefly, if you already have an Atomist workspace, you can run the following commands to create the necessary resources in your Kubernetes cluster. Replace WORKSPACE_ID with your Atomist workspace/team ID and TOKEN with a GitHub token with "read:org" scopes for a user within the GitHub organization linked to your Atomist workspace.

$ kubectl apply --filename=https://raw.githubusercontent.com/atomist/k8-automation/master/assets/kubectl/cluster-wide.yaml
$ kubectl create secret --namespace=k8-automation generic automation \
    --from-literal=config='{"teamIds":["WORKSPACE_ID"],"token":"TOKEN"}'

SDM interface

The KubeDeploy event handler triggers off an SDM Goal with the following properties:

JSON Path Value
fulfillment.name @atomist/k8-automation
fulfillment.method side-effect
state requested

In addition, it expects the SDM Goal to have a data property that when parsed as JSON has a kubernetes property whose value is an object with the following properties:

Property Required Description
name Yes Name of the resources that will be created
environment Yes Must equal the value of the running k8-automation instance's configuration.environment
ns No Namespace to create the resources in, default is "default"
imagePullSecret No Name of the Kubernetes image pull secret, if omitted the deployment spec is not provided an image pull secret
port No Port the container service listens on, if omitted the deployment spec will have no configured liveness or readiness probe and no service will be created
path No Absolute path under the hostname the ingress controller should use for this service, if omitted no ingress rule is created
host No Host name to use in ingress rule, only has effect if path is provided, if omitted when path is provided, the rule is created under the wildcard host
protocol No Scheme to use when setting the URL for the service endpoint, "https" or "http", default is "https" if tlsSecret is provided, "http" otherwise
replicas No Number of replicas (pods) deployment should have
tlsSecret No Name of existing Kubernetes TLS secret to use when configuring the ingress
deploymentSpec No Stringified JSON Kubernetes deployment spec to overlay on top of default deployment spec, it only needs to contain the properties you want to add or override from the default
serviceSpec No Stringified JSON Kubernetes service spec to overlay on top of default service spec, it only needs to contain the properties you want to add or override from the default

Support

General support questions should be discussed in the #support channel in our community Slack team at atomist-community.slack.com.

If you find a problem, please create an issue.

Development

Before developing this project, you will need to install Node.js and configure your environment.

Node.js

You will need to have Node.js installed. To verify that the right versions are installed, please run:

$ node -v
v9.7.1
$ npm -v
5.6.0

The node version should be 8 or greater and the npm version should be 5 or greater.

Cloning the repository and installing dependencies

To get started run the following commands to clone the project, install its dependencies, and build the project:

$ git clone git@github.com:atomist/k8-automation.git
$ cd k8-automation
$ npm install
$ npm run build

Configuring your environment

If this is the first time you will be running an Atomist API client locally, you should first configure your system using the atomist script:

$ `npm bin`/atomist config

The script does two things: records what Slack team you want your automations running in and creates a GitHub personal access token with "repo" and "read:org" scopes.

The script will prompt you for your Atomist workspace/team ID, or you can supply it using the --team TEAM_ID command-line option. You can get your Atomist team ID from the settings page for your Atomist workspace or by typing team in a DM to the Atomist bot.

The script will prompt you for your GitHub credentials. It needs them to create the GitHub personal access token. Atomist does not store your credentials and only writes the generated token to your local machine.

The Atomist API client authenticates using a GitHub personal access token. The Atomist API uses the token to confirm you are who you say you are and are in a GitHub organization connected to the Slack team in which you are running the automations. In addition, it uses the token when performing any operations that access the GitHub API.

Running locally

You can run this automation client locally, allowing you to change the source code of this project and immediately see the effects in your environment with the following command

$ npm run autostart

To run in a more traditional manner, build the project and then simple start it.

$ npm run build
$ npm start

To download and run the Docker image of this project, run the following command

$ docker run --rm -e GITHUB_TOKEN=YOUR_TOKEN -e ATOMIST_TEAMS=TEAM_ID \
    atomist/k8-automation:VERSION

replacing YOUR_TOKEN and TEAM_ID with the token and team ID from your ~/.atomist/client.config.json created by the atomist config command and VERSION with the latest release of this repo. Note that this will not be running any code from your local machine but the code in the Docker image.

Build and Test

Command Reason
npm install install all the required packages
npm run build lint, compile, and test
npm start start the Atomist automation client
npm run autostart run the client, refreshing when files change
npm run lint run tslint against the TypeScript
npm run compile compile all TypeScript into JavaScript
npm test run tests and ensure everything is working
npm run autotest run tests continuously
npm run clean remove stray compiled JavaScript files and build directory

Release

Releases are managed by the Atomist SDM. Press the "Release" button in the Atomist dashboard or Slack.


Created by Atomist. Need Help? Join our Slack team.

Current Tags

  • 1.0.0-master.20181007212944                                ...           branch-master (a year ago)
  • 0.9.0                                ...           latest (a year ago)

50 Versions

  • 1.0.0-master.20181007212944                                ...           a year ago
  • 1.0.0-master.20180829160736                                ...           a year ago
  • 0.9.1-20180808184713                                ...           a year ago
  • 0.9.1-20180808184413                                ...           a year ago
  • 0.9.1-20180804141551                                ...           a year ago
  • 0.9.0                                ...           a year ago
  • 0.9.0-20180803223231                                ...           a year ago
  • 0.9.0-20180803223018                                ...           a year ago
  • 0.9.0-20180803210939                                ...           a year ago
  • 0.9.0-20180803172723                                ...           a year ago
  • 0.9.0-20180802210016                                ...           a year ago
  • 0.8.1-20180725101723                                ...           a year ago
  • 0.8.1-20180606143023                                ...           2 years ago
  • 0.8.1-20180606142152                                ...           2 years ago
  • 0.8.0                                ...           2 years ago
  • 0.8.0-20180606141314                                ...           2 years ago
  • 0.8.0-20180605221641                                ...           2 years ago
  • 0.8.0-20180605192538                                ...           2 years ago
  • 0.8.0-20180529021029                                ...           2 years ago
  • 0.8.0-20180529012208                                ...           2 years ago
  • 0.8.0-20180528235257                                ...           2 years ago
  • 0.8.0-20180528163804                                ...           2 years ago
  • 0.8.0-20180522135337                                ...           2 years ago
  • 0.8.0-20180521205143                                ...           2 years ago
  • 0.8.0-20180519111510                                ...           2 years ago
  • 0.8.0-20180518230410                                ...           2 years ago
  • 0.8.0-20180518221907                                ...           2 years ago
  • 0.7.3                                ...           2 years ago
  • 0.7.2                                ...           2 years ago
  • 0.7.1                                ...           2 years ago
  • 0.7.0                                ...           2 years ago
  • 0.6.3                                ...           2 years ago
  • 0.6.2                                ...           2 years ago
  • 0.6.1                                ...           2 years ago
  • 0.6.0                                ...           2 years ago
  • 0.5.3                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
  • 0.5.1                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.6                                ...           2 years ago
  • 0.2.5                                ...           2 years ago
  • 0.2.4                                ...           2 years ago
  • 0.2.3                                ...           2 years ago
  • 0.2.2                                ...           2 years ago
  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 50
Last Day 0
Last Week 50
Last Month 151
Dependencies (11)
Dev Dependencies (21)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |