Kubernetes
zenml.integrations.kubernetes
Kubernetes integration for Kubernetes-native orchestration.
The Kubernetes integration sub-module powers an alternative to the local orchestrator. You can enable it by registering the Kubernetes orchestrator with the CLI tool.
Attributes
KUBERNETES = 'kubernetes'
module-attribute
KUBERNETES_DEPLOYER_FLAVOR = 'kubernetes'
module-attribute
KUBERNETES_ORCHESTRATOR_FLAVOR = 'kubernetes'
module-attribute
KUBERNETES_STEP_OPERATOR_FLAVOR = 'kubernetes'
module-attribute
Classes
Flavor
Class for ZenML Flavors.
Attributes
config_class: Type[StackComponentConfig]
abstractmethod
property
Returns StackComponentConfig config class.
Returns:
| Type | Description |
|---|---|
Type[StackComponentConfig]
|
The config class. |
config_schema: Dict[str, Any]
property
The config schema for a flavor.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The config schema. |
display_name: Optional[str]
property
The display name of the flavor.
By default, converts the technical name to a human-readable format. For example, "vm_kubernetes" becomes "VM Kubernetes". Flavors can override this to provide custom display names.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The display name of the flavor. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[StackComponent]
abstractmethod
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[StackComponent]
|
The implementation class for this flavor. |
logo_url: Optional[str]
property
A url to represent the flavor in the dashboard.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The flavor logo. |
name: str
abstractmethod
property
The flavor name.
Returns:
| Type | Description |
|---|---|
str
|
The flavor name. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor SDK docs url. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector resource requirements for service connectors.
Specifies resource requirements that are used to filter the available service connector types that are compatible with this flavor.
Returns:
| Type | Description |
|---|---|
Optional[ServiceConnectorRequirements]
|
Requirements for compatible service connectors, if a service |
Optional[ServiceConnectorRequirements]
|
connector is required for this flavor. |
type: StackComponentType
abstractmethod
property
Functions
from_model(flavor_model: FlavorResponse) -> Flavor
classmethod
Loads a flavor from a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flavor_model
|
FlavorResponse
|
The model to load from. |
required |
Raises:
| Type | Description |
|---|---|
CustomFlavorImportError
|
If the custom flavor can't be imported. |
ImportError
|
If the flavor can't be imported. |
Returns:
| Type | Description |
|---|---|
Flavor
|
The loaded flavor. |
Source code in src/zenml/stack/flavor.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
generate_default_docs_url() -> str
Generate the doc urls for all inbuilt and integration flavors.
Note that this method is not going to be useful for custom flavors, which do not have any docs in the main zenml docs.
Returns:
| Type | Description |
|---|---|
str
|
The complete url to the zenml documentation |
Source code in src/zenml/stack/flavor.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
generate_default_sdk_docs_url() -> str
Generate SDK docs url for a flavor.
Returns:
| Type | Description |
|---|---|
str
|
The complete url to the zenml SDK docs |
Source code in src/zenml/stack/flavor.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
to_model(integration: Optional[str] = None, is_custom: bool = True) -> FlavorRequest
Converts a flavor to a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
integration
|
Optional[str]
|
The integration to use for the model. |
None
|
is_custom
|
bool
|
Whether the flavor is a custom flavor. |
True
|
Returns:
| Type | Description |
|---|---|
FlavorRequest
|
The model. |
Source code in src/zenml/stack/flavor.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
Integration
Base class for integration in ZenML.
Functions
activate() -> None
classmethod
Abstract method to activate the integration.
Source code in src/zenml/integrations/integration.py
140 141 142 | |
check_installation() -> bool
classmethod
Method to check whether the required packages are installed.
Returns:
| Type | Description |
|---|---|
bool
|
True if all required packages are installed, False otherwise. |
Source code in src/zenml/integrations/integration.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
flavors() -> List[Type[Flavor]]
classmethod
Abstract method to declare new stack component flavors.
Returns:
| Type | Description |
|---|---|
List[Type[Flavor]]
|
A list of new stack component flavors. |
Source code in src/zenml/integrations/integration.py
144 145 146 147 148 149 150 151 | |
get_requirements(target_os: Optional[str] = None, python_version: Optional[str] = None) -> List[str]
classmethod
Method to get the requirements for the integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
python_version
|
Optional[str]
|
The Python version to use for the requirements. |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/integration.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
get_uninstall_requirements(target_os: Optional[str] = None) -> List[str]
classmethod
Method to get the uninstall requirements for the integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/integration.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
plugin_flavors() -> List[Type[BasePluginFlavor]]
classmethod
Abstract method to declare new plugin flavors.
Returns:
| Type | Description |
|---|---|
List[Type[BasePluginFlavor]]
|
A list of new plugin flavors. |
Source code in src/zenml/integrations/integration.py
153 154 155 156 157 158 159 160 | |
KubernetesIntegration
Bases: Integration
Definition of Kubernetes integration for ZenML.
Functions
flavors() -> List[Type[Flavor]]
classmethod
Declare the stack component flavors for the Kubernetes integration.
Returns:
| Type | Description |
|---|---|
List[Type[Flavor]]
|
List of new stack component flavors. |
Source code in src/zenml/integrations/kubernetes/__init__.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
Modules
constants
Kubernetes orchestrator constants.
deployers
Kubernetes deployer implementation.
Classes
KubernetesDeployer(**kwargs: Any)
Bases: ContainerizedDeployer
Kubernetes deployer using template-based resource management.
Initialize the Kubernetes deployer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
107 108 109 110 111 112 113 114 115 116 | |
config: KubernetesDeployerConfig
property
Get the deployer configuration.
Returns:
| Type | Description |
|---|---|
KubernetesDeployerConfig
|
The deployer configuration. |
k8s_applier: KubernetesApplier
property
Get or create Kubernetes Applier instance.
Returns:
| Type | Description |
|---|---|
KubernetesApplier
|
Kubernetes Applier instance. |
k8s_core_api: k8s_client.CoreV1Api
property
Get Kubernetes Core V1 API client.
Returns:
| Type | Description |
|---|---|
CoreV1Api
|
Kubernetes Core V1 API client. |
settings_class: Optional[Type[KubernetesDeployerSettings]]
property
Return the settings class.
Returns:
| Type | Description |
|---|---|
Optional[Type[KubernetesDeployerSettings]]
|
The settings class for this deployer. |
validator: Optional[StackValidator]
property
Stack validator for the deployer.
Returns:
| Type | Description |
|---|---|
Optional[StackValidator]
|
Stack validator instance. |
do_deprovision_deployment(deployment: DeploymentResponse, timeout: int) -> Optional[DeploymentOperationalState]
Deprovision a deployment using inventory-based deletion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to deprovision. |
required |
timeout
|
int
|
Timeout in seconds. |
required |
Returns:
| Type | Description |
|---|---|
Optional[DeploymentOperationalState]
|
None to indicate immediate deletion. |
Raises:
| Type | Description |
|---|---|
DeploymentDeprovisionError
|
If deprovisioning fails. |
DeploymentNotFoundError
|
If deployment has no inventory. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 | |
do_get_deployment_state(deployment: DeploymentResponse) -> DeploymentOperationalState
Get deployment state based on inventory.
This method checks ALL resources in the inventory to determine status: - Checks all Deployment resources to see if they're ready - Checks all Service resources to get URLs - Works with both built-in and custom templates
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment. |
required |
Returns:
| Type | Description |
|---|---|
DeploymentOperationalState
|
The operational state. |
Raises:
| Type | Description |
|---|---|
DeploymentNotFoundError
|
If no resources found in cluster. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 | |
do_get_deployment_state_logs(deployment: DeploymentResponse, follow: bool = False, tail: Optional[int] = None) -> Generator[str, bool, None]
Get deployment logs from all pods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment. |
required |
follow
|
bool
|
Whether to follow logs (only follows first pod if true). |
False
|
tail
|
Optional[int]
|
Number of lines to tail per pod. |
None
|
Yields:
| Type | Description |
|---|---|
str
|
Log lines from all pods, prefixed with pod name. |
Raises:
| Type | Description |
|---|---|
DeploymentLogsNotFoundError
|
If no Deployment found or pods unavailable. |
DeployerError
|
If deployment has no inventory. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 | |
do_provision_deployment(deployment: DeploymentResponse, stack: Stack, environment: Dict[str, str], secrets: Dict[str, str], timeout: int) -> DeploymentOperationalState
Provision a Kubernetes deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to provision. |
required |
stack
|
Stack
|
The stack the pipeline will be deployed on. |
required |
environment
|
Dict[str, str]
|
Environment variables. |
required |
secrets
|
Dict[str, str]
|
Secret environment variables. |
required |
timeout
|
int
|
Timeout in seconds. |
required |
Returns:
| Type | Description |
|---|---|
DeploymentOperationalState
|
The operational state of the deployment. |
Raises:
| Type | Description |
|---|---|
DeploymentProvisionError
|
If provisioning fails. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 | |
get_kube_client(incluster: Optional[bool] = None) -> k8s_client.ApiClient
Getter for the Kubernetes API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
incluster
|
Optional[bool]
|
Whether to use the in-cluster config or not. Overrides
the |
None
|
Returns:
| Type | Description |
|---|---|
ApiClient
|
The Kubernetes API client. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if the Kubernetes connector behaves unexpectedly. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
get_kubernetes_contexts() -> Tuple[List[str], str]
Get list of configured Kubernetes contexts and the active context.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if the Kubernetes configuration cannot be loaded. |
Returns:
| Name | Type | Description |
|---|---|---|
context_name |
List[str]
|
List of configured Kubernetes contexts |
active_context_name |
str
|
Name of the active Kubernetes context. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
Modules
kubernetes_deployer
Kubernetes deployer implementation.
KubernetesDeployer(**kwargs: Any)
Bases: ContainerizedDeployer
Kubernetes deployer using template-based resource management.
Initialize the Kubernetes deployer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
107 108 109 110 111 112 113 114 115 116 | |
config: KubernetesDeployerConfig
property
Get the deployer configuration.
Returns:
| Type | Description |
|---|---|
KubernetesDeployerConfig
|
The deployer configuration. |
k8s_applier: KubernetesApplier
property
Get or create Kubernetes Applier instance.
Returns:
| Type | Description |
|---|---|
KubernetesApplier
|
Kubernetes Applier instance. |
k8s_core_api: k8s_client.CoreV1Api
property
Get Kubernetes Core V1 API client.
Returns:
| Type | Description |
|---|---|
CoreV1Api
|
Kubernetes Core V1 API client. |
settings_class: Optional[Type[KubernetesDeployerSettings]]
property
Return the settings class.
Returns:
| Type | Description |
|---|---|
Optional[Type[KubernetesDeployerSettings]]
|
The settings class for this deployer. |
validator: Optional[StackValidator]
property
Stack validator for the deployer.
Returns:
| Type | Description |
|---|---|
Optional[StackValidator]
|
Stack validator instance. |
do_deprovision_deployment(deployment: DeploymentResponse, timeout: int) -> Optional[DeploymentOperationalState]
Deprovision a deployment using inventory-based deletion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to deprovision. |
required |
timeout
|
int
|
Timeout in seconds. |
required |
Returns:
| Type | Description |
|---|---|
Optional[DeploymentOperationalState]
|
None to indicate immediate deletion. |
Raises:
| Type | Description |
|---|---|
DeploymentDeprovisionError
|
If deprovisioning fails. |
DeploymentNotFoundError
|
If deployment has no inventory. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 | |
do_get_deployment_state(deployment: DeploymentResponse) -> DeploymentOperationalState
Get deployment state based on inventory.
This method checks ALL resources in the inventory to determine status: - Checks all Deployment resources to see if they're ready - Checks all Service resources to get URLs - Works with both built-in and custom templates
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment. |
required |
Returns:
| Type | Description |
|---|---|
DeploymentOperationalState
|
The operational state. |
Raises:
| Type | Description |
|---|---|
DeploymentNotFoundError
|
If no resources found in cluster. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 | |
do_get_deployment_state_logs(deployment: DeploymentResponse, follow: bool = False, tail: Optional[int] = None) -> Generator[str, bool, None]
Get deployment logs from all pods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment. |
required |
follow
|
bool
|
Whether to follow logs (only follows first pod if true). |
False
|
tail
|
Optional[int]
|
Number of lines to tail per pod. |
None
|
Yields:
| Type | Description |
|---|---|
str
|
Log lines from all pods, prefixed with pod name. |
Raises:
| Type | Description |
|---|---|
DeploymentLogsNotFoundError
|
If no Deployment found or pods unavailable. |
DeployerError
|
If deployment has no inventory. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 | |
do_provision_deployment(deployment: DeploymentResponse, stack: Stack, environment: Dict[str, str], secrets: Dict[str, str], timeout: int) -> DeploymentOperationalState
Provision a Kubernetes deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to provision. |
required |
stack
|
Stack
|
The stack the pipeline will be deployed on. |
required |
environment
|
Dict[str, str]
|
Environment variables. |
required |
secrets
|
Dict[str, str]
|
Secret environment variables. |
required |
timeout
|
int
|
Timeout in seconds. |
required |
Returns:
| Type | Description |
|---|---|
DeploymentOperationalState
|
The operational state of the deployment. |
Raises:
| Type | Description |
|---|---|
DeploymentProvisionError
|
If provisioning fails. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 | |
get_kube_client(incluster: Optional[bool] = None) -> k8s_client.ApiClient
Getter for the Kubernetes API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
incluster
|
Optional[bool]
|
Whether to use the in-cluster config or not. Overrides
the |
None
|
Returns:
| Type | Description |
|---|---|
ApiClient
|
The Kubernetes API client. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if the Kubernetes connector behaves unexpectedly. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
get_kubernetes_contexts() -> Tuple[List[str], str]
Get list of configured Kubernetes contexts and the active context.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if the Kubernetes configuration cannot be loaded. |
Returns:
| Name | Type | Description |
|---|---|---|
context_name |
List[str]
|
List of configured Kubernetes contexts |
active_context_name |
str
|
Name of the active Kubernetes context. |
Source code in src/zenml/integrations/kubernetes/deployers/kubernetes_deployer.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
flavors
Kubernetes integration flavors.
Classes
KubernetesDeployerConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseDeployerConfig, KubernetesDeployerSettings
Configuration for the Kubernetes deployer.
This config combines deployer-specific settings with Kubernetes component configuration (context, namespace, in-cluster mode).
Attributes:
| Name | Type | Description |
|---|---|---|
incluster |
bool
|
If |
kubernetes_context |
Optional[str]
|
Name of a Kubernetes context to run deployments in. If the stack component is linked to a Kubernetes service connector, this field is ignored. Otherwise, it is mandatory. |
kubernetes_namespace |
Optional[str]
|
Default Kubernetes namespace for deployments. Can be overridden per-deployment using the |
local |
bool
|
If |
Source code in src/zenml/stack/stack_component.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
is_local: bool
property
Checks if this is a local Kubernetes cluster.
Returns:
| Type | Description |
|---|---|
bool
|
True if using a local Kubernetes cluster, False otherwise. |
is_remote: bool
property
Checks if this stack component is running remotely.
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a remote component, False otherwise. |
KubernetesDeployerFlavor
Bases: BaseDeployerFlavor
Flavor for the Kubernetes deployer.
config_class: Type[KubernetesDeployerConfig]
property
Returns KubernetesDeployerConfig config class.
Returns:
| Type | Description |
|---|---|
Type[KubernetesDeployerConfig]
|
The config class. |
docs_url: Optional[str]
property
A URL to docs about this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The documentation URL. |
implementation_class: Type[KubernetesDeployer]
property
Returns the implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[KubernetesDeployer]
|
The implementation class. |
logo_url: str
property
The logo URL for the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The logo URL. |
name: str
property
The name of the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The flavor name. |
sdk_docs_url: Optional[str]
property
A URL to SDK docs about this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The SDK documentation URL. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector requirements for the Kubernetes deployer.
Returns:
| Type | Description |
|---|---|
Optional[ServiceConnectorRequirements]
|
Service connector requirements. |
KubernetesDeployerSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseDeployerSettings
Settings for the Kubernetes deployer.
Follows a progressive complexity model: - Essential Settings: Core configuration for Deployment + Service (80% of users) - Additional Resources: Add ANY K8s resource (Ingress, HPA, NetworkPolicy, etc.) - Custom Templates: Override deployment.yaml.j2 or service.yaml.j2 for advanced control
Essential Settings
namespace: Kubernetes namespace for deployments. service_type: How to expose service (LoadBalancer, NodePort, ClusterIP). service_port: Port to expose on the service. image_pull_policy: When to pull images (Always, IfNotPresent, Never). labels: Custom labels to apply to all resources. command: Override container command/entrypoint. args: Override container args. service_account_name: ServiceAccount for pods (RBAC). image_pull_secrets: Secrets for private registries.
Advanced Settings
pod_settings: Advanced pod configuration (volumes, affinity, tolerations, etc.). additional_resources: Paths to YAML files with additional K8s resources. custom_templates_dir: Path to custom Jinja2 templates for Deployment/Service. Use this to customize health probes, service annotations, etc.
Source code in src/zenml/config/secret_reference_mixin.py
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
validate_interdependent_settings() -> KubernetesDeployerSettings
Validate settings that depend on each other.
Returns:
| Type | Description |
|---|---|
KubernetesDeployerSettings
|
The validated settings. |
Source code in src/zenml/integrations/kubernetes/flavors/kubernetes_deployer_flavor.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
validate_probe_path(v: str) -> str
classmethod
Validate that probe paths start with /.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str
|
The probe path value. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The validated probe path. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the path doesn't start with /. |
Source code in src/zenml/integrations/kubernetes/flavors/kubernetes_deployer_flavor.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
KubernetesOrchestratorConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseOrchestratorConfig, KubernetesOrchestratorSettings
Configuration for the Kubernetes orchestrator.
Source code in src/zenml/stack/stack_component.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
handles_step_retries: bool
property
Whether the orchestrator handles step retries.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the orchestrator handles step retries. |
is_local: bool
property
Checks if this stack component is running locally.
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a local component, False otherwise. |
is_remote: bool
property
Checks if this stack component is running remotely.
This designation is used to determine if the stack component can be used with a local ZenML database or if it requires a remote ZenML server.
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a remote component, False otherwise. |
is_schedulable: bool
property
Whether the orchestrator is schedulable or not.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the orchestrator is schedulable or not. |
is_synchronous: bool
property
Whether the orchestrator runs synchronous or not.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the orchestrator runs synchronous or not. |
supports_client_side_caching: bool
property
Whether the orchestrator supports client side caching.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the orchestrator supports client side caching. |
KubernetesOrchestratorFlavor
Bases: BaseOrchestratorFlavor
Kubernetes orchestrator flavor.
config_class: Type[KubernetesOrchestratorConfig]
property
Returns KubernetesOrchestratorConfig config class.
Returns:
| Type | Description |
|---|---|
Type[KubernetesOrchestratorConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[KubernetesOrchestrator]
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[KubernetesOrchestrator]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
| Type | Description |
|---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor SDK docs url. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector resource requirements for service connectors.
Specifies resource requirements that are used to filter the available service connector types that are compatible with this flavor.
Returns:
| Type | Description |
|---|---|
Optional[ServiceConnectorRequirements]
|
Requirements for compatible service connectors, if a service |
Optional[ServiceConnectorRequirements]
|
connector is required for this flavor. |
KubernetesOrchestratorSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseSettings
Settings for the Kubernetes orchestrator.
Configuration options for how pipelines are executed on Kubernetes clusters. Field descriptions are defined inline using Field() descriptors.
Source code in src/zenml/config/secret_reference_mixin.py
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
KubernetesStepOperatorConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseStepOperatorConfig, KubernetesStepOperatorSettings
Configuration for the Kubernetes step operator.
Source code in src/zenml/stack/stack_component.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
is_local: bool
property
Checks if this stack component is running locally.
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a local component, False otherwise. |
is_remote: bool
property
Checks if this stack component is running remotely.
This designation is used to determine if the stack component can be used with a local ZenML database or if it requires a remote ZenML server.
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a remote component, False otherwise. |
KubernetesStepOperatorFlavor
Bases: BaseStepOperatorFlavor
Kubernetes step operator flavor.
config_class: Type[KubernetesStepOperatorConfig]
property
Returns KubernetesStepOperatorConfig config class.
Returns:
| Type | Description |
|---|---|
Type[KubernetesStepOperatorConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[KubernetesStepOperator]
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[KubernetesStepOperator]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
| Type | Description |
|---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor SDK docs url. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector resource requirements for service connectors.
Specifies resource requirements that are used to filter the available service connector types that are compatible with this flavor.
Returns:
| Type | Description |
|---|---|
Optional[ServiceConnectorRequirements]
|
Requirements for compatible service connectors, if a service |
Optional[ServiceConnectorRequirements]
|
connector is required for this flavor. |
KubernetesStepOperatorSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseSettings
Settings for the Kubernetes step operator.
Source code in src/zenml/config/secret_reference_mixin.py
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
Modules
kubernetes_deployer_flavor
Kubernetes deployer flavor.
KubernetesDeployerConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseDeployerConfig, KubernetesDeployerSettings
Configuration for the Kubernetes deployer.
This config combines deployer-specific settings with Kubernetes component configuration (context, namespace, in-cluster mode).
Attributes:
| Name | Type | Description |
|---|---|---|
incluster |
bool
|
If |
kubernetes_context |
Optional[str]
|
Name of a Kubernetes context to run deployments in. If the stack component is linked to a Kubernetes service connector, this field is ignored. Otherwise, it is mandatory. |
kubernetes_namespace |
Optional[str]
|
Default Kubernetes namespace for deployments. Can be overridden per-deployment using the |
local |
bool
|
If |
Source code in src/zenml/stack/stack_component.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
is_local: bool
property
Checks if this is a local Kubernetes cluster.
Returns:
| Type | Description |
|---|---|
bool
|
True if using a local Kubernetes cluster, False otherwise. |
is_remote: bool
property
Checks if this stack component is running remotely.
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a remote component, False otherwise. |
KubernetesDeployerFlavor
Bases: BaseDeployerFlavor
Flavor for the Kubernetes deployer.
config_class: Type[KubernetesDeployerConfig]
property
Returns KubernetesDeployerConfig config class.
Returns:
| Type | Description |
|---|---|
Type[KubernetesDeployerConfig]
|
The config class. |
docs_url: Optional[str]
property
A URL to docs about this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The documentation URL. |
implementation_class: Type[KubernetesDeployer]
property
Returns the implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[KubernetesDeployer]
|
The implementation class. |
logo_url: str
property
The logo URL for the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The logo URL. |
name: str
property
The name of the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The flavor name. |
sdk_docs_url: Optional[str]
property
A URL to SDK docs about this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The SDK documentation URL. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector requirements for the Kubernetes deployer.
Returns:
| Type | Description |
|---|---|
Optional[ServiceConnectorRequirements]
|
Service connector requirements. |
KubernetesDeployerSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseDeployerSettings
Settings for the Kubernetes deployer.
Follows a progressive complexity model: - Essential Settings: Core configuration for Deployment + Service (80% of users) - Additional Resources: Add ANY K8s resource (Ingress, HPA, NetworkPolicy, etc.) - Custom Templates: Override deployment.yaml.j2 or service.yaml.j2 for advanced control
Essential Settings
namespace: Kubernetes namespace for deployments. service_type: How to expose service (LoadBalancer, NodePort, ClusterIP). service_port: Port to expose on the service. image_pull_policy: When to pull images (Always, IfNotPresent, Never). labels: Custom labels to apply to all resources. command: Override container command/entrypoint. args: Override container args. service_account_name: ServiceAccount for pods (RBAC). image_pull_secrets: Secrets for private registries.
Advanced Settings
pod_settings: Advanced pod configuration (volumes, affinity, tolerations, etc.). additional_resources: Paths to YAML files with additional K8s resources. custom_templates_dir: Path to custom Jinja2 templates for Deployment/Service. Use this to customize health probes, service annotations, etc.
Source code in src/zenml/config/secret_reference_mixin.py
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
validate_interdependent_settings() -> KubernetesDeployerSettings
Validate settings that depend on each other.
Returns:
| Type | Description |
|---|---|
KubernetesDeployerSettings
|
The validated settings. |
Source code in src/zenml/integrations/kubernetes/flavors/kubernetes_deployer_flavor.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
validate_probe_path(v: str) -> str
classmethod
Validate that probe paths start with /.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str
|
The probe path value. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The validated probe path. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the path doesn't start with /. |
Source code in src/zenml/integrations/kubernetes/flavors/kubernetes_deployer_flavor.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
kubernetes_orchestrator_flavor
Kubernetes orchestrator flavor.
KubernetesOrchestratorConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseOrchestratorConfig, KubernetesOrchestratorSettings
Configuration for the Kubernetes orchestrator.
Source code in src/zenml/stack/stack_component.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
handles_step_retries: bool
property
Whether the orchestrator handles step retries.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the orchestrator handles step retries. |
is_local: bool
property
Checks if this stack component is running locally.
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a local component, False otherwise. |
is_remote: bool
property
Checks if this stack component is running remotely.
This designation is used to determine if the stack component can be used with a local ZenML database or if it requires a remote ZenML server.
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a remote component, False otherwise. |
is_schedulable: bool
property
Whether the orchestrator is schedulable or not.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the orchestrator is schedulable or not. |
is_synchronous: bool
property
Whether the orchestrator runs synchronous or not.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the orchestrator runs synchronous or not. |
supports_client_side_caching: bool
property
Whether the orchestrator supports client side caching.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the orchestrator supports client side caching. |
KubernetesOrchestratorFlavor
Bases: BaseOrchestratorFlavor
Kubernetes orchestrator flavor.
config_class: Type[KubernetesOrchestratorConfig]
property
Returns KubernetesOrchestratorConfig config class.
Returns:
| Type | Description |
|---|---|
Type[KubernetesOrchestratorConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[KubernetesOrchestrator]
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[KubernetesOrchestrator]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
| Type | Description |
|---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor SDK docs url. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector resource requirements for service connectors.
Specifies resource requirements that are used to filter the available service connector types that are compatible with this flavor.
Returns:
| Type | Description |
|---|---|
Optional[ServiceConnectorRequirements]
|
Requirements for compatible service connectors, if a service |
Optional[ServiceConnectorRequirements]
|
connector is required for this flavor. |
KubernetesOrchestratorSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseSettings
Settings for the Kubernetes orchestrator.
Configuration options for how pipelines are executed on Kubernetes clusters. Field descriptions are defined inline using Field() descriptors.
Source code in src/zenml/config/secret_reference_mixin.py
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
kubernetes_step_operator_flavor
Kubernetes step operator flavor.
KubernetesStepOperatorConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseStepOperatorConfig, KubernetesStepOperatorSettings
Configuration for the Kubernetes step operator.
Source code in src/zenml/stack/stack_component.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
is_local: bool
property
Checks if this stack component is running locally.
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a local component, False otherwise. |
is_remote: bool
property
Checks if this stack component is running remotely.
This designation is used to determine if the stack component can be used with a local ZenML database or if it requires a remote ZenML server.
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a remote component, False otherwise. |
KubernetesStepOperatorFlavor
Bases: BaseStepOperatorFlavor
Kubernetes step operator flavor.
config_class: Type[KubernetesStepOperatorConfig]
property
Returns KubernetesStepOperatorConfig config class.
Returns:
| Type | Description |
|---|---|
Type[KubernetesStepOperatorConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[KubernetesStepOperator]
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[KubernetesStepOperator]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
| Type | Description |
|---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor SDK docs url. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector resource requirements for service connectors.
Specifies resource requirements that are used to filter the available service connector types that are compatible with this flavor.
Returns:
| Type | Description |
|---|---|
Optional[ServiceConnectorRequirements]
|
Requirements for compatible service connectors, if a service |
Optional[ServiceConnectorRequirements]
|
connector is required for this flavor. |
KubernetesStepOperatorSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseSettings
Settings for the Kubernetes step operator.
Source code in src/zenml/config/secret_reference_mixin.py
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
k8s_applier
Kubernetes resource applier.
Classes
DeletionResult
Bases: BaseModel
Result of deleting resources from inventory.
KubernetesApplier(api_client: k8s_client.ApiClient)
Kubernetes applier using Server-Side Apply with inventory-based deletion.
Initialize the applier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_client
|
ApiClient
|
A configured Kubernetes ApiClient. |
required |
Source code in src/zenml/integrations/kubernetes/k8s_applier.py
112 113 114 115 116 117 118 119 | |
delete_from_inventory(inventory: List[ResourceInventoryItem], *, propagation_policy: Optional[str] = 'Foreground', grace_period_seconds: Optional[int] = None) -> DeletionResult
Delete resources from an inventory list (Helm/Flux/Argo pattern).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory
|
List[ResourceInventoryItem]
|
List of resources to delete (from provision() return value). |
required |
propagation_policy
|
Optional[str]
|
'Foreground', 'Background', or None. |
'Foreground'
|
grace_period_seconds
|
Optional[int]
|
Optional grace period override. |
None
|
Returns:
| Type | Description |
|---|---|
DeletionResult
|
DeletionResult containing counts and lists of deleted, skipped, and failed resources. |
Source code in src/zenml/integrations/kubernetes/k8s_applier.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
get_resource(name: str, namespace: Optional[str], kind: str, api_version: str) -> Optional[Any]
Fetch a single resource or return None if not found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Resource name. |
required |
namespace
|
Optional[str]
|
Namespace (ignored for cluster-scoped kinds). |
required |
kind
|
str
|
Kinds like 'Deployment', 'Service', etc. |
required |
api_version
|
str
|
API version string, e.g., 'apps/v1'. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Any]
|
The resource object if found, None otherwise. |
Raises:
| Type | Description |
|---|---|
ApiException
|
On API errors. |
Source code in src/zenml/integrations/kubernetes/k8s_applier.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
list_resources(kind: str, api_version: str, namespace: Optional[str] = None, label_selector: Optional[str] = None) -> List[Any]
List resources of a given kind/apiVersion (optionally by namespace/labels).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Resource kind (e.g., 'Deployment', 'Service', 'Pod') |
required |
api_version
|
str
|
API version string (e.g., 'apps/v1', 'v1') |
required |
namespace
|
Optional[str]
|
Namespace for namespaced resources (ignored for cluster-scoped) |
None
|
label_selector
|
Optional[str]
|
Optional label selector to filter resources (e.g., 'app=myapp,env=prod') |
None
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
List of resource objects matching the query criteria. |
List[Any]
|
Returns empty list only if the API explicitly returns zero items. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the API response is malformed (missing .items attribute or .items is not a list). This indicates a serious API or client issue. |
Source code in src/zenml/integrations/kubernetes/k8s_applier.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | |
provision(objs: Iterable[ResourceLike], default_namespace: Optional[str], *, field_manager: str = 'zenml-deployer', force: bool = False, timeout: Optional[int] = None, stop_on_error: bool = True) -> Tuple[List[Any], List[ResourceInventoryItem]]
Provision (create/update) resources using Server-Side Apply.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objs
|
Iterable[ResourceLike]
|
Iterable of resource dicts or client models. Supports 'kind: List'. |
required |
default_namespace
|
Optional[str]
|
Namespace to use if a namespaced resource lacks metadata.namespace. |
required |
field_manager
|
str
|
Field manager identity for SSA ownership tracking. |
'zenml-deployer'
|
force
|
bool
|
If True, force ownership on SSA conflicts (override other managers). |
False
|
timeout
|
Optional[int]
|
Optional request timeout (seconds) passed to the Python client. |
None
|
stop_on_error
|
bool
|
If True, stop provisioning on first error. If False, continue with remaining resources and collect all errors. |
True
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
A tuple of: |
List[ResourceInventoryItem]
|
|
Tuple[List[Any], List[ResourceInventoryItem]]
|
|
Raises:
| Type | Description |
|---|---|
ProvisioningError
|
If provisioning fails, with partial inventory and error details. |
Exception
|
If provisioning fails for KeyboardInterrupt or SystemExit. |
Source code in src/zenml/integrations/kubernetes/k8s_applier.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
wait_for_deployment_ready(name: str, namespace: str, *, timeout: int = 300, check_interval: int = 5) -> Any
Wait for a Deployment (apps/v1) to report Available=True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Resource name. |
required |
namespace
|
str
|
Namespace (ignored for cluster-scoped kinds). |
required |
timeout
|
int
|
Max seconds to wait. |
300
|
check_interval
|
int
|
Seconds between polls. |
5
|
Returns:
| Type | Description |
|---|---|
Any
|
The raw resource object from the dynamic client. |
Note
Internally normalizes the deployment to a dict for inspection, but returns the original object from the API.
Source code in src/zenml/integrations/kubernetes/k8s_applier.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | |
wait_for_resource_condition(name: str, namespace: Optional[str], kind: str, api_version: str, condition_fn: Callable[[Any], bool], timeout: int = 300, check_interval: int = 5, desc: str = 'resource') -> Any
Poll the object until condition_fn(obj) returns True or timeout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Resource name. |
required |
namespace
|
Optional[str]
|
Namespace (ignored for cluster-scoped kinds). |
required |
kind
|
str
|
Kinds like 'Deployment', 'Service', etc. |
required |
api_version
|
str
|
API version string, e.g., 'apps/v1'. |
required |
condition_fn
|
Callable[[Any], bool]
|
Callable that returns True when the resource is ready. |
required |
timeout
|
int
|
Max seconds to wait. |
300
|
check_interval
|
int
|
Seconds between polls. |
5
|
desc
|
str
|
Human-friendly description for error messages. |
'resource'
|
Returns:
| Type | Description |
|---|---|
Any
|
The object that satisfied the condition. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the timeout is reached. |
Source code in src/zenml/integrations/kubernetes/k8s_applier.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
wait_for_service_loadbalancer_ip(name: str, namespace: str, *, timeout: int = 300, check_interval: int = 5) -> str
Wait for a LoadBalancer Service to publish an external IP/hostname.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Service name. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
timeout
|
int
|
Maximum time to wait in seconds. |
300
|
check_interval
|
int
|
Time between checks in seconds. |
5
|
Returns:
| Type | Description |
|---|---|
str
|
The external IP or hostname of the LoadBalancer. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If timeout is reached or service has no external IP. |
Source code in src/zenml/integrations/kubernetes/k8s_applier.py
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | |
ProvisioningError(message: str, inventory: List[ResourceInventoryItem], errors: List[str])
Bases: RuntimeError
Exception raised when resource provisioning fails.
This exception carries partial results (inventory and errors) to enable proper error handling and rollback without losing track of what was created.
Initialize provisioning error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
High-level error message. |
required |
inventory
|
List[ResourceInventoryItem]
|
List of resources successfully provisioned before failure. |
required |
errors
|
List[str]
|
List of error messages for failed resources. |
required |
Source code in src/zenml/integrations/kubernetes/k8s_applier.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
ResourceInventoryItem
Bases: BaseModel
A single resource in the inventory.
Functions
kube_utils
Utilities for Kubernetes related functions.
Internal interface: no backwards compatibility guarantees. Adjusted from https://github.com/tensorflow/tfx/blob/master/tfx/utils/kube_utils.py.
Classes
JobStatus
Bases: Enum
Status of a Kubernetes job.
PatchedFailurePolicyRule
Bases: V1PodFailurePolicyRule
Patched failure policy rule.
on_pod_conditions
property
writable
On pod conditions.
Returns:
| Type | Description |
|---|---|
|
On pod conditions. |
PodPhase
Bases: Enum
Phase of the Kubernetes pod.
Pod phases are defined in https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase.
Functions
apply_default_resource_requests(memory: str, cpu: Optional[str] = None, pod_settings: Optional[KubernetesPodSettings] = None) -> KubernetesPodSettings
Applies default resource requests to a pod settings object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory
|
str
|
The memory resource request. |
required |
cpu
|
Optional[str]
|
The CPU resource request. |
None
|
pod_settings
|
Optional[KubernetesPodSettings]
|
The pod settings to update. A new one will be created if not provided. |
None
|
Returns:
| Type | Description |
|---|---|
KubernetesPodSettings
|
The new or updated pod settings. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 | |
build_service_url(core_api: k8s_client.CoreV1Api, service: Union[k8s_client.V1Service, Dict[str, Any]], namespace: str, ingress: Optional[Union[k8s_client.V1Ingress, Dict[str, Any]]] = None) -> Optional[str]
Build URL for accessing a Kubernetes service.
Supports multiple service types:
- LoadBalancer: Returns http://
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Kubernetes Core V1 API client. |
required |
service
|
Union[V1Service, Dict[str, Any]]
|
Kubernetes Service resource (model or dict). |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
ingress
|
Optional[Union[V1Ingress, Dict[str, Any]]]
|
Optional Kubernetes Ingress resource. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Service URL |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 | |
check_job_status(batch_api: k8s_client.BatchV1Api, core_api: k8s_client.CoreV1Api, namespace: str, job_name: str, fail_on_container_waiting_reasons: Optional[List[str]] = None, container_name: Optional[str] = None) -> Tuple[JobStatus, Optional[str]]
Check the status of a job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_api
|
BatchV1Api
|
Kubernetes BatchV1Api client. |
required |
core_api
|
CoreV1Api
|
Kubernetes CoreV1Api client. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
job_name
|
str
|
Name of the job for which to wait. |
required |
fail_on_container_waiting_reasons
|
Optional[List[str]]
|
List of container waiting reasons that will cause the job to fail. |
None
|
container_name
|
Optional[str]
|
Name of the container to check for failure. |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[JobStatus, Optional[str]]
|
The status of the job and an error message if the job failed. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 | |
convert_resource_settings_to_k8s_format(resource_settings: ResourceSettings) -> Tuple[Dict[str, str], Dict[str, str], int]
Convert ZenML ResourceSettings to Kubernetes resource format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource_settings
|
ResourceSettings
|
The resource settings from pipeline configuration. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Tuple of (requests, limits, replicas) in Kubernetes format. |
Dict[str, str]
|
|
int
|
|
Tuple[Dict[str, str], Dict[str, str], int]
|
|
Source code in src/zenml/integrations/kubernetes/kube_utils.py
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 | |
create_and_wait_for_pod_to_start(core_api: k8s_client.CoreV1Api, pod_display_name: str, pod_name: str, pod_manifest: k8s_client.V1Pod, namespace: str, startup_max_retries: int, startup_failure_delay: float, startup_failure_backoff: float, startup_timeout: float) -> None
Create a pod and wait for it to reach a desired state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Client of Core V1 API of Kubernetes API. |
required |
pod_display_name
|
str
|
The display name of the pod to use in logs. |
required |
pod_name
|
str
|
The name of the pod to create. |
required |
pod_manifest
|
V1Pod
|
The manifest of the pod to create. |
required |
namespace
|
str
|
The namespace in which to create the pod. |
required |
startup_max_retries
|
int
|
The maximum number of retries for the pod startup. |
required |
startup_failure_delay
|
float
|
The delay between retries for the pod startup. |
required |
startup_failure_backoff
|
float
|
The backoff factor for the pod startup. |
required |
startup_timeout
|
float
|
The maximum time to wait for the pod to start. |
required |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
If the pod is still in a pending state after the maximum wait time has elapsed. |
Exception
|
If the pod fails to start after the maximum number of retries. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | |
create_config_map(core_api: k8s_client.CoreV1Api, namespace: str, name: str, data: Dict[str, str]) -> None
Create a Kubernetes config map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Kubernetes CoreV1Api client. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
name
|
str
|
Name of the config map to create. |
required |
data
|
Dict[str, str]
|
Data to store in the config map. |
required |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 | |
create_edit_service_account(core_api: k8s_client.CoreV1Api, rbac_api: k8s_client.RbacAuthorizationV1Api, service_account_name: str, namespace: str, role_binding_name: str = 'zenml-edit') -> None
Create a new Kubernetes service account with "edit" rights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Client of Core V1 API of Kubernetes API. |
required |
rbac_api
|
RbacAuthorizationV1Api
|
Client of Rbac Authorization V1 API of Kubernetes API. |
required |
service_account_name
|
str
|
Name of the service account. |
required |
namespace
|
str
|
Kubernetes namespace. Defaults to "default". |
required |
role_binding_name
|
str
|
Name of the role binding. Defaults to "zenml-edit". |
'zenml-edit'
|
Source code in src/zenml/integrations/kubernetes/kube_utils.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
create_job(batch_api: k8s_client.BatchV1Api, namespace: str, job_manifest: k8s_client.V1Job) -> None
Create a Kubernetes job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_api
|
BatchV1Api
|
Kubernetes batch api. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
job_manifest
|
V1Job
|
The manifest of the job to create. |
required |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | |
create_namespace(core_api: k8s_client.CoreV1Api, namespace: str) -> None
Create a Kubernetes namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Client of Core V1 API of Kubernetes API. |
required |
namespace
|
str
|
Kubernetes namespace. Defaults to "default". |
required |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
402 403 404 405 406 407 408 409 410 | |
create_or_update_secret(core_api: k8s_client.CoreV1Api, namespace: str, secret_name: str, data: Dict[str, Optional[str]]) -> None
Create a Kubernetes secret if it doesn't exist, or update it if it does.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Client of Core V1 API of Kubernetes API. |
required |
namespace
|
str
|
The namespace in which to create or update the secret. |
required |
secret_name
|
str
|
The name of the secret to create or update. |
required |
data
|
Dict[str, Optional[str]]
|
The secret data. If the value is None, the key will be removed from the secret. |
required |
Raises:
| Type | Description |
|---|---|
ApiException
|
If the secret creation failed for any reason other than the secret already existing. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
create_secret(core_api: k8s_client.CoreV1Api, namespace: str, secret_name: str, data: Dict[str, Optional[str]]) -> None
Create a Kubernetes secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Client of Core V1 API of Kubernetes API. |
required |
namespace
|
str
|
The namespace in which to create the secret. |
required |
secret_name
|
str
|
The name of the secret to create. |
required |
data
|
Dict[str, Optional[str]]
|
The secret data. |
required |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | |
delete_config_map(core_api: k8s_client.CoreV1Api, namespace: str, name: str) -> None
Delete a Kubernetes config map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Kubernetes CoreV1Api client. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
name
|
str
|
Name of the config map to delete. |
required |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 | |
delete_secret(core_api: k8s_client.CoreV1Api, namespace: str, secret_name: str) -> None
Delete a Kubernetes secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Client of Core V1 API of Kubernetes API. |
required |
namespace
|
str
|
The namespace in which to delete the secret. |
required |
secret_name
|
str
|
The name of the secret to delete. |
required |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
get_config_map(core_api: k8s_client.CoreV1Api, namespace: str, name: str) -> k8s_client.V1ConfigMap
Get a Kubernetes config map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Kubernetes CoreV1Api client. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
name
|
str
|
Name of the config map to get. |
required |
Returns:
| Type | Description |
|---|---|
V1ConfigMap
|
The config map. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 | |
get_container_status(pod: k8s_client.V1Pod, container_name: str) -> Optional[k8s_client.V1ContainerState]
Get the status of a container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod
|
V1Pod
|
The pod to get the container status for. |
required |
container_name
|
str
|
The container name. |
required |
Returns:
| Type | Description |
|---|---|
Optional[V1ContainerState]
|
The container status. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 | |
get_container_termination_reason(pod: k8s_client.V1Pod, container_name: str) -> Optional[Tuple[int, str]]
Get the termination reason for a container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod
|
V1Pod
|
The pod to get the termination reason for. |
required |
container_name
|
str
|
The container name. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Tuple[int, str]]
|
The exit code and termination reason for the container. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 | |
get_job(batch_api: k8s_client.BatchV1Api, namespace: str, job_name: str) -> k8s_client.V1Job
Get a job by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_api
|
BatchV1Api
|
Kubernetes batch api. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
job_name
|
str
|
The name of the job to get. |
required |
Returns:
| Type | Description |
|---|---|
V1Job
|
The job. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 | |
get_parent_job_name(core_api: k8s_client.CoreV1Api, pod_name: str, namespace: str) -> Optional[str]
Get the name of the job that created a pod.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Kubernetes CoreV1Api client. |
required |
pod_name
|
str
|
Name of the pod. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The name of the job that created the pod, or None if the pod is not |
Optional[str]
|
associated with a job. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 | |
get_pod(core_api: k8s_client.CoreV1Api, pod_name: str, namespace: str) -> Optional[k8s_client.V1Pod]
Get a pod from Kubernetes metadata API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Client of |
required |
pod_name
|
str
|
The name of the pod. |
required |
namespace
|
str
|
The namespace of the pod. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
When it sees unexpected errors from Kubernetes API. |
Returns:
| Type | Description |
|---|---|
Optional[V1Pod]
|
The found pod object. None if it's not found. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
get_pod_owner_references(core_api: k8s_client.CoreV1Api, pod_name: str, namespace: str) -> List[k8s_client.V1OwnerReference]
Get owner references for a pod.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Kubernetes CoreV1Api client. |
required |
pod_name
|
str
|
Name of the pod. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
Returns:
| Type | Description |
|---|---|
List[V1OwnerReference]
|
List of owner references. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | |
is_inside_kubernetes() -> bool
Check whether we are inside a Kubernetes cluster or on a remote host.
Returns:
| Type | Description |
|---|---|
bool
|
True if inside a Kubernetes cluster, else False. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
133 134 135 136 137 138 139 140 141 142 143 | |
is_step_job(job: k8s_client.V1Job) -> bool
Check if a job is a step job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
V1Job
|
The job to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the job is a step job. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
756 757 758 759 760 761 762 763 764 765 766 767 768 | |
list_jobs(batch_api: k8s_client.BatchV1Api, namespace: str, label_selector: Optional[str] = None) -> k8s_client.V1JobList
List jobs in a namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_api
|
BatchV1Api
|
Kubernetes batch api. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
label_selector
|
Optional[str]
|
The label selector to use. |
None
|
Returns:
| Type | Description |
|---|---|
V1JobList
|
The job list. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | |
load_kube_config(incluster: bool = False, context: Optional[str] = None) -> None
Load the Kubernetes client config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
incluster
|
bool
|
Whether to load the in-cluster config. |
False
|
context
|
Optional[str]
|
Name of the Kubernetes context. If not provided, uses the
currently active context. Will be ignored if |
None
|
Source code in src/zenml/integrations/kubernetes/kube_utils.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
pod_failed(pod: k8s_client.V1Pod) -> bool
Check if pod status is 'Failed'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod
|
V1Pod
|
Kubernetes pod. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if pod status is 'Failed' else False. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
195 196 197 198 199 200 201 202 203 204 | |
pod_is_done(pod: k8s_client.V1Pod) -> bool
Check if pod status is 'Succeeded'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod
|
V1Pod
|
Kubernetes pod. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if pod status is 'Succeeded' else False. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
207 208 209 210 211 212 213 214 215 216 | |
pod_is_not_pending(pod: k8s_client.V1Pod) -> bool
Check if pod status is not 'Pending'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod
|
V1Pod
|
Kubernetes pod. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
False if the pod status is 'Pending' else True. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
183 184 185 186 187 188 189 190 191 192 | |
retry_on_api_exception(func: Callable[..., R], max_retries: int = 3, delay: float = 1, backoff: float = 1, fail_on_status_codes: Tuple[int, ...] = (404,)) -> Callable[..., R]
Retry a function on API exceptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., R]
|
The function to retry. |
required |
max_retries
|
int
|
The maximum number of retries. |
3
|
delay
|
float
|
The delay between retries. |
1
|
backoff
|
float
|
The backoff factor. |
1
|
fail_on_status_codes
|
Tuple[int, ...]
|
The status codes to fail on immediately. |
(404,)
|
Returns:
| Type | Description |
|---|---|
Callable[..., R]
|
The wrapped function with retry logic. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | |
sanitize_label(label: str) -> str
Sanitize a label for a Kubernetes resource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label to sanitize. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The sanitized label. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
update_config_map(core_api: k8s_client.CoreV1Api, namespace: str, name: str, data: Dict[str, str]) -> None
Update a Kubernetes config map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Kubernetes CoreV1Api client. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
name
|
str
|
Name of the config map to update. |
required |
data
|
Dict[str, str]
|
Data to store in the config map. |
required |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 | |
update_job(batch_api: k8s_client.BatchV1Api, namespace: str, job_name: str, annotations: Dict[str, str]) -> k8s_client.V1Job
Update a job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_api
|
BatchV1Api
|
Kubernetes batch api. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
job_name
|
str
|
The name of the job to update. |
required |
annotations
|
Dict[str, str]
|
The annotations to update. |
required |
Returns:
| Type | Description |
|---|---|
V1Job
|
The updated job. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 | |
update_secret(core_api: k8s_client.CoreV1Api, namespace: str, secret_name: str, data: Dict[str, Optional[str]]) -> None
Update a Kubernetes secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_api
|
CoreV1Api
|
Client of Core V1 API of Kubernetes API. |
required |
namespace
|
str
|
The namespace in which to update the secret. |
required |
secret_name
|
str
|
The name of the secret to update. |
required |
data
|
Dict[str, Optional[str]]
|
The secret data. If the value is None, the key will be removed from the secret. |
required |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
wait_for_job_to_finish(batch_api: k8s_client.BatchV1Api, core_api: k8s_client.CoreV1Api, namespace: str, job_name: str, backoff_interval: float = 1, maximum_backoff: float = 32, exponential_backoff: bool = False, fail_on_container_waiting_reasons: Optional[List[str]] = None, stream_logs: bool = True, container_name: Optional[str] = None) -> None
Wait for a job to finish.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_api
|
BatchV1Api
|
Kubernetes BatchV1Api client. |
required |
core_api
|
CoreV1Api
|
Kubernetes CoreV1Api client. |
required |
namespace
|
str
|
Kubernetes namespace. |
required |
job_name
|
str
|
Name of the job for which to wait. |
required |
backoff_interval
|
float
|
The interval to wait between polling the job status. |
1
|
maximum_backoff
|
float
|
The maximum interval to wait between polling the job status. |
32
|
exponential_backoff
|
bool
|
Whether to use exponential backoff. |
False
|
fail_on_container_waiting_reasons
|
Optional[List[str]]
|
List of container waiting reasons that will cause the job to fail. |
None
|
stream_logs
|
bool
|
Whether to stream the job logs. |
True
|
container_name
|
Optional[str]
|
Name of the container to stream logs from. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the job failed or timed out. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 | |
wait_pod(kube_client_fn: Callable[[], k8s_client.ApiClient], pod_name: str, namespace: str, exit_condition_lambda: Callable[[k8s_client.V1Pod], bool], timeout_sec: int = 0, exponential_backoff: bool = False, stream_logs: bool = False) -> k8s_client.V1Pod
Wait for a pod to meet an exit condition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kube_client_fn
|
Callable[[], ApiClient]
|
the kube client fn is a function that is called
periodically and is used to get a |
required |
pod_name
|
str
|
The name of the pod. |
required |
namespace
|
str
|
The namespace of the pod. |
required |
exit_condition_lambda
|
Callable[[V1Pod], bool]
|
A lambda which will be called periodically to wait for a pod to exit. The function returns True to exit. |
required |
timeout_sec
|
int
|
Timeout in seconds to wait for pod to reach exit condition, or 0 to wait for an unlimited duration. Defaults to unlimited. |
0
|
exponential_backoff
|
bool
|
Whether to use exponential back off for polling. Defaults to False. |
False
|
stream_logs
|
bool
|
Whether to stream the pod logs to
|
False
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
when the function times out. |
Returns:
| Type | Description |
|---|---|
V1Pod
|
The pod object which meets the exit condition. |
Source code in src/zenml/integrations/kubernetes/kube_utils.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
manifest_utils
Utility functions for building manifests for k8s pods.
Classes
Functions
add_local_stores_mount(pod_spec: k8s_client.V1PodSpec) -> None
Makes changes in place to the configuration of the pod spec.
Configures mounted volumes for stack components that write to a local path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod_spec
|
V1PodSpec
|
The pod spec to update. |
required |
Source code in src/zenml/integrations/kubernetes/manifest_utils.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
add_pod_settings(pod_spec: k8s_client.V1PodSpec, settings: KubernetesPodSettings) -> None
Updates pod spec fields in place if passed in orchestrator settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod_spec
|
V1PodSpec
|
Pod spec to update. |
required |
settings
|
KubernetesPodSettings
|
Pod settings to apply. |
required |
Source code in src/zenml/integrations/kubernetes/manifest_utils.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
build_cron_job_manifest(job_template: k8s_client.V1JobTemplateSpec, cron_expression: str, successful_jobs_history_limit: Optional[int] = None, failed_jobs_history_limit: Optional[int] = None) -> k8s_client.V1CronJob
Build a Kubernetes cron job manifest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_template
|
V1JobTemplateSpec
|
The job template to use for the cron job. |
required |
cron_expression
|
str
|
The cron expression to use for the cron job. |
required |
successful_jobs_history_limit
|
Optional[int]
|
The number of successful jobs to keep. |
None
|
failed_jobs_history_limit
|
Optional[int]
|
The number of failed jobs to keep. |
None
|
Returns:
| Type | Description |
|---|---|
V1CronJob
|
The Kubernetes cron job manifest. |
Source code in src/zenml/integrations/kubernetes/manifest_utils.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
build_job_manifest(job_name: str, pod_template: k8s_client.V1PodTemplateSpec, backoff_limit: Optional[int] = None, ttl_seconds_after_finished: Optional[int] = None, labels: Optional[Dict[str, str]] = None, annotations: Optional[Dict[str, str]] = None, active_deadline_seconds: Optional[int] = None, pod_failure_policy: Optional[Dict[str, Any]] = None, owner_references: Optional[List[k8s_client.V1OwnerReference]] = None) -> k8s_client.V1Job
Build a Kubernetes job manifest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_name
|
str
|
Name of the job. |
required |
pod_template
|
V1PodTemplateSpec
|
The pod template to use for the job. |
required |
backoff_limit
|
Optional[int]
|
The backoff limit for the job. |
None
|
ttl_seconds_after_finished
|
Optional[int]
|
The TTL seconds after finished for the job. |
None
|
labels
|
Optional[Dict[str, str]]
|
The labels to use for the job. |
None
|
annotations
|
Optional[Dict[str, str]]
|
The annotations to use for the job. |
None
|
active_deadline_seconds
|
Optional[int]
|
The active deadline seconds for the job. |
None
|
pod_failure_policy
|
Optional[Dict[str, Any]]
|
The pod failure policy for the job. |
None
|
owner_references
|
Optional[List[V1OwnerReference]]
|
The owner references for the job. |
None
|
Returns:
| Type | Description |
|---|---|
V1Job
|
The Kubernetes job manifest. |
Source code in src/zenml/integrations/kubernetes/manifest_utils.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
build_namespace_manifest(namespace: str, labels: Optional[Dict[str, str]] = None) -> Dict[str, Any]
Build the manifest for a new namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
Kubernetes namespace. |
required |
labels
|
Optional[Dict[str, str]]
|
Optional labels to apply to the namespace. These labels are used to track namespace ownership for cleanup. For example, adding 'zenml-deployment-id' allows us to identify and safely delete namespaces created by ZenML deployments. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Manifest of the new namespace. |
Source code in src/zenml/integrations/kubernetes/manifest_utils.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
build_pod_manifest(pod_name: Optional[str], image_name: str, command: List[str], args: List[str], privileged: bool, pod_settings: Optional[KubernetesPodSettings] = None, service_account_name: Optional[str] = None, env: Optional[Dict[str, str]] = None, labels: Optional[Dict[str, str]] = None, mount_local_stores: bool = False, owner_references: Optional[List[k8s_client.V1OwnerReference]] = None, termination_grace_period_seconds: Optional[int] = 30) -> k8s_client.V1Pod
Build a Kubernetes pod manifest for a ZenML run or step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod_name
|
Optional[str]
|
Name of the pod. |
required |
image_name
|
str
|
Name of the Docker image. |
required |
command
|
List[str]
|
Command to execute the entrypoint in the pod. |
required |
args
|
List[str]
|
Arguments provided to the entrypoint command. |
required |
privileged
|
bool
|
Whether to run the container in privileged mode. |
required |
pod_settings
|
Optional[KubernetesPodSettings]
|
Optional settings for the pod. |
None
|
service_account_name
|
Optional[str]
|
Optional name of a service account. Can be used to assign certain roles to a pod, e.g., to allow it to run Kubernetes commands from within the cluster. |
None
|
env
|
Optional[Dict[str, str]]
|
Environment variables to set. |
None
|
labels
|
Optional[Dict[str, str]]
|
Labels to add to the pod. |
None
|
mount_local_stores
|
bool
|
Whether to mount the local stores path inside the pod. |
False
|
owner_references
|
Optional[List[V1OwnerReference]]
|
List of owner references for the pod. |
None
|
termination_grace_period_seconds
|
Optional[int]
|
The amount of seconds to wait for a pod to shutdown gracefully. |
30
|
Returns:
| Type | Description |
|---|---|
V1Pod
|
Pod manifest. |
Source code in src/zenml/integrations/kubernetes/manifest_utils.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
build_role_binding_manifest_for_service_account(name: str, role_name: str, service_account_name: str, namespace: str = 'default') -> Dict[str, Any]
Build a manifest for a role binding of a service account.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the cluster role binding. |
required |
role_name
|
str
|
Name of the role. |
required |
service_account_name
|
str
|
Name of the service account. |
required |
namespace
|
str
|
Kubernetes namespace. Defaults to "default". |
'default'
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Manifest for a cluster role binding of a service account. |
Source code in src/zenml/integrations/kubernetes/manifest_utils.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
build_secret_manifest(name: str, data: Mapping[str, Optional[str]], namespace: Optional[str] = None, secret_type: str = 'Opaque') -> Dict[str, Any]
Builds a Kubernetes secret manifest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the secret. |
required |
data
|
Mapping[str, Optional[str]]
|
The secret data. |
required |
namespace
|
Optional[str]
|
The namespace to create the secret in. |
None
|
secret_type
|
str
|
The secret type. |
'Opaque'
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The secret manifest. |
Source code in src/zenml/integrations/kubernetes/manifest_utils.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
build_service_account_manifest(name: str, namespace: str = 'default') -> Dict[str, Any]
Build the manifest for a service account.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the service account. |
required |
namespace
|
str
|
Kubernetes namespace. Defaults to "default". |
'default'
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Manifest for a service account. |
Source code in src/zenml/integrations/kubernetes/manifest_utils.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
job_template_manifest_from_job(job: k8s_client.V1Job) -> k8s_client.V1JobTemplateSpec
Build a Kubernetes job template manifest from a job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
V1Job
|
The job manifest to build the template from. |
required |
Returns:
| Type | Description |
|---|---|
V1JobTemplateSpec
|
The job template manifest. |
Source code in src/zenml/integrations/kubernetes/manifest_utils.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
pod_template_manifest_from_pod(pod: k8s_client.V1Pod) -> k8s_client.V1PodTemplateSpec
Build a Kubernetes pod template manifest from a pod.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod
|
V1Pod
|
The pod manifest to build the template from. |
required |
Returns:
| Type | Description |
|---|---|
V1PodTemplateSpec
|
The pod template manifest. |
Source code in src/zenml/integrations/kubernetes/manifest_utils.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
orchestrators
Kubernetes-native orchestration.
Classes
KubernetesOrchestrator(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: ContainerizedOrchestrator
Orchestrator for running ZenML pipelines using native Kubernetes.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
config: KubernetesOrchestratorConfig
property
Returns the KubernetesOrchestratorConfig config.
Returns:
| Type | Description |
|---|---|
KubernetesOrchestratorConfig
|
The configuration. |
settings_class: Optional[Type[BaseSettings]]
property
Settings class for the Kubernetes orchestrator.
Returns:
| Type | Description |
|---|---|
Optional[Type[BaseSettings]]
|
The settings class. |
supported_execution_modes: List[ExecutionMode]
property
Returns the supported execution modes for this flavor.
Returns:
| Type | Description |
|---|---|
List[ExecutionMode]
|
A tuple of supported execution modes. |
validator: Optional[StackValidator]
property
Defines the validator that checks whether the stack is valid.
Returns:
| Type | Description |
|---|---|
Optional[StackValidator]
|
Stack validator. |
delete_schedule(schedule: ScheduleResponse) -> None
Deletes a schedule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schedule
|
ScheduleResponse
|
The schedule to delete. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the cron job name is not found. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 | |
fetch_status(run: PipelineRunResponse, include_steps: bool = False) -> Tuple[Optional[ExecutionStatus], Optional[Dict[str, ExecutionStatus]]]
Refreshes the status of a specific pipeline run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
PipelineRunResponse
|
The run that was executed by this orchestrator. |
required |
include_steps
|
bool
|
If True, also fetch the status of individual steps. |
False
|
Returns:
| Type | Description |
|---|---|
Optional[ExecutionStatus]
|
A tuple of (pipeline_status, step_statuses). |
Optional[Dict[str, ExecutionStatus]]
|
If include_steps is False, step_statuses will be None. |
Tuple[Optional[ExecutionStatus], Optional[Dict[str, ExecutionStatus]]]
|
If include_steps is True, step_statuses will be a dict (possibly empty). |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 | |
get_kube_client(incluster: Optional[bool] = None) -> k8s_client.ApiClient
Getter for the Kubernetes API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
incluster
|
Optional[bool]
|
Whether to use the in-cluster config or not. Overrides
the |
None
|
Returns:
| Type | Description |
|---|---|
ApiClient
|
The Kubernetes API client. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if the Kubernetes connector behaves unexpectedly. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
get_kubernetes_contexts() -> Tuple[List[str], str]
Get list of configured Kubernetes contexts and the active context.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if the Kubernetes configuration cannot be loaded. |
Returns:
| Name | Type | Description |
|---|---|---|
context_name |
List[str]
|
List of configured Kubernetes contexts |
active_context_name |
str
|
Name of the active Kubernetes context. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
get_orchestrator_run_id() -> str
Returns the active orchestrator run id.
Returns:
| Type | Description |
|---|---|
str
|
The orchestrator run id. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
966 967 968 969 970 971 972 973 974 975 976 977 | |
get_pipeline_run_metadata(run_id: UUID) -> Dict[str, MetadataType]
Get general component-specific metadata for a pipeline run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
UUID
|
The ID of the pipeline run. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, MetadataType]
|
A dictionary of metadata. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 | |
get_token_secret_name(snapshot_id: UUID) -> str
Returns the name of the secret that contains the ZenML token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot_id
|
UUID
|
The ID of the snapshot. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The name of the secret that contains the ZenML token. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
402 403 404 405 406 407 408 409 410 411 | |
run_isolated_step(step_run_info: StepRunInfo, environment: Dict[str, str]) -> None
Runs an isolated step on Kubernetes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step_run_info
|
StepRunInfo
|
The step run information. |
required |
environment
|
Dict[str, str]
|
The environment variables to set. |
required |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 | |
should_build_pipeline_image(snapshot: PipelineSnapshotBase) -> bool
Whether to always build the pipeline image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotBase
|
The pipeline snapshot. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether to always build the pipeline image. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
submit_dynamic_pipeline(snapshot: PipelineSnapshotResponse, stack: Stack, environment: Dict[str, str], placeholder_run: Optional[PipelineRunResponse] = None) -> Optional[SubmissionResult]
Submits a dynamic pipeline to the orchestrator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The snapshot of the pipeline. |
required |
stack
|
Stack
|
The stack to use for the pipeline. |
required |
environment
|
Dict[str, str]
|
The environment variables to set in the pipeline. |
required |
placeholder_run
|
Optional[PipelineRunResponse]
|
The placeholder run for the pipeline. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[SubmissionResult]
|
Optional submission result. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | |
submit_pipeline(snapshot: PipelineSnapshotResponse, stack: Stack, base_environment: Dict[str, str], step_environments: Dict[str, Dict[str, str]], placeholder_run: Optional[PipelineRunResponse] = None) -> Optional[SubmissionResult]
Submit a static pipeline to the orchestrator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot to submit. |
required |
stack
|
Stack
|
The stack the pipeline will run on. |
required |
base_environment
|
Dict[str, str]
|
Base environment shared by all steps. This should be set if your orchestrator for example runs one container that is responsible for starting all the steps. |
required |
step_environments
|
Dict[str, Dict[str, str]]
|
Environment variables to set when executing specific steps. |
required |
placeholder_run
|
Optional[PipelineRunResponse]
|
An optional placeholder run for the snapshot. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[SubmissionResult]
|
Optional submission result. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
update_schedule(schedule: ScheduleResponse, update: ScheduleUpdate) -> None
Updates a schedule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schedule
|
ScheduleResponse
|
The schedule to update. |
required |
update
|
ScheduleUpdate
|
The update to apply to the schedule. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the cron job name is not found. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 | |
Modules
dag_runner
DAG runner.
DagRunner(nodes: List[Node], node_startup_function: Callable[[Node], NodeStatus], node_monitoring_function: Callable[[Node], NodeStatus], node_stop_function: Optional[Callable[[Node], None]] = None, interrupt_function: Optional[Callable[[], Optional[InterruptMode]]] = None, monitoring_interval: float = 1.0, monitoring_delay: float = 0.0, interrupt_check_interval: float = 1.0, max_parallelism: Optional[int] = None)
DAG runner.
This class does the orchestration of running the nodes of a DAG. It is running two loops in separate threads: The main thread - checks if any nodes should be skipped or are ready to run, in which case the node will be added to the startup queue - creates a worker thread to start the node and executes it in a thread pool if there are nodes in the startup queue and the maximum parallelism is not reached - periodically checks if the DAG should be interrupted The monitoring thread - monitors the running nodes and updates their status
Initialize the DAG runner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes
|
List[Node]
|
The nodes of the DAG. |
required |
node_startup_function
|
Callable[[Node], NodeStatus]
|
The function to start a node. |
required |
node_monitoring_function
|
Callable[[Node], NodeStatus]
|
The function to monitor a node. |
required |
node_stop_function
|
Optional[Callable[[Node], None]]
|
The function to stop a node. |
None
|
interrupt_function
|
Optional[Callable[[], Optional[InterruptMode]]]
|
Will be periodically called to check if the DAG should be interrupted. |
None
|
monitoring_interval
|
float
|
The interval in which the nodes are monitored. |
1.0
|
monitoring_delay
|
float
|
The delay in seconds to wait between monitoring different nodes. |
0.0
|
interrupt_check_interval
|
float
|
The interval in which the interrupt function is called. |
1.0
|
max_parallelism
|
Optional[int]
|
The maximum number of nodes to run in parallel. |
None
|
Source code in src/zenml/integrations/kubernetes/orchestrators/dag_runner.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
active_nodes: List[Node]
property
Active nodes.
Active nodes are nodes that are either running or starting.
Returns:
| Type | Description |
|---|---|
List[Node]
|
Active nodes. |
running_nodes: List[Node]
property
run() -> Dict[str, NodeStatus]
Run the DAG.
Returns:
| Type | Description |
|---|---|
Dict[str, NodeStatus]
|
The final node states. |
Source code in src/zenml/integrations/kubernetes/orchestrators/dag_runner.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
InterruptMode
Node
Bases: BaseModel
DAG node.
is_finished: bool
property
Whether the node is finished.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the node is finished. |
NodeStatus
kubernetes_orchestrator
Kubernetes-native orchestrator.
KubernetesOrchestrator(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: ContainerizedOrchestrator
Orchestrator for running ZenML pipelines using native Kubernetes.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
config: KubernetesOrchestratorConfig
property
Returns the KubernetesOrchestratorConfig config.
Returns:
| Type | Description |
|---|---|
KubernetesOrchestratorConfig
|
The configuration. |
settings_class: Optional[Type[BaseSettings]]
property
Settings class for the Kubernetes orchestrator.
Returns:
| Type | Description |
|---|---|
Optional[Type[BaseSettings]]
|
The settings class. |
supported_execution_modes: List[ExecutionMode]
property
Returns the supported execution modes for this flavor.
Returns:
| Type | Description |
|---|---|
List[ExecutionMode]
|
A tuple of supported execution modes. |
validator: Optional[StackValidator]
property
Defines the validator that checks whether the stack is valid.
Returns:
| Type | Description |
|---|---|
Optional[StackValidator]
|
Stack validator. |
delete_schedule(schedule: ScheduleResponse) -> None
Deletes a schedule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schedule
|
ScheduleResponse
|
The schedule to delete. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the cron job name is not found. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 | |
fetch_status(run: PipelineRunResponse, include_steps: bool = False) -> Tuple[Optional[ExecutionStatus], Optional[Dict[str, ExecutionStatus]]]
Refreshes the status of a specific pipeline run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
PipelineRunResponse
|
The run that was executed by this orchestrator. |
required |
include_steps
|
bool
|
If True, also fetch the status of individual steps. |
False
|
Returns:
| Type | Description |
|---|---|
Optional[ExecutionStatus]
|
A tuple of (pipeline_status, step_statuses). |
Optional[Dict[str, ExecutionStatus]]
|
If include_steps is False, step_statuses will be None. |
Tuple[Optional[ExecutionStatus], Optional[Dict[str, ExecutionStatus]]]
|
If include_steps is True, step_statuses will be a dict (possibly empty). |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 | |
get_kube_client(incluster: Optional[bool] = None) -> k8s_client.ApiClient
Getter for the Kubernetes API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
incluster
|
Optional[bool]
|
Whether to use the in-cluster config or not. Overrides
the |
None
|
Returns:
| Type | Description |
|---|---|
ApiClient
|
The Kubernetes API client. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if the Kubernetes connector behaves unexpectedly. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
get_kubernetes_contexts() -> Tuple[List[str], str]
Get list of configured Kubernetes contexts and the active context.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if the Kubernetes configuration cannot be loaded. |
Returns:
| Name | Type | Description |
|---|---|---|
context_name |
List[str]
|
List of configured Kubernetes contexts |
active_context_name |
str
|
Name of the active Kubernetes context. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
get_orchestrator_run_id() -> str
Returns the active orchestrator run id.
Returns:
| Type | Description |
|---|---|
str
|
The orchestrator run id. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
966 967 968 969 970 971 972 973 974 975 976 977 | |
get_pipeline_run_metadata(run_id: UUID) -> Dict[str, MetadataType]
Get general component-specific metadata for a pipeline run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
UUID
|
The ID of the pipeline run. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, MetadataType]
|
A dictionary of metadata. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 | |
get_token_secret_name(snapshot_id: UUID) -> str
Returns the name of the secret that contains the ZenML token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot_id
|
UUID
|
The ID of the snapshot. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The name of the secret that contains the ZenML token. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
402 403 404 405 406 407 408 409 410 411 | |
run_isolated_step(step_run_info: StepRunInfo, environment: Dict[str, str]) -> None
Runs an isolated step on Kubernetes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step_run_info
|
StepRunInfo
|
The step run information. |
required |
environment
|
Dict[str, str]
|
The environment variables to set. |
required |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 | |
should_build_pipeline_image(snapshot: PipelineSnapshotBase) -> bool
Whether to always build the pipeline image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotBase
|
The pipeline snapshot. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether to always build the pipeline image. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
submit_dynamic_pipeline(snapshot: PipelineSnapshotResponse, stack: Stack, environment: Dict[str, str], placeholder_run: Optional[PipelineRunResponse] = None) -> Optional[SubmissionResult]
Submits a dynamic pipeline to the orchestrator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The snapshot of the pipeline. |
required |
stack
|
Stack
|
The stack to use for the pipeline. |
required |
environment
|
Dict[str, str]
|
The environment variables to set in the pipeline. |
required |
placeholder_run
|
Optional[PipelineRunResponse]
|
The placeholder run for the pipeline. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[SubmissionResult]
|
Optional submission result. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | |
submit_pipeline(snapshot: PipelineSnapshotResponse, stack: Stack, base_environment: Dict[str, str], step_environments: Dict[str, Dict[str, str]], placeholder_run: Optional[PipelineRunResponse] = None) -> Optional[SubmissionResult]
Submit a static pipeline to the orchestrator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot to submit. |
required |
stack
|
Stack
|
The stack the pipeline will run on. |
required |
base_environment
|
Dict[str, str]
|
Base environment shared by all steps. This should be set if your orchestrator for example runs one container that is responsible for starting all the steps. |
required |
step_environments
|
Dict[str, Dict[str, str]]
|
Environment variables to set when executing specific steps. |
required |
placeholder_run
|
Optional[PipelineRunResponse]
|
An optional placeholder run for the snapshot. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[SubmissionResult]
|
Optional submission result. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
update_schedule(schedule: ScheduleResponse, update: ScheduleUpdate) -> None
Updates a schedule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schedule
|
ScheduleResponse
|
The schedule to update. |
required |
update
|
ScheduleUpdate
|
The update to apply to the schedule. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the cron job name is not found. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 | |
kubernetes_orchestrator_entrypoint
Entrypoint of the Kubernetes master/orchestrator pod.
main() -> None
Entrypoint of the k8s master/orchestrator pod.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the orchestrator pod is not associated with a job. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator_entrypoint.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 | |
parse_args() -> argparse.Namespace
Parse entrypoint arguments.
Returns:
| Type | Description |
|---|---|
Namespace
|
Parsed args. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator_entrypoint.py
81 82 83 84 85 86 87 88 89 90 | |
kubernetes_orchestrator_entrypoint_configuration
Entrypoint configuration for the Kubernetes master/orchestrator pod.
KubernetesOrchestratorEntrypointConfiguration
Entrypoint configuration for the k8s master/orchestrator pod.
get_entrypoint_arguments(snapshot_id: UUID, run_id: Optional[UUID] = None) -> List[str]
classmethod
Gets all arguments that the entrypoint command should be called with.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot_id
|
UUID
|
ID of the snapshot. |
required |
run_id
|
Optional[UUID]
|
Optional ID of the pipeline run. Not set for scheduled runs. |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List of entrypoint arguments. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator_entrypoint_configuration.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
get_entrypoint_command() -> List[str]
classmethod
Returns a command that runs the entrypoint module.
Returns:
| Type | Description |
|---|---|
List[str]
|
Entrypoint command. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator_entrypoint_configuration.py
40 41 42 43 44 45 46 47 48 49 50 51 52 | |
get_entrypoint_options() -> Set[str]
classmethod
Gets all the options required for running this entrypoint.
Returns:
| Type | Description |
|---|---|
Set[str]
|
Entrypoint options. |
Source code in src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator_entrypoint_configuration.py
28 29 30 31 32 33 34 35 36 37 38 | |
pod_settings
Kubernetes pod settings.
Classes
KubernetesPodSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseSettings
Kubernetes Pod settings.
Attributes:
| Name | Type | Description |
|---|---|---|
node_selectors |
Dict[str, str]
|
Node selectors to apply to the pod. |
affinity |
Dict[str, Any]
|
Affinity to apply to the pod. |
tolerations |
List[Dict[str, Any]]
|
Tolerations to apply to the pod. |
resources |
Dict[str, Dict[str, str]]
|
Resource requests and limits for the pod. |
annotations |
Dict[str, str]
|
Annotations to apply to the pod metadata. |
volumes |
List[Dict[str, Any]]
|
Volumes to mount in the pod. |
volume_mounts |
List[Dict[str, Any]]
|
Volume mounts to apply to the pod containers. |
host_ipc |
bool
|
Whether to enable host IPC for the pod. |
scheduler_name |
Optional[str]
|
The name of the scheduler to use for the pod. |
image_pull_secrets |
List[str]
|
Image pull secrets to use for the pod. |
labels |
Dict[str, str]
|
Labels to apply to the pod. |
env |
List[Dict[str, Any]]
|
Environment variables to apply to the container. |
env_from |
List[Dict[str, Any]]
|
Environment variables to apply to the container. |
container_security_context |
Dict[str, Any]
|
Security context settings to apply to all containers in the pod. This allows specifying container-level security attributes such as runAsUser, runAsNonRoot, allowPrivilegeEscalation, etc. Note: This is different from pod-level security context (which can be set via additional_pod_spec_args) as some admission policies require container-level security settings. |
additional_pod_spec_args |
Dict[str, Any]
|
Additional arguments to pass to the pod. These will be applied to the pod spec. |
Source code in src/zenml/config/secret_reference_mixin.py
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
Functions
warn_if_invalid_model_data(data: Any, class_name: str) -> None
Validates the data of a Kubernetes model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to validate. |
required |
class_name
|
str
|
Name of the class of the model. |
required |
Source code in src/zenml/integrations/kubernetes/pod_settings.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
Modules
serialization_utils
Kubernetes serialization utils.
Functions
deserialize_kubernetes_model(data: Dict[str, Any], class_name: str) -> Any
Deserializes a Kubernetes model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
The model data. |
required |
class_name
|
str
|
Name of the Kubernetes model class. |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the data contains values for an invalid attribute. |
Returns:
| Type | Description |
|---|---|
Any
|
The deserialized model. |
Source code in src/zenml/integrations/kubernetes/serialization_utils.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
get_model_class(class_name: str) -> Type[Any]
Gets a Kubernetes model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
class_name
|
str
|
Name of the class to get. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If no Kubernetes model class exists for this name. |
Returns:
| Type | Description |
|---|---|
Type[Any]
|
The model class. |
Source code in src/zenml/integrations/kubernetes/serialization_utils.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
is_model_class(class_name: str) -> bool
Checks whether the given class name is a Kubernetes model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
class_name
|
str
|
Name of the class to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
If the given class name is a Kubernetes model class. |
Source code in src/zenml/integrations/kubernetes/serialization_utils.py
194 195 196 197 198 199 200 201 202 203 204 205 | |
normalize_resource_to_dict(resource: Union[Dict[str, Any], Any]) -> Dict[str, Any]
Normalize a Kubernetes resource to a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
Union[Dict[str, Any], Any]
|
K8s resource (dict, typed model, or dynamic resource). |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Normalized dict with camelCase fields (apiVersion, metadata, etc.). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If resource type is unsupported or serialization fails. |
Source code in src/zenml/integrations/kubernetes/serialization_utils.py
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 55 56 57 58 59 | |
serialize_kubernetes_model(model: Any) -> Dict[str, Any]
Serializes a Kubernetes model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Any
|
The model to serialize. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the model is not a Kubernetes model. |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The serialized model. |
Source code in src/zenml/integrations/kubernetes/serialization_utils.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
service_connectors
Kubernetes Service Connector.
Classes
KubernetesServiceConnector(**kwargs: Any)
Bases: ServiceConnector
Kubernetes service connector.
Source code in src/zenml/service_connectors/service_connector.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
Modules
kubernetes_service_connector
Kubernetes Service Connector.
The Kubernetes Service Connector implements various authentication methods for Kubernetes clusters.
KubernetesAuthenticationMethods
KubernetesBaseConfig
KubernetesServerConfig
KubernetesServerCredentials
KubernetesServiceConnector(**kwargs: Any)
Bases: ServiceConnector
Kubernetes service connector.
Source code in src/zenml/service_connectors/service_connector.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
KubernetesTokenConfig
KubernetesTokenCredentials
KubernetesUserPasswordConfig
KubernetesUserPasswordCredentials
step_operators
Kubernetes step operator.
Classes
KubernetesStepOperator(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: BaseStepOperator
Step operator to run on Kubernetes.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
config: KubernetesStepOperatorConfig
property
Returns the KubernetesStepOperatorConfig config.
Returns:
| Type | Description |
|---|---|
KubernetesStepOperatorConfig
|
The configuration. |
settings_class: Optional[Type[BaseSettings]]
property
Settings class for the Kubernetes step operator.
Returns:
| Type | Description |
|---|---|
Optional[Type[BaseSettings]]
|
The settings class. |
validator: Optional[StackValidator]
property
Validates the stack.
Returns:
| Type | Description |
|---|---|
Optional[StackValidator]
|
A validator that checks that the stack contains a remote container |
Optional[StackValidator]
|
registry and a remote artifact store. |
get_docker_builds(snapshot: PipelineSnapshotBase) -> List[BuildConfiguration]
Gets the Docker builds required for the component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotBase
|
The pipeline snapshot for which to get the builds. |
required |
Returns:
| Type | Description |
|---|---|
List[BuildConfiguration]
|
The required Docker builds. |
Source code in src/zenml/integrations/kubernetes/step_operators/kubernetes_step_operator.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
get_kube_client() -> k8s_client.ApiClient
Get the Kubernetes API client.
Returns:
| Type | Description |
|---|---|
ApiClient
|
The Kubernetes API client. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the service connector returns an unexpected client. |
Source code in src/zenml/integrations/kubernetes/step_operators/kubernetes_step_operator.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
launch(info: StepRunInfo, entrypoint_command: List[str], environment: Dict[str, str]) -> None
Launches a step on Kubernetes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Information about the step run. |
required |
entrypoint_command
|
List[str]
|
Command that executes the step. |
required |
environment
|
Dict[str, str]
|
Environment variables to set in the step operator environment. |
required |
Source code in src/zenml/integrations/kubernetes/step_operators/kubernetes_step_operator.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
Modules
kubernetes_step_operator
Kubernetes step operator implementation.
KubernetesStepOperator(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: BaseStepOperator
Step operator to run on Kubernetes.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
config: KubernetesStepOperatorConfig
property
Returns the KubernetesStepOperatorConfig config.
Returns:
| Type | Description |
|---|---|
KubernetesStepOperatorConfig
|
The configuration. |
settings_class: Optional[Type[BaseSettings]]
property
Settings class for the Kubernetes step operator.
Returns:
| Type | Description |
|---|---|
Optional[Type[BaseSettings]]
|
The settings class. |
validator: Optional[StackValidator]
property
Validates the stack.
Returns:
| Type | Description |
|---|---|
Optional[StackValidator]
|
A validator that checks that the stack contains a remote container |
Optional[StackValidator]
|
registry and a remote artifact store. |
get_docker_builds(snapshot: PipelineSnapshotBase) -> List[BuildConfiguration]
Gets the Docker builds required for the component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotBase
|
The pipeline snapshot for which to get the builds. |
required |
Returns:
| Type | Description |
|---|---|
List[BuildConfiguration]
|
The required Docker builds. |
Source code in src/zenml/integrations/kubernetes/step_operators/kubernetes_step_operator.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
get_kube_client() -> k8s_client.ApiClient
Get the Kubernetes API client.
Returns:
| Type | Description |
|---|---|
ApiClient
|
The Kubernetes API client. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the service connector returns an unexpected client. |
Source code in src/zenml/integrations/kubernetes/step_operators/kubernetes_step_operator.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
launch(info: StepRunInfo, entrypoint_command: List[str], environment: Dict[str, str]) -> None
Launches a step on Kubernetes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Information about the step run. |
required |
entrypoint_command
|
List[str]
|
Command that executes the step. |
required |
environment
|
Dict[str, str]
|
Environment variables to set in the step operator environment. |
required |
Source code in src/zenml/integrations/kubernetes/step_operators/kubernetes_step_operator.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
template_engine
Kubernetes template engine.
Classes
KubernetesTemplateEngine(strict_undefined: bool = True)
Engine for generating Kubernetes resources from Jinja2 templates.
Attributes:
| Name | Type | Description |
|---|---|---|
env |
Jinja2 environment for rendering templates. |
Initialize the template engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strict_undefined
|
bool
|
If True, raise an error for undefined template variables. If False, undefined variables are silently ignored. |
True
|
Source code in src/zenml/integrations/kubernetes/template_engine.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
load_yaml_documents(yaml_content: str) -> List[Dict[str, Any]]
staticmethod
Load one or more YAML documents from a string.
Supports two common Kubernetes YAML patterns:
1. Multiple documents separated by ---:
```yaml
apiVersion: v1 kind: ConfigMap
apiVersion: apps/v1
kind: Deployment
2. Top-level list of resources:yaml
- apiVersion: v1
kind: ConfigMap
- apiVersion: apps/v1
kind: Deployment
```
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yaml_content
|
str
|
YAML string potentially containing multiple documents. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List of resource dictionaries (skips None documents). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If YAML is invalid or contains non-dict documents. |
Source code in src/zenml/integrations/kubernetes/template_engine.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
render_template(file: str, context: Dict[str, Any]) -> List[Dict[str, Any]]
Render a YAML file with optional Jinja2 template context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str
|
Path to the YAML file (local or remote). |
required |
context
|
Dict[str, Any]
|
Optional Jinja2 template context for variable substitution. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List of resource dictionaries. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the template file doesn't exist. |
ValueError
|
If template rendering or YAML parsing fails. |
Source code in src/zenml/integrations/kubernetes/template_engine.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |