AS AgentScopeAPI 手册 / API Reference

KubernetesClient

public class KubernetesClient extends BaseClient
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:38–913

Kubernetes 客户端,封装与远端服务的连接和调用。位于 io.agentscope.runtime.sandbox.client.kubernetes 包,继承自 BaseClient。核心成员包括 connect、isConnected、getKubeconfigPath、createContainer、createDeployment、startContainer。

Kubernetes container management client implementation

构造器摘要Constructor Summary

构造器Constructor说明Description
public KubernetesClient()
初始化 `KubernetesClient` 实例。
Creates a new instance.
public KubernetesClient(String kubeconfigPath)
初始化 `KubernetesClient` 实例。
Creates a new instance.
public KubernetesClient(KubernetesClientStarter config)
初始化 `KubernetesClient` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public boolean connect()
建立连接并完成初始化。
Returns the connect.
public boolean connect(String kubeconfigPath)
建立连接并完成初始化。
Connect using kubeconfig file path
public boolean isConnected()
判断是否已连接。
Returns whether the connected.
public String getKubeconfigPath()
获取 `getKubeconfigPath`。
Returns the kubeconfig path.
public ContainerCreateResult createContainer(String containerName, String imageName, List<String> ports, List<VolumeBinding> volumeBindings, Map<String, String> environment, Map<String, Object> runtimeConfig)
创建容器。
Creates the container.
public String createDeployment(String deploymentName, String imageName, List<String> ports, Map<String, Integer> portMapping, List<VolumeBinding> volumeBindings, Map<String, String> environment, Map<String, Object> runtimeConfig)
创建部署。
Creates the deployment.
public void startContainer(String containerId)
启动容器。
Starts the container.
public void stopContainer(String containerId)
停止容器。
Stops the container.
public void removeContainer(String containerId)
移除容器。
Removes the container.
public String getContainerStatus(String containerId)
获取容器状态。
Returns the container status.
public List<V1Pod> listPods()
列出 `listPods`。
Lists the pods.
public List<V1Deployment> listDeployments()
列出 `listDeployments`。
Lists the deployments.
public String getLoadBalancerExternalIP(String containerId)
获取加载均衡器外部 IP。
Returns the load balancer external IP.
public String waitForLoadBalancerExternalIP(String containerId, int timeoutSeconds)
等待用于加载均衡器外部 IP。
Performs the wait for load balancer external IP operation.
public boolean imageExists(String imageName)
设置该参数。
Performs the image exists operation.
public boolean pullImage(String imageName)
设置该参数。
Performs the pull image operation.
public boolean inspectContainer(String containerIdOrName)
设置该参数。
Performs the inspect container operation.

构造器详情Constructor Detail

KubernetesClient

public KubernetesClient()

初始化 KubernetesClient 实例。

Creates a new instance.

源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:51–52

KubernetesClient

public KubernetesClient(String kubeconfigPath)

初始化 KubernetesClient 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
kubeconfigPathStringkubeconfig 路径(类型 `String`)。The kubeconfig path.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:54–57

KubernetesClient

public KubernetesClient(KubernetesClientStarter config)

初始化 KubernetesClient 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
configKubernetesClientStarter配置对象(类型 `KubernetesClientStarter`)。The config.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:59–63

方法详情Method Detail

connect

public boolean connect()

建立连接并完成初始化。

Returns the connect.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:65–111

connect

public boolean connect(String kubeconfigPath)

建立连接并完成初始化。

Connect using kubeconfig file path

参数Parameters
名称Name类型Type说明Description
kubeconfigPathStringkubeconfig 路径(类型 `String`)。kubeconfig file path
返回Returns boolean
返回布尔值,表示判断结果。whether connection is successful
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:119–122

isConnected

public boolean isConnected()

判断是否已连接。

Returns whether the connected.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:124–127

getKubeconfigPath

public String getKubeconfigPath()

获取 getKubeconfigPath。

Returns the kubeconfig path.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:129–131

createContainer

public ContainerCreateResult createContainer(String containerName, String imageName, List<String> ports, List<VolumeBinding> volumeBindings, Map<String, String> environment, Map<String, Object> runtimeConfig)

创建容器。

Creates the container.

参数Parameters
名称Name类型Type说明Description
containerNameString容器名称(类型 `String`)。The container name.
imageNameString图像名称(类型 `String`)。The image name.
portsList<String>ports(类型 `List`)。The ports.
volumeBindingsList<VolumeBinding>volume Bindings(类型 `List`)。The volume bindings.
environmentMap<String, String>环境(类型 `Map`)。The environment.
runtimeConfigMap<String, Object>运行时配置(类型 `Map`)。The runtime config.
返回Returns ContainerCreateResult
返回ContainerCreateResult。Returns container create result.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:159–253

createDeployment

public String createDeployment(String deploymentName, String imageName, List<String> ports, Map<String, Integer> portMapping, List<VolumeBinding> volumeBindings, Map<String, String> environment, Map<String, Object> runtimeConfig)

创建部署。

Creates the deployment.

参数Parameters
名称Name类型Type说明Description
deploymentNameString部署名称(类型 `String`)。The deployment name.
imageNameString图像名称(类型 `String`)。The image name.
portsList<String>ports(类型 `List`)。The ports.
portMappingMap<String, Integer>port Mapping(类型 `Map`)。The port mapping.
volumeBindingsList<VolumeBinding>volume Bindings(类型 `List`)。The volume bindings.
environmentMap<String, String>环境(类型 `Map`)。The environment.
runtimeConfigMap<String, Object>运行时配置(类型 `Map`)。The runtime config.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:295–318

startContainer

public void startContainer(String containerId)

启动容器。

Starts the container.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:467–485

stopContainer

public void stopContainer(String containerId)

停止容器。

Stops the container.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:487–500

removeContainer

public void removeContainer(String containerId)

移除容器。

Removes the container.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:502–523

getContainerStatus

public String getContainerStatus(String containerId)

获取容器状态。

Returns the container status.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:525–546

listPods

public List<V1Pod> listPods()

列出 listPods。

Lists the pods.

返回Returns List<V1Pod>
返回列出。Returns list.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:548–562

listDeployments

public List<V1Deployment> listDeployments()

列出 listDeployments。

Lists the deployments.

返回Returns List<V1Deployment>
返回列出。Returns list.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:564–576

getLoadBalancerExternalIP

public String getLoadBalancerExternalIP(String containerId)

获取加载均衡器外部 IP。

Returns the load balancer external IP.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:578–614

waitForLoadBalancerExternalIP

public String waitForLoadBalancerExternalIP(String containerId, int timeoutSeconds)

等待用于加载均衡器外部 IP。

Performs the wait for load balancer external IP operation.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
timeoutSecondsint超时秒(类型 `int`)。The timeout seconds.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:616–636

imageExists

public boolean imageExists(String imageName)

设置该参数。

Performs the image exists operation.

参数Parameters
名称Name类型Type说明Description
imageNameString图像名称(类型 `String`)。The image name.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:881–887

pullImage

public boolean pullImage(String imageName)

设置该参数。

Performs the pull image operation.

参数Parameters
名称Name类型Type说明Description
imageNameString图像名称(类型 `String`)。The image name.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:889–895

inspectContainer

public boolean inspectContainer(String containerIdOrName)

设置该参数。

Performs the inspect container operation.

参数Parameters
名称Name类型Type说明Description
containerIdOrNameString容器标识或名称(类型 `String`)。The container id or name.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:897–912

继承成员Inherited Members

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.