runway.module.k8s module

K8s (kustomize) module.

class runway.module.k8s.K8s(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)[source]

Bases: runway.module.base.RunwayModule

Kubectl Runway Module.

Instantiate class.

Parameters
  • 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 skip

Determine if the module should be skipped.

run_kubectl(command: str = 'plan')Dict[str, bool][source]

Run kubectl.

plan()None[source]

Run kustomize build and display generated plan.

deploy()None[source]

Run kubectl apply.

destroy()None[source]

Run kubectl delete.

__getitem__(key: str)typing.Any

Make the object subscriptable.

Parameters

key – Attribute to get.

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

Bases: runway.module.base.ModuleOptions

Module options for Kubernetes.

data

Options parsed into a data model.

Type

RunwayK8sModuleOptionsDataModel

deploy_environment

Runway deploy environment object.

Type

DeployEnvironment

kubectl_version

Version of kubectl to use.

Type

Optional[str]

path

Module path.

Type

Path

Instantiate class.

Parameters
  • data – Options parsed into a data model.

  • deploy_environment – Current deploy environment.

  • path – Module path.

property kustomize_config

Kustomize configuration file.

property overlay_path

Directory containing the kustomize overlay to use.

__eq__(other: typing.Any)bool

Assess equality.

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

Generate possible overlay directories.

Prefers more explicit direcory name but falls back to environmet name only.

Parameters
  • environment – Current deploy environment.

  • region – Current AWS region.

get(name: str, default: Optional[typing.Any] = None)typing.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: DeployEnvironment, obj: object, path: Optional[Path] = None)K8sOptions[source]

Parse options definition and return an options object.

Parameters
  • deploy_environment – Current deploy environment.

  • obj – Object to parse.

  • path – Module path.