Giter VIP home page Giter VIP logo

eastern's Introduction

Project Eastern

Travis GitHub license Read the Docs PyPI Docker Hub

A Kubernetes templating and deployment tool.

Table of Contents

Features

  • Simple, logicless template engine designed for YAML
  • Work with multiple environments
  • In use in production at Wongnai
  • Extensible plugin architecture

Installation

Note that Eastern requires kubectl.

Installing from PyPI

Run pip install eastern to install.

Running from Docker Image

Eastern is available on Docker Hub for continuous delivery users.

docker run -v `pwd`:/projects/ --rm wongnai/eastern eastern generate /projects/kubernetes.yaml

Installing from Git

  1. Clone this repository
  2. Run python3 setup.py install. You might to run this as root.
  3. Run eastern to verify that it is installed.

Usage

Template language

At its core, Eastern is a YAML templating tool. Eastern provides the following commands as YAML comment.

  • load? file_1.yaml, file_2.yaml ...: Load the first file available
  • load! file_1.yaml, file_2.yaml ...: Same as load? but throw when no file is loaded.

The file name and contents may contains variable interpolation. Available variable is

  • ${NAMESPACE}: Name of namespace

Additional variables can be passed by -s var=value.

For example:

image: wongnai/eastern:${IMAGE_TAG}
env:
  # load! env-${NAMESPACE}.yaml, env.yaml

See full deployment example in the example folder.

Once you have written a template, test it with eastern generate path/to/file.yaml namespace -s IMAGE_TAG=2.0.

Deploy

To deploy, run eastern deploy path/to/file.yaml namespace.

Available options:

  • --set var=value (-s): Set additional template variables
  • --edit (-e): Edit resulting YAML before deploying
  • --no-wait: Exit after running kubectl without waiting for rolling deploy

Deploy jobs

Eastern comes with Job deployment tool.

To start a job, run eastern job path/to/file.yaml namespace image_tag. The file must have the job as its only document. Eastern will add image_tag as job suffix, deploy, wait until job's completion and remove the job.

Supplied image_tag is available in the template as ${IMAGE_TAG}.

Plugin

Eastern is extensible. We use Eastern plugins ourselves. The API docs is available on Read the Docs.

License

(C) 2017 Wongnai Media Co, Ltd.

Eastern is licensed under MIT License

eastern's People

Contributors

bakamitai456 avatar blead avatar seehait avatar skrityak avatar tanapoln avatar tuterdust avatar whs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eastern's Issues

Test flakes

Travis often report test failure in timing-related tests

when disabled timeout it always throw error

when i use eastern job --timeout 0 migrate_job.yaml default $BITBUCKET_COMMIT. it ran job normally but it throw an error below.

Cleaning up job database-migrate-job-5d74557cd710d188aaadfc3ebbcc9b89300555d6
job.batch "database-migrate-job-5d74557cd710d188aaadfc3ebbcc9b89300555d6" deleted
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/eastern-4.4.1-py3.7.egg/eastern/timeout.py", line 34, in run
  File "/usr/local/lib/python3.7/site-packages/eastern-4.4.1-py3.7.egg/eastern/timeout.py", line 66, in set_timeout
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 651, in call_later
    timer = self.call_at(self.time() + delay, callback, *args,
TypeError: unsupported operand type(s) for +: 'float' and 'NoneType'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/eastern", line 11, in <module>
    load_entry_point('eastern==4.4.1', 'console_scripts', 'eastern')()
  File "/usr/local/lib/python3.7/site-packages/click-6.7-py3.7.egg/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click-6.7-py3.7.egg/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click-6.7-py3.7.egg/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click-6.7-py3.7.egg/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click-6.7-py3.7.egg/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click-6.7-py3.7.egg/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/eastern-4.4.1-py3.7.egg/eastern/cli.py", line 223, in job
  File "/usr/local/lib/python3.7/site-packages/eastern-4.4.1-py3.7.egg/eastern/job_manager.py", line 78, in wait_completion
  File "/usr/local/lib/python3.7/site-packages/eastern-4.4.1-py3.7.egg/eastern/timeout.py", line 20, in run_sync
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.7/site-packages/eastern-4.4.1-py3.7.egg/eastern/timeout.py", line 53, in run
AttributeError: 'ProcessTimeout' object has no attribute '_timeout'```

Accept dynamic variable configured via command line

Now, Easter CLI only accept 3 parameter like this:

eastern deploy <kube-yml> <namespace> <image-tag>

And it map <namespace> and <image-tag> to variables ${NAMESPACE} and ${IMAGE_TAG} respectively.
Which is very strict and limit the capabilities of templating.

I would suggest to change the format of arguments accepted to be like this:

eastern deploy <kube-yml> NAMESPACE=<namespace> IMAGE_TAG=<image-tag> ...`

which can accept any number of arguments!
I also suggest to put a constraint on parameter naming to this regex: [A-Z0-9_]+

By the way, it will break the old one, maybe, we could drop the support.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.