runway.module.k8s module

K8s (kustomize) module.

class runway.module.k8s.K8s[source]

Bases: runway.module.base.RunwayModule

Kubectl Runway Module.

__init__(context: RunwayContext, *, explicitly_enabled: Optional[bool] = False, logger: RunwayLogger = <RunwayLogger runway.module.k8s (WARNING)>, module_root: Path, name: Optional[str] = None, options: Optional[Union[Dict[str, Any], ModuleOptions]] = None, parameters: Optional[Dict[str, Any]] = None, **_: Any) None[source]

Instantiate class.

  • context – Runway context object for the current session.

  • explicitly_enabled – Whether or not the module is explicitly enabled. This is can be set in the event that the current environment being deployed to matches the defined environments of the module/deployment.

  • logger – Used to write logs.

  • module_root – Root path of the module.

  • name – Name of the module.

  • options – Options passed to the module class from the config as options or module_options if coming from the deployment level.

  • parameters – Values to pass to the underlying infrastructure as code tool that will alter the resulting infrastructure being deployed. Used to templatize IaC.

property kbenv: runway.env_mgr.kbenv.KBEnvManager

Kubectl environment manager.

property kubectl_bin: str

Path to kubectl binary.

property skip: bool

Determine if the module should be skipped.

deploy() None[source]

Run kubectl apply.

destroy() None[source]

Run kubectl delete.

gen_cmd(command: typing_extensions.Literal[annotation, apply, auth, autoscale, cp, create, delete, describe, diff, edit, exec, expose, get, kustomize, label, logs, patch, port - forward, proxy], args_list: Optional[List[str]] = None) List[str][source]

Generate and log a kubectl command.

This does not execute the command, only prepares it for use.

  • command – The CDK command to be executed.

  • args_list – Additional arguments to include in the generated command.


The full command to be passed into a subprocess.

init() None[source]

Run init.

kubectl_apply() None[source]

Execute kubectl apply command.

kubectl_delete() None[source]

Execute kubectl delete command.

kubectl_kustomize() str[source]

Execute kubectl kustomize command.

plan() None[source]

Run kustomize build and display generated plan.

__getitem__(key: str) Any

Make the object subscriptable.


key – Attribute to get.

class runway.module.k8s.K8sOptions[source]

Bases: runway.module.base.ModuleOptions

Module options for Kubernetes.


Options parsed into a data model.




Runway deploy environment object.




Version of kubectl to use.




Module path.



__init__(data: runway.config.models.runway.options.k8s.RunwayK8sModuleOptionsDataModel, deploy_environment: runway.core.components._deploy_environment.DeployEnvironment, path: pathlib.Path) None[source]

Instantiate class.

  • data – Options parsed into a data model.

  • deploy_environment – Current deploy environment.

  • path – Module path.

property kustomize_config: pathlib.Path

Kustomize configuration file.

property overlay_path: pathlib.Path

Directory containing the kustomize overlay to use.

__eq__(other: Any) bool

Assess equality.

static gen_overlay_dirs(environment: str, region: str) List[str][source]

Generate possible overlay directories.

Prefers more explicit directory name but falls back to environment name only.

  • environment – Current deploy environment.

  • region – Current AWS region.

get(name: str, default: Optional[Any] = None) Any

Get a value or return the default.

classmethod get_overlay_dir(path: pathlib.Path, environment: str, region: str) pathlib.Path[source]

Determine the overlay directory to use.

classmethod parse_obj(deploy_environment: runway.core.components._deploy_environment.DeployEnvironment, obj: object, path: Optional[pathlib.Path] = None) runway.module.k8s.K8sOptions[source]

Parse options definition and return an options object.

  • deploy_environment – Current deploy environment.

  • obj – Object to parse.

  • path – Module path.