prefect_kubernetes.services
¶
Tasks for working with Kubernetes services.
create_namespaced_service
async
¶
Create a namespaced Kubernetes service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kubernetes_credentials |
KubernetesCredentials
|
A |
required |
new_service |
V1Service
|
A |
required |
namespace |
Optional[str]
|
The namespace to create the service in. |
'default'
|
**kube_kwargs |
Optional[Dict[str, Any]]
|
Additional keyword arguments to pass to the |
{}
|
Returns:
Type | Description |
---|---|
V1Service
|
A |
Example
from prefect import flow
from prefect_kubernetes.credentials import KubernetesCredentials
from prefect_kubernetes.services import create_namespaced_service
from kubernetes_asyncio.client.models import V1Service
@flow
def create_service_flow():
v1_service = create_namespaced_service(
kubernetes_credentials=KubernetesCredentials.load("k8s-creds"),
new_service=V1Service(metadata={...}, spec={...}),
)
Source code in prefect_kubernetes/services.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
delete_namespaced_service
async
¶
Delete a namespaced Kubernetes service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kubernetes_credentials |
KubernetesCredentials
|
|
required |
service_name |
str
|
The name of the service to delete. |
required |
delete_options |
Optional[V1DeleteOptions]
|
A |
None
|
namespace |
Optional[str]
|
The namespace to delete the service from. |
'default'
|
**kube_kwargs |
Optional[Dict[str, Any]]
|
Optional extra keyword arguments to pass to the Kubernetes API. |
{}
|
Returns:
Type | Description |
---|---|
V1Service
|
A |
Example
from prefect import flow
from prefect_kubernetes.credentials import KubernetesCredentials
from prefect_kubernetes.services import delete_namespaced_service
@flow
def kubernetes_orchestrator():
delete_namespaced_service(
kubernetes_credentials=KubernetesCredentials.load("k8s-creds"),
service_name="my-service",
namespace="my-namespace",
)
Source code in prefect_kubernetes/services.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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
list_namespaced_service
async
¶
List namespaced Kubernetes services.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kubernetes_credentials |
KubernetesCredentials
|
|
required |
namespace |
Optional[str]
|
The namespace to list services from. |
'default'
|
**kube_kwargs |
Optional[Dict[str, Any]]
|
Optional extra keyword arguments to pass to the Kubernetes API. |
{}
|
Returns:
Type | Description |
---|---|
V1ServiceList
|
A |
Example
from prefect import flow
from prefect_kubernetes.credentials import KubernetesCredentials
from prefect_kubernetes.services import list_namespaced_service
@flow
def kubernetes_orchestrator():
list_namespaced_service(
kubernetes_credentials=KubernetesCredentials.load("k8s-creds"),
namespace="my-namespace",
)
Source code in prefect_kubernetes/services.py
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 |
|
patch_namespaced_service
async
¶
Patch a namespaced Kubernetes service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kubernetes_credentials |
KubernetesCredentials
|
|
required |
service_name |
str
|
The name of the service to patch. |
required |
service_updates |
V1Service
|
A |
required |
namespace |
Optional[str]
|
The namespace to patch the service in. |
'default'
|
**kube_kwargs |
Optional[Dict[str, Any]]
|
Optional extra keyword arguments to pass to the Kubernetes API. |
{}
|
Returns:
Type | Description |
---|---|
V1Service
|
A |
Example
from prefect import flow
from prefect_kubernetes.credentials import KubernetesCredentials
from prefect_kubernetes.services import patch_namespaced_service
from kubernetes_asyncio.client.models import V1Service
@flow
def kubernetes_orchestrator():
patch_namespaced_service(
kubernetes_credentials=KubernetesCredentials.load("k8s-creds"),
service_name="my-service",
new_service=V1Service(metadata={...}, spec={...}),
namespace="my-namespace",
)
Source code in prefect_kubernetes/services.py
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 |
|
read_namespaced_service
async
¶
Read a namespaced Kubernetes service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kubernetes_credentials |
KubernetesCredentials
|
|
required |
service_name |
str
|
The name of the service to read. |
required |
namespace |
Optional[str]
|
The namespace to read the service from. |
'default'
|
**kube_kwargs |
Optional[Dict[str, Any]]
|
Optional extra keyword arguments to pass to the Kubernetes API. |
{}
|
Returns:
Type | Description |
---|---|
V1Service
|
A |
Example
from prefect import flow
from prefect_kubernetes.credentials import KubernetesCredentials
from prefect_kubernetes.services import read_namespaced_service
@flow
def kubernetes_orchestrator():
read_namespaced_service(
kubernetes_credentials=KubernetesCredentials.load("k8s-creds"),
service_name="my-service",
namespace="my-namespace",
)
Source code in prefect_kubernetes/services.py
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 |
|
replace_namespaced_service
async
¶
Replace a namespaced Kubernetes service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kubernetes_credentials |
KubernetesCredentials
|
|
required |
service_name |
str
|
The name of the service to replace. |
required |
new_service |
V1Service
|
A |
required |
namespace |
Optional[str]
|
The namespace to replace the service in. |
'default'
|
**kube_kwargs |
Optional[Dict[str, Any]]
|
Optional extra keyword arguments to pass to the Kubernetes API. |
{}
|
Returns:
Type | Description |
---|---|
V1Service
|
A |
Example
from prefect import flow
from prefect_kubernetes.credentials import KubernetesCredentials
from prefect_kubernetes.services import replace_namespaced_service
from kubernetes_asyncio.client.models import V1Service
@flow
def kubernetes_orchestrator():
replace_namespaced_service(
kubernetes_credentials=KubernetesCredentials.load("k8s-creds"),
service_name="my-service",
new_service=V1Service(metadata={...}, spec={...}),
namespace="my-namespace",
)
Source code in prefect_kubernetes/services.py
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 |
|