KubernetesClient
public class KubernetesClient extends BaseClient
io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:38–913Kubernetes 客户端,封装与远端服务的连接和调用。位于 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
构造器详情Constructor Detail
KubernetesClient
public KubernetesClient()
初始化 KubernetesClient 实例。
Creates a new instance.
io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:51–52KubernetesClient
public KubernetesClient(String kubeconfigPath)
初始化 KubernetesClient 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
kubeconfigPath | String | kubeconfig 路径(类型 `String`)。The kubeconfig path. |
io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:54–57KubernetesClient
public KubernetesClient(KubernetesClientStarter config)
初始化 KubernetesClient 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
config | KubernetesClientStarter | 配置对象(类型 `KubernetesClientStarter`)。The config. |
io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:59–63方法详情Method Detail
connect
public boolean connect()
建立连接并完成初始化。
Returns the connect.
booleanio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:65–111connect
public boolean connect(String kubeconfigPath)
建立连接并完成初始化。
Connect using kubeconfig file path
| 名称Name | 类型Type | 说明Description |
|---|---|---|
kubeconfigPath | String | kubeconfig 路径(类型 `String`)。kubeconfig file path |
booleanio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:119–122isConnected
public boolean isConnected()
判断是否已连接。
Returns whether the connected.
booleanio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:124–127getKubeconfigPath
public String getKubeconfigPath()
获取 getKubeconfigPath。
Returns the kubeconfig path.
Stringio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:129–131createContainer
public ContainerCreateResult createContainer(String containerName, String imageName, List<String> ports, List<VolumeBinding> volumeBindings, Map<String, String> environment, Map<String, Object> runtimeConfig)
创建容器。
Creates the container.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerName | String | 容器名称(类型 `String`)。The container name. |
imageName | String | 图像名称(类型 `String`)。The image name. |
ports | List<String> | ports(类型 `List`)。The ports. |
volumeBindings | List<VolumeBinding> | volume Bindings(类型 `List`)。The volume bindings. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
runtimeConfig | Map<String, Object> | 运行时配置(类型 `Map`)。The runtime config. |
ContainerCreateResultio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:159–253createDeployment
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
deploymentName | String | 部署名称(类型 `String`)。The deployment name. |
imageName | String | 图像名称(类型 `String`)。The image name. |
ports | List<String> | ports(类型 `List`)。The ports. |
portMapping | Map<String, Integer> | port Mapping(类型 `Map`)。The port mapping. |
volumeBindings | List<VolumeBinding> | volume Bindings(类型 `List`)。The volume bindings. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
runtimeConfig | Map<String, Object> | 运行时配置(类型 `Map`)。The runtime config. |
Stringio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:295–318startContainer
public void startContainer(String containerId)
启动容器。
Starts the container.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerId | String | 容器标识(类型 `String`)。The container id. |
io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:467–485stopContainer
public void stopContainer(String containerId)
停止容器。
Stops the container.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerId | String | 容器标识(类型 `String`)。The container id. |
io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:487–500removeContainer
public void removeContainer(String containerId)
移除容器。
Removes the container.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerId | String | 容器标识(类型 `String`)。The container id. |
io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:502–523getContainerStatus
public String getContainerStatus(String containerId)
获取容器状态。
Returns the container status.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerId | String | 容器标识(类型 `String`)。The container id. |
Stringio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:525–546listPods
public List<V1Pod> listPods()
列出 listPods。
Lists the pods.
List<V1Pod>io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:548–562listDeployments
public List<V1Deployment> listDeployments()
列出 listDeployments。
Lists the deployments.
List<V1Deployment>io/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:564–576getLoadBalancerExternalIP
public String getLoadBalancerExternalIP(String containerId)
获取加载均衡器外部 IP。
Returns the load balancer external IP.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerId | String | 容器标识(类型 `String`)。The container id. |
Stringio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:578–614waitForLoadBalancerExternalIP
public String waitForLoadBalancerExternalIP(String containerId, int timeoutSeconds)
等待用于加载均衡器外部 IP。
Performs the wait for load balancer external IP operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerId | String | 容器标识(类型 `String`)。The container id. |
timeoutSeconds | int | 超时秒(类型 `int`)。The timeout seconds. |
Stringio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:616–636imageExists
public boolean imageExists(String imageName)
设置该参数。
Performs the image exists operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
imageName | String | 图像名称(类型 `String`)。The image name. |
booleanio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:881–887pullImage
public boolean pullImage(String imageName)
设置该参数。
Performs the pull image operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
imageName | String | 图像名称(类型 `String`)。The image name. |
booleanio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:889–895inspectContainer
public boolean inspectContainer(String containerIdOrName)
设置该参数。
Performs the inspect container operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerIdOrName | String | 容器标识或名称(类型 `String`)。The container id or name. |
booleanio/agentscope/runtime/sandbox/client/kubernetes/KubernetesClient.java:897–912