我的应用程序使用client-java-8.0.2.jar和java1.8.0ü版本。我在使用以下代码创建pod时遇到以下错误,
代码:
// get the default api-client
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api api = new CoreV1Api();
List<V1EnvVar> envVariables = new ArrayList<V1EnvVar>();
for (Map.Entry<String, String> entry : attributes.entrySet()) {
V1EnvVar env = new V1EnvVar();
env.setName(entry.getKey());
env.setValue(entry.getValue());
envVariables.add(env);
}
// create pod of a Kubernetes cluster
V1Pod pod = new V1PodBuilder().withNewMetadata().withName(serviceName).endMetadata().withNewSpec()
.addNewContainer().addAllToEnv(envVariables).withName("www").withImage(dockerImage).endContainer()
.endSpec().build();
pod = api.createNamespacedPod("default", pod, null, null, null);
错误:
Error while creating the cluster:
io.kubernetes.client.openapi.ApiException:
at io.kubernetes.client.openapi.ApiClient.handleResponse(ApiClient.java:979) ~[client-java-api-8.0.2.jar!/:na]
at io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:895) ~[client-java-api-8.0.2.jar!/:na]
at io.kubernetes.client.openapi.apis.CoreV1Api.createNamespacedPodWithHttpInfo(CoreV1Api.java:7902) ~[client-java-api-8.0.2.jar!/:na]
at io.kubernetes.client.openapi.apis.CoreV1Api.createNamespacedPod(CoreV1Api.java:7876) ~[client-java-api-8.0.2.jar!/:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_252]
非常感谢您的意见。
1条答案
按热度按时间dphi5xsq1#
答案是集群名称应该是“小写字母数字字符”
我试着用下面的代码调试这个问题,
我的最新代码,
错误: