Class K8sHelper
java.lang.Object
io.agentscope.extensions.sandbox.kubernetes.client.internal.K8sHelper
Encapsulates Kubernetes CRD operations for agent-sandbox lifecycle management.
Mirrors the Python SDK's
K8sHelper.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateSandboxClaim(String name, String warmPool, String namespace, Map<String, String> labels, Long shutdownAfterSeconds, Map<String, String> podLabels, Map<String, String> podAnnotations) Creates a SandboxClaim referencing the given warm pool.voiddeleteSandboxClaim(String name, String namespace) Deletes a SandboxClaim.io.fabric8.kubernetes.client.KubernetesClientgetSandbox(String name, String namespace) Gets a Sandbox resource, or null if not found.getSandboxClaim(String name, String namespace) Gets a SandboxClaim, or null if not found.listSandboxClaims(String namespace, String labelSelector) Lists SandboxClaim names in a namespace, optionally filtered by label selector.resolveSandboxName(String claimName, String namespace, long timeoutSeconds) Watches the SandboxClaim until the sandbox name is resolved in its status.static StringselectPodIp(List<String> podIPs) Selects a preferred pod IP (first IPv4 if present, otherwise first entry).waitForSandboxReady(String sandboxName, String namespace, long timeoutSeconds) Waits for a Sandbox resource to become Ready.
-
Constructor Details
-
K8sHelper
public K8sHelper(io.fabric8.kubernetes.client.KubernetesClient client)
-
-
Method Details
-
getClient
public io.fabric8.kubernetes.client.KubernetesClient getClient() -
createSandboxClaim
public SandboxClaim createSandboxClaim(String name, String warmPool, String namespace, Map<String, String> labels, Long shutdownAfterSeconds, Map<String, String> podLabels, Map<String, String> podAnnotations) Creates a SandboxClaim referencing the given warm pool.- Parameters:
name- claim namewarmPool- warm pool namenamespace- Kubernetes namespacelabels- optional claim labelsshutdownAfterSeconds- optional TTL; when set, populatesspec.lifecyclepodLabels- optional labels forspec.additionalPodMetadatapodAnnotations- optional annotations forspec.additionalPodMetadata- Returns:
- the created claim
-
deleteSandboxClaim
Deletes a SandboxClaim. No-op if already deleted.- Parameters:
name- claim namenamespace- namespace
-
getSandboxClaim
Gets a SandboxClaim, or null if not found.- Parameters:
name- claim namenamespace- namespace- Returns:
- claim or null
-
listSandboxClaims
Lists SandboxClaim names in a namespace, optionally filtered by label selector.- Parameters:
namespace- namespacelabelSelector- optional label selector- Returns:
- claim names
-
getSandbox
Gets a Sandbox resource, or null if not found.- Parameters:
name- sandbox namenamespace- namespace- Returns:
- sandbox or null
-
resolveSandboxName
public String resolveSandboxName(String claimName, String namespace, long timeoutSeconds) throws Exception Watches the SandboxClaim until the sandbox name is resolved in its status.- Parameters:
claimName- claim namenamespace- namespacetimeoutSeconds- timeout- Returns:
- resolved sandbox name
- Throws:
Exception
-
waitForSandboxReady
public SandboxResource.SandboxIdentity waitForSandboxReady(String sandboxName, String namespace, long timeoutSeconds) throws Exception Waits for a Sandbox resource to become Ready.- Parameters:
sandboxName- sandbox namenamespace- namespacetimeoutSeconds- timeout- Returns:
- sandbox identity metadata
- Throws:
Exception
-
selectPodIp
Selects a preferred pod IP (first IPv4 if present, otherwise first entry).- Parameters:
podIPs- pod IP list- Returns:
- selected IP or null
-