crate.operator.exposure module¶
- class crate.operator.exposure.ChangeExposureSubHandler(namespace, name, ref, context, depends_on=None, run_on_dep_failures=False, operation=None)¶
Bases:
StateBasedSubHandlerHandles changes to spec.cluster.exposure between ‘loadbalancer’ and ‘traefik’. Deletes old resources and creates new ones accordingly.
- class crate.operator.exposure.CreateTraefikResourcesSubHandler(namespace, name, ref, context, depends_on=None, run_on_dep_failures=False, operation=None)¶
Bases:
StateBasedSubHandlerCreates Traefik resources during cluster creation.
- async handle(namespace, name, owner_references, dns_record, source_ranges, http_port, postgres_port, logger, **kwargs)¶
- async crate.operator.exposure.create_traefik_resources(owner_references, namespace, name, dns_record, source_ranges, http_port, postgres_port, logger)¶
Create MiddlewareTCP and IngressRouteTCP resources for Traefik exposure.
If source_ranges is non‑empty, a MiddlewareTCP with IP allowlist is created and referenced in the IngressRouteTCP routes. Otherwise, the IngressRouteTCP routes are created without any middleware (no IP restriction).
- Parameters:
owner_references (
Optional[List[V1OwnerReference]]) – Owner references to set on the created resources.namespace (
str) – Kubernetes namespace where the resources will be created.name (
str) – Name of the CrateDB cluster (used in resource names).source_ranges (
Optional[List[str]]) – List of CIDR ranges for IP allowlist.http_port (
int) – Port number for HTTP traffic (default 4200).postgres_port (
int) – Port number for PostgreSQL traffic (default 5432).logger (
Logger) – Logger for operation tracking.
- Return type:
- async crate.operator.exposure.delete_ingress_route_tcps(namespace, name, logger)¶
Delete only the IngressRouteTCP resources (keep middleware if any).
This is used when updating CIDRs from empty to non‑empty, to recreate the ingress routes with the new middleware reference.
- async crate.operator.exposure.delete_middleware_tcp(namespace, name, logger)¶
Delete only the MiddlewareTCP resource.
- async crate.operator.exposure.delete_service(core, namespace, name)¶
Delete the main data service (crate-<name>).
- async crate.operator.exposure.delete_traefik_resources(namespace, name)¶
Delete all Traefik resources owned by this CrateDB cluster.
Deletes the MiddlewareTCP and both IngressRouteTCP resources.
- async crate.operator.exposure.patch_service_exposure(core, namespace, name, new_exposure, source_ranges, dns_record, additional_annotations, logger)¶
Patch the existing crate-<name> service in-place to switch between LoadBalancer and ClusterIP.
- async crate.operator.exposure.update_traefik_ip_restriction(namespace, name, new_cidrs, logger)¶
Create, patch, or delete Traefik MiddlewareTCP based on new CIDRs. Also ensures IngressRouteTCPs reference the middleware if it exists.
Handles four cases: - non‑empty -> non‑empty: patch existing middleware. - non‑empty -> empty: delete middleware and remove reference from ingress routes. - empty -> non‑empty: create middleware and recreate ingress routes to reference it. - empty -> empty: do nothing.