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.
- 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
ormodule_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.
- 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.
- Parameters
command – The CDK command to be executed.
args_list – Additional arguments to include in the generated command.
- Returns
The full command to be passed into a subprocess.
- kubectl_apply() None [source]
Execute
kubectl apply
command.https://kubectl.docs.kubernetes.io/references/kubectl/apply/
- kubectl_delete() None [source]
Execute
kubectl delete
command.https://kubectl.docs.kubernetes.io/references/kubectl/delete/
- kubectl_kustomize() str [source]
Execute
kubectl kustomize
command.https://kubectl.docs.kubernetes.io/references/kubectl/kustomize/
- __new__(**kwargs)
- class runway.module.k8s.K8sOptions[source]
Bases:
runway.module.base.ModuleOptions
Module options for Kubernetes.
- data
Options parsed into a data model.
- deploy_environment
Runway deploy environment object.
- path
Module path.
- Type
- __init__(data: runway.config.models.runway.options.k8s.RunwayK8sModuleOptionsDataModel, deploy_environment: runway.core.components._deploy_environment.DeployEnvironment, path: pathlib.Path) None [source]
Instantiate class.
- Parameters
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.
- __new__(**kwargs)
- 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.
- Parameters
environment – Current deploy environment.
region – Current AWS region.
- 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.
- Parameters
deploy_environment – Current deploy environment.
obj – Object to parse.
path – Module path.