-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster_provider.py
54 lines (43 loc) · 1.75 KB
/
cluster_provider.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import argparse
import logging
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import NewType, Optional, Any
import configargparse
logger = logging.getLogger(__name__)
ClusterType = NewType("ClusterType", str)
@dataclass
class ClusterInfo:
# cluster type string like "kind" or "eks"
cluster_type: ClusterType
# some cluster providers are used as a proxy to other providers; then the real (end) cluster type
# should be put here; example: cluster_type = "external", overridden_cluster_type = "kind"
overridden_cluster_type: Optional[ClusterType]
# as defined by cluster provider
version: str
# from the real cluster provider
cluster_id: str
# path to the kubeconfig file to connect to the cluster
kube_config_path: str
# cluster provider instance responsible for managing this cluster (needs forward type declaration)
managing_provider: "ClusterProvider"
# cluster might have an optional config file used to create that cluster
config_file: str
# a flag indicating if the App Platform was already initialized
app_platform_ready: bool = False
class ClusterProvider(ABC):
@property
@abstractmethod
def provided_cluster_type(self) -> ClusterType:
raise NotImplementedError
@abstractmethod
def get_cluster(self, cluster_type: ClusterType, config: argparse.Namespace, **kwargs: Any) -> ClusterInfo:
raise NotImplementedError
@abstractmethod
def delete_cluster(self, cluster_info: ClusterInfo) -> None:
raise NotImplementedError
@abstractmethod
def initialize_config(self, config_parser: configargparse.ArgParser) -> None:
raise NotImplementedError
def pre_run(self, config: argparse.Namespace) -> None:
pass