eastern package

Submodules

eastern.cli module

eastern.kubectl module

exception eastern.kubectl.JobNotFound

Bases: eastern.kubectl.KubernetesException

Cannot find the given job

Raised by Kubectl.get_job_pod_name()

class eastern.kubectl.Kubectl(path='kubectl')

Bases: object

Kubernetes CLI wrapper

Parameters:path (str) – Path to kubectl (or command name if in path)
apply(file='-', data=None)

Run kubectl apply

Parameters:
  • file (str) – Filename to apply, or - to apply from data
  • data (str) – Manifest body to apply, only when file is -
Returns:

Return value of the command (0 for success)

delete_job(name)

Delete a job

Parameters:name (str) – Job name
Returns:Return value (0 for success)
get_job_pod_name(name)

Get the actual pod name of a job

Parameters:name (str) – Job name
Returns:Job name
Raises:JobNotFound – If no pod for that job is found
get_job_status(name)

Get Job status

Parameters:name (str) – Job name
Return type:JobStatus
Raises:KeyError in case there is no status in response
get_launch_args()

Get kubectl command line

eg. ['kubectl', '--namespace', 'production', '--context', 'production']

Return type:list[str]
get_pod(name)

Get pod’s metadata

Parameters:name (str) – Pod name
Return type:dict
get_pod_log(name)

Get pod’s log

Parameters:name (str) – Pod name
Return type:str
get_pod_phase(name)

Get the phase of the pod

Parameters:name (str) – Pod name
Returns:Pod phase
list_pod()

Lists a pod

Parameters:namespace (str) – Namespace name
Return type:str
rollout_wait(name, timeout=None)

Run kubectl rollout status and wait for exit

Parameters:name (str) – Deployment name to wait
Returns:Return value of the command (0 for success)

eastern.kubeyml_helper module

eastern.plugin module

class eastern.plugin.EasternPlugin

Bases: abc.ABC

Base class for all plugins

deploy_post_hook(manifest, ctx, **kwargs)

Run actions after deployment succeeded

Available context objects:

Parameters:
  • manifest (str) – Kubernetes manifest
  • ctx (click.Context) – Click context
deploy_pre_hook(manifest, ctx, **kwargs)

Preprocess the manifest before deploying. Can also be used to run actions.

Must always return the manifest.

Available context objects:

Parameters:
  • manifest (str) – Kubernetes manifest
  • ctx – Click context
Return type:

str

env_hook(formatter, **kwargs)

Return a dict of additional environment values (equivalent to -s on command line)

Parameters:formatter (eastern.formatter.formatter.Formatter) – A formatter instance
Return type:dict
format_post_hook(body, formatter, **kwargs)

Postprocess a template. The template will be given after all plugins has processed it.

Must always return the resulting template.

Parameters:
  • body (str) – The whole template
  • formatter (eastern.formatter.formatter.Formatter) – A formatter instance
Return type:

str

format_pre_hook(body, formatter, **kwargs)

Preprocess a template. The template will be given as-is.

Must always return the resulting template.

Parameters:
  • body (str) – The whole template
  • formatter (eastern.formatter.formatter.Formatter) – A formatter instance
Return type:

str

line_post_hook(line, formatter, **kwargs)

Postprocess a formatter line. The line will be given after all plugins has processed the line.

Must always return the resulting line.

Parameters:
  • line (str) – A line of template
  • formatter (eastern.formatter.formatter.Formatter) – A formatter instance
Return type:

str

line_pre_hook(line, formatter, **kwargs)

Preprocess a formatter line. The line will be given as-is.

Must always return the resulting line.

Parameters:
  • line (str) – A line of template
  • formatter (eastern.formatter.formatter.Formatter) – A formatter instance
Return type:

str

Module contents