• This repository has been archived on 13/Jan/2021
  • Stars
    star
    287
  • Rank 144,232 (Top 3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Smith is a Kubernetes workflow engine / resource manager

Smith

Build Status Go Report Card

Smith is a Kubernetes workflow engine / resource manager.

It's functional and under active development.

News

  • 13.02.2019: A lot of changes went in and we are using it in production. Time for v2.
  • 01.01.2018: Milestone v1.0 is complete and v1.0.0 released!

The idea

What if we build a service that allows us to manage Kubernetes' built-in resources and other Custom Resources (CRs) in a generic way? Similar to how AWS CloudFormation (or Google Deployment Manager) allows us to manage any AWS/GCE and custom resource. Then we could expose all the resources we need to integrate as Custom Resources and manage them declaratively. This is an open architecture with Kubernetes as its core. Other controllers can create/update/watch CRs to co-ordinate their work/lifecycle.

Implementation

A group of resources is defined using a Bundle (just like a Stack for AWS CloudFormation). The Bundle itself is also a Kubernetes CR. Smith watches for new instances of a Bundle (and events to existing ones), picks them up and processes them.

Processing involves parsing the bundle, building a dependency graph (which is implicitly defined in the bundle), walking the graph, and creating/updating necessary resources. Each created/referenced resource gets a controller owner reference pointing at the origin Bundle.

Example bundle

CR definitions:

For Bundle see 0-crd.yaml.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: postgresql-resources.smith.atlassian.com
spec:
  group: smith.atlassian.com
  names:
    kind: PostgresqlResource
    plural: postgresqlresources
    singular: postgresqlresource
  versions:
  - name: v1
    served: true
    storage: true

Bundle:

apiVersion: smith.atlassian.com/v1
kind: Bundle
metadata:
  name: bundle1
spec:
  resources:
  - name: db1
    spec:
      object:
        apiVersion: smith.atlassian.com/v1
        kind: PostgresqlResource
        metadata:
          name: db1
        spec:
          disk: 100GiB
  - name: app1
    references:
    - resource: db1
    spec:
      object:
        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: app1
        spec:
          replicas: 1
          bundle:
            metadata:
              labels:
                app: app1
            spec:
              containers:
              - name: app1
                image: quay.io/some/app1

Outputs

Some resource types can have Outputs:

Resources can reference outputs of other resources within the same bundle. See what is supported.

Dependencies

Resources may depend on each other explicitly via object references. Resources are created in the reverse dependency order.

States

READY is the state of a Resource when it can be considered created. E.g. if it is a DB then it means it was provisioned and set up as requested. State is often part of Status but it depends on kind of resource.

Event-driven and stateless

Smith does not block while waiting for a resource to reach the READY state. Instead, when walking the dependency graph, if a resource is not in the READY state (still being created) it skips processing of that resource. Resources that don't have their dependencies READY are not processed. Resources that can be created concurrently are created concurrently. Full bundle re-processing is triggered by events about the watched resources. Smith is watching all supported resource kinds and reacts to events to determine which bundle should be re-processed. This scales better than watching individual resources and much better than polling individual resources. Smith controller is built according to recommendations and following the same behaviour, semantics and code "style" as native Kubernetes controllers as closely as possible.

Features

  • Supported object kinds: Deployment, Service, ConfigMap, Secret, Ingress, ServiceAccount, HorizontalPodAutoscaler, PodDisruptionBudget;
  • Service Catalog support: objects with kind ServiceInstance and ServiceBinding. See an example and recording of the presentation to Service Catalog SIG;
  • Dynamic Custom Resources support via special annotations;
  • References between objects in the graph to pull parts of objects/fields from dependencies;
  • Smith will delete objects which were removed from a Bundle when Bundle reconciliation is performed (e.g. on a Bundle update);
  • Plugins framework for injecting custom behavior when walking the dependency graph;

Notes

Presentations

Smith has been presented to:

On App Controller

Mirantis App Controller (discussed here kubernetes/kubernetes#29453) is a very similar workflow engine with a few differences.

  • Graph of dependencies is defined explicitly.
  • It uses polling and blocks while waiting for the resource to become READY.
  • The goal of Smith is to manage Custom Resources and Service Catalog objects. App Controller cannot manage them as of this writing (?).
  • Smith has very advanced support for Service Catalog objects.

On Helm

Helm is a package manager for Kubernetes. Smith operates on a lower level, even though it can be used by a human, that is not the main use case. Smith is built to be used as a foundation component with human-friendly tooling built on top of it. E.g. Helm could probably use Smith under the covers to manipulate Kubernetes API objects. Another use case is a PaaS that delegates (some) object manipulations to Smith.

Requirements

  • Kubernetes 1.11+ is required - we use /status subresource and OpenAPI schema features that became available in this version;
  • List of project dependencies and their versions can be found in go.mod and go.sum files.

Building, testing and running

  • Go modules are used for package management. You need Go v1.12 or newer.
  • Bazel is used as the build tool. Please install it.
  • To install dependencies run
make setup

Integration tests can be run against any Kubernetes context that is configured locally. To see which contexts are available run:

kubectl config get-contexts

By default a context named minikube is used. If you use minikube and want to run tests against that context then you don't need to do anything extra. If you want to run against some other context you may do so by setting the KUBE_CONTEXT environment variable which is honored by the makefile.

E.g. to run against Kubernetes-for-Docker use KUBE_CONTEXT=docker-for-desktop.

  • To run integration tests run
make integration-test
make integration-test-sc

This command assumes Service Catalog and UPS Broker are installed in the cluster. To install them follow the Service Catalog walkthrough.

  • To run Smith locally against the configured context run
make run
# or to run with Service Catalog support enabled
make run-sc
  • To build the Docker image run
make docker

This command only builds the image, which is not very useful. If you want to import it into your Docker run

make docker-export

Documentation

Contributing

Pull requests, issues and comments welcome. For pull requests:

  • Add tests for new features and bug fixes
  • Follow the existing style
  • Separate unrelated changes into multiple pull requests

See the existing issues for things to start contributing.

For bigger changes, make sure you start a discussion first by creating an issue and explaining the intended change.

Atlassian requires contributors to sign a Contributor License Agreement, known as a CLA. This serves as a record stating that the contributor is entitled to contribute the code/documentation/translation to the project and is willing to have it used in distributions and derivative works (or is willing to transfer ownership).

Prior to accepting your contributions we ask that you please follow the appropriate link below to digitally sign the CLA. The Corporate CLA is for those who are contributing as a member of an organization and the individual CLA is for those contributing as an individual.

License

Copyright (c) 2016-2019 Atlassian and others. Apache 2.0 licensed, see LICENSE file.

More Repositories

1

react-beautiful-dnd

Beautiful and accessible drag and drop for lists with React
JavaScript
33,330
star
2

pragmatic-drag-and-drop

Fast drag and drop for any experience on any tech stack
TypeScript
9,523
star
3

jest-in-case

Jest utility for creating variations of the same test
JavaScript
1,056
star
4

react-sweet-state

Shared state management solution for React
JavaScript
870
star
5

escalator

Escalator is a batch or job optimized horizontal autoscaler for Kubernetes
Go
663
star
6

github-for-jira

Connect your code with your project management in Jira
TypeScript
626
star
7

prosemirror-utils

⚒ Utils library for ProseMirror
TypeScript
479
star
8

nucleus

A configurable and versatile update server for all your Electron apps
TypeScript
396
star
9

docker-chromium-xvfb

Docker image for running browser tests against headless Chromium
Dockerfile
385
star
10

gostatsd

An implementation of Etsy's statsd in Go with tags support
Go
380
star
11

babel-plugin-react-flow-props-to-prop-types

Convert Flow React props annotation to PropTypes
JavaScript
234
star
12

better-ajv-errors

JSON Schema validation for Human 👨‍🎤
JavaScript
233
star
13

browser-interaction-time

⏰ A JavaScript library (written in TypeScript) to measure the time a user is active on a website
TypeScript
217
star
14

gajira

GitHub Actions for Jira
199
star
15

extract-react-types

One stop shop for documenting your react components.
JavaScript
179
star
16

stricter

A project-wide js-linting tool
TypeScript
157
star
17

data-center-helm-charts

Helm charts for Atlassian's Data Center products
Java
155
star
18

bazel-tools

Reusable bits for Bazel
Starlark
113
star
19

gajira-login

Jira Login GitHub Action
JavaScript
98
star
20

terraform-provider-artifactory

Terraform provider to manage Artifactory
Go
89
star
21

build-stats

🏆 get the build stats for pipelines 🏆
TypeScript
81
star
22

dc-app-performance-toolkit

Atlassian Data Center App Performance Toolkit
Python
75
star
23

kubetoken

Kubetoken
Go
74
star
24

koa-oas3

Request and response validator for Koa using Open API Specification
TypeScript
73
star
25

1time

Lightweight, thread-safe Java/Kotlin TOTP (time-based one-time passwords) and HOTP generator and validator for multi-factor authentication valid for both prover and verifier based on shared secret
Kotlin
68
star
26

gajira-transition

JavaScript
59
star
27

gajira-create

JavaScript
58
star
28

sketch-plugin

Design your next Atlassian app with our component libraries and suite of Sketch tools 💎
JavaScript
57
star
29

go-sentry-api

A go client for the sentry api https://sentry.io/api/
Go
50
star
30

themis

Autoscaling EMR clusters and Kinesis streams on Amazon Web Services (AWS)
JavaScript
48
star
31

gajira-todo

JavaScript
46
star
32

jira-cloud-for-sketch

A Sketch plugin providing integration with JIRA Cloud
JavaScript
45
star
33

gajira-find-issue-key

JavaScript
43
star
34

oas3-chow-chow

Request and response validator against OpenAPI Specification 3
TypeScript
42
star
35

validate-npm-package

Validate a package.json file
JavaScript
38
star
36

gajira-cli

JavaScript
38
star
37

conartist

Scaffold out and keep all your files in sync over time. Code-shifts for your file system.
JavaScript
34
star
38

gajira-comment

JavaScript
33
star
39

jira-github-connector-plugin

This project has been superseded by the JIRA DVCS Connector
JavaScript
30
star
40

voyager

Voyager PaaS
Go
29
star
41

atlaskit-framerx

[Unofficial] Atlaskit for Framer X (experimental)
TypeScript
28
star
42

jira-actions

Kotlin
27
star
43

sourcemap

Java
24
star
44

asap-authentication-python

This package provides a python implementation of the Atlassian Service to Service Authentication specification.
Python
23
star
45

go-artifactory

Go library for artifactory REST API
Go
23
star
46

vscode-extension-jira-frontend

JavaScript
18
star
47

ssh

Kotlin
16
star
48

jira-performance-tests

Kotlin
16
star
49

homebrew-tap

This repository contains a collection of Homebrew (aka, Brew) "formulae" for Atlassian
Ruby
16
star
50

atlassian-connect-example-app-node

TypeScript
15
star
51

docker-fluentd

Docker image for fluentd with support for both elasticsearch and kinesis
Makefile
11
star
52

infrastructure

Kotlin
11
star
53

omniauth-jira

OmniAuth strategy for JIRA
Ruby
11
star
54

jenkins-for-jira

Connect your Jenkins server to Jira Software Cloud for more visibility into your development pipeline
TypeScript
11
star
55

redis-dump-restore

Node.js library to dump and restore Redis.
JavaScript
10
star
56

fluent-plugin-kinesis-aggregation

fluent kinesis plugin shipping KPL aggregation format records, based on https://github.com/awslabs/aws-fluent-plugin-kinesis
Ruby
10
star
57

rocker

Little text UI for docker
Rust
9
star
58

hubot-stride

JavaScript
9
star
59

graphql-braid

9
star
60

copy-pkg

Copy a package.json with filters and normalization
JavaScript
8
star
61

gray-matter-loader

Webpack loader for extracting front-matter using gray-matter - https://www.npmjs.com/package/gray-matter
JavaScript
8
star
62

jsm-integration-scripts

Jira Service Management Integration Scripts
Python
8
star
63

autoconvert

TinyMCE plugin for Atlassian Autoconvert
JavaScript
8
star
64

less-plugin-inline-svg

A Less plugin that allows to inline SVG file and customize its CSS styles
JavaScript
7
star
65

aws-infrastructure

Kotlin
7
star
66

jira-hardware-exploration

Kotlin
6
star
67

report

HTML
6
star
68

virtual-users

Kotlin
6
star
69

docker-infrastructure

Kotlin
6
star
70

jobsite

Tools for working with workspaces as defined by Yarn, Lerna, Bolt, etc.
JavaScript
5
star
71

git-lob

Experimental large files in Git (discontinued, use git-lfs instead)
Go
5
star
72

ansible-ixgbevf

4
star
73

concurrency

Kotlin
4
star
74

jvm-tasks

Kotlin
4
star
75

ssh-ubuntu

Kotlin
4
star
76

jpt-example-btf

Java
3
star
77

gojiid

A Goji Middleware For adding Request Id to Context
Go
3
star
78

jira-software-actions

Kotlin
3
star
79

workspace

Kotlin
2
star
80

putty-sourcetree-fork

A fork of PuTTY used by Sourcetree
C
2
star
81

atlassian-connect-example-app-python

Python
2
star
82

atlassian-connect-example-app-java

Java
2
star
83

jec

JEC Client source codes and installation packages
Go
2
star
84

nadel-graphql-gateway-demo

Nadel GraphQL Gateway Demo app
HTML
1
star
85

parcel-stress-test

JavaScript
1
star
86

homebrew-bitbucket

A collection of pinned versions of dependencies for Bitbucket
Ruby
1
star
87

frontend-guides

1
star
88

tangerine-state-viewer

Visual Studio Code extension to facilitate tangerine state navigation
TypeScript
1
star
89

uniql-es

JavaScript
1
star
90

jasmine-http-server-spy

Creates jasmine spy objects backed by a http server.
CoffeeScript
1
star
91

packit-cli

CLI tool for creating package based architecture for enterprise frontend applications.
JavaScript
1
star
92

fluent-plugin-statsd_event

Fluentd plugin for sendind events to a statsd service
Ruby
1
star
93

github-packages-test

Test repo to verify artifact delivery pipeline
Kotlin
1
star
94

org.eclipse.jgit-atlassian

Java
1
star
95

jces-1209

Benchmark for Cloud and DC
Kotlin
1
star
96

webvieweventtest

TypeScript
1
star
97

quick-303

Cloud vs DC
Kotlin
1
star