crate.operator.utils.kubeapi module¶
- async crate.operator.utils.kubeapi.call_kubeapi(method, logger, *, continue_on_absence=False, continue_on_conflict=False, namespace=None, body=None, **kwargs)¶
Await a Kubernetes API method and return its result.
If the API fails with an HTTP 404 NOT FOUND error and
continue_on_absence
is set toTrue
a warning is raised andcall_kubeapi
returnsNone
.If the API fails with an HTTP 409 CONFLICT error and
continue_on_conflict
is set toTrue
a warning is raised andcall_kubeapi
returnsNone
.In case of any other error or when either option is set to
False
(default) thekubernetes_asyncio.client.exceptions.ApiException
is re-raised.- Parameters
method (
Callable
[...
,Awaitable
]) – A Kubernetes API function which will be called withnamespace
andbody
, if provided, and all otherkwargs
. The function will also be awaited and the response returned.logger (
Logger
) –continue_on_absence – When
True
, emit a warning instead of an error on HTTP 404 responses.continue_on_conflict – When
True
, emit a warning instead of an error on HTTP 409 responses.namespace (
Optional
[str
]) – The namespace passed to namespaced K8s API endpoints.body (
Optional
[TypeVar
(K8sModel
,V1CronJob
,V1ConfigMap
,V1Deployment
,V1PersistentVolume
,V1PersistentVolumeClaim
,V1Secret
,V1Service
,V1StatefulSet
)]) – The body passed to the K8s API endpoints.
- Return type
Optional
[Awaitable
[TypeVar
(K8sModel
,V1CronJob
,V1ConfigMap
,V1Deployment
,V1PersistentVolume
,V1PersistentVolumeClaim
,V1Secret
,V1Service
,V1StatefulSet
)]]
- async crate.operator.utils.kubeapi.ensure_user_password_label(core, namespace, secret_name)¶
Add the LABEL_USER_PASSWORD label to a namespaced secret.
- async crate.operator.utils.kubeapi.get_host(core, namespace, name)¶
Return the hostname to the CrateDB cluster within the Kubernetes cluster. This uses the “discovery” service for internal access, since the public-facing “crate” service can be IP-restricted.
During testing, the function returns the public IP address, because the operator doesn’t run inside Kubernetes during tests but outside. And the only way to connect to the CrateDB cluster is to go through the public interface.
- async crate.operator.utils.kubeapi.get_service_public_hostname(core, namespace, name)¶
Query the given CrateDB Kubernetes Service fo it’s public IP address / hostname.
- async crate.operator.utils.kubeapi.get_system_user_password(core, namespace, name)¶
Return the password for the system user of cluster
name
innamespace
.
- async crate.operator.utils.kubeapi.resolve_secret_key_ref(core, namespace, secret_key_ref)¶
Lookup the secret value defined by
secret_key_ref
innamespace
.- Parameters
core (
CoreV1Api
) – An instance of the Kubernetes Core V1 API.namespace (
str
) – The namespace where to lookup a secret and its value.secret_key_ref (
SecretKeyRef
) – asecretKeyRef
containing the secret name and key within that holds the desired value.
- Return type