fabric8io / kubernetes-client

Java client for Kubernetes & OpenShift
http://fabric8.io
Apache License 2.0
3.41k stars 1.46k forks source link

io.fabric8.kubernetes-client:version6.13.0 io.sundr.builder-annotations:version0.103.1 #6103

Open mafei-github opened 4 months ago

mafei-github commented 4 months ago
java: java.lang.IllegalStateException: No template renderer found for:jar:file:/D:/Maven/apache-maven-3.8.5/conf/repository/io/fabric8/kubernetes-model-gatewayapi/6.13.0/kubernetes-model-gatewayapi-6.13.0.jar!/manifest.vm
java.lang.RuntimeException: java.lang.IllegalStateException: No template renderer found for:jar:file:/D:/Maven/apache-maven-3.8.5/conf/repository/io/fabric8/kubernetes-model-gatewayapi/6.13.0/kubernetes-model-gatewayapi-6.13.0.jar!/manifest.vm
    at com.sun.tools.javac.main.Main.compile(Main.java:553)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
    at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:239)
    at org.jetbrains.jps.javac.ExternalJavacProcess.compile(ExternalJavacProcess.java:189)
    at org.jetbrains.jps.javac.ExternalJavacProcess.access$400(ExternalJavacProcess.java:28)
    at org.jetbrains.jps.javac.ExternalJavacProcess$CompilationRequestsHandler$1.run(ExternalJavacProcess.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)
Caused by: java.lang.IllegalStateException: No template renderer found for:jar:file:/D:/Maven/apache-maven-3.8.5/conf/repository/io/fabric8/kubernetes-model-gatewayapi/6.13.0/kubernetes-model-gatewayapi-6.13.0.jar!/manifest.vm
    at io.sundr.transform.internal.TemplateTransformationProcessor.lambda$process$0(TemplateTransformationProcessor.java:141)
    at java.util.Optional.orElseThrow(Optional.java:290)
    at io.sundr.transform.internal.TemplateTransformationProcessor.process(TemplateTransformationProcessor.java:141)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    ... 9 more
manusa commented 4 months ago

Could you share more details about your project?

It might be that your jar archive is corrupt or your project is having trouble loading it. The mentioned resource does exist in the officially released artifact: https://repo1.maven.org/maven2/io/fabric8/kubernetes-model-gatewayapi/6.13.0/kubernetes-model-gatewayapi-6.13.0.jar

mafei-github commented 4 months ago

8BAAE537-E693-4d88-969F-3602F070DBD9 Is this necessary? How do you use it?

manusa commented 4 months ago

This is used to generate the META-INF/services/io.fabric8.kubernetes.api.model.KubernetesResource file at the Kubernetes Client compile time.

It's not necessary for downstream usage. If you are using the Kubernetes Client in your project, then this is not a required resource From your screenshot, I'm completely confused about what you're trying to do. For some reason it looks like if you're actually recompiling the Kubernetes Client project.

mafei-github commented 4 months ago

1: 图片 2: 图片 Are these two steps the way to use Java to access Volcano? How to create a pod inside a container?

mafei-github commented 4 months ago

图片 This is a pod created before, it is possible 图片 图片 图片 May I ask why this cannot inherit the client's IP and port

manusa commented 4 months ago

That code is sort of deprecated.

The way you should instantiate your client for Volcano (or any other extension or model type) is by:

try (
  KubernetesClient kc = new KubernetesClientBuilder().build();
  VolcanoClient volcanoClient = kc.adapt(VolcanoClient.class)
) {
  volcanoClient.//...
}

May I ask why this cannot inherit the client's IP and port

That's weird, both clients are initialized the same way.

Anyway, as you can see in the previous snippet, the right approach is to adapt your original client to a volcano client: client.adapt(VolcanoClient.class).queues().//...

mafei-github commented 3 months ago

图片 图片 图片

rohanKanojia commented 3 months ago

@mafei-github : Could you please share code snippets instead of screenshots? Could you please check with kubectl whether you have v1beta1.VolcanoJob resource installed in your Kubernetes cluster?

mafei-github commented 3 months ago

图片 queue、podgroup volcanojob?

mafei-github commented 3 months ago

How to create volcanojob in this project

rohanKanojia commented 3 months ago

@mafei-github : It looks like VolcanoJob resource isn't added to the model of volcano extension. We need to add it to the model and client DSL

mafei-github commented 3 months ago

public interface V1beta1APIGroupDSL extends Client { MixedOperation<PodGroup, PodGroupList, Resource> podGroups(); MixedOperation<Queue, QueueList, Resource> queues(); MixedOperation<VolcanoJob, VolcanoJobList, Resource> volcanoJobs(); }

VolcanoJob volcanoJob = new VolcanoJobBuilder() .withNewMetadata() .withNamespace(namespace) .withName("test-job") .withLabels(baseLabels) // .withResourceVersion("66").withSelfLink("/apis/scheduling.volcano.sh/v1beta1/volcanojob/test-job") .endMetadata() .withNewSpec() .withSchedulerName("volcano") .withMinAvailable(1) .withWeight(2) .withPriorityClassName("high-priority") .withMaxRetry(3) .withQueue("queue.com") .withVolumeMounts(volumeMounts) .withVolumes(volumes) .withTasks(tasks) .endSpec() .build(); VolcanoJob orReplace = defaultVolcanoClient.v1beta1().volcanoJobs().inNamespace(namespace).createOrReplace(volcanoJob);

public class V1beta1APIGroupClient extends ClientAdapter implements V1beta1APIGroupDSL { @Override public V1beta1APIGroupClient newInstance() { return new V1beta1APIGroupClient(); }

@Override
public MixedOperation<PodGroup, PodGroupList, Resource<PodGroup>> podGroups() {
    return resources(PodGroup.class, PodGroupList.class);
}

@Override
public MixedOperation<Queue, QueueList, Resource<Queue>> queues() {
    return resources(Queue.class, QueueList.class);
}

@Override
public MixedOperation<VolcanoJob, VolcanoJobList, Resource<VolcanoJob>> volcanoJobs() {
    return resources(VolcanoJob.class, VolcanoJobList.class);
}

}

java.lang.IllegalStateException: No adapter available for type:class com.dmai.model.common.k8s.volcano.client.V1beta1APIGroupClient

rohanKanojia commented 3 months ago

@mafei-github Is it possible for you to create a draft pull request? It'll be easier to check with that.

mafei-github commented 3 months ago

2NPU-volcanojob.txt java.lang.IllegalStateException: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "volumes": com.dmai.model.common.k8s.volcano.model.src.scheduling.VolcanoJobSpec#setVolumes(1 params) vs com.dmai.model.common.k8s.volcano.model.src.scheduling.VolcanoJobSpec#setVolumeMounts(1 params)

mafei-github commented 3 months ago

step one:create queue 图片 is ok 图片

step two:create podgroup 图片 is ok 图片 The queue and podgroup in the first two steps actually refers to this project

step three:create volcanojob 图片 It's not ok I modified this based on the original k8s job reference

manusa commented 3 months ago

Could you please create a GitHub repository with some sort of reproducer (or whatever public code you already have). Maybe this way we can provide better suggestions. Otherwise it's hard for us to understand what problems you're facing.

mafei-github commented 3 months ago

图片 图片

mafei-github commented 3 months ago

图片 图片

rohanKanojia commented 3 months ago

@mafei-github : Could you please provide a resource where all volcano resources and supported apiGroups are listed? We can add them in upcoming release.

mafei-github commented 3 months ago

Do we need to support this interface on the k8s SDK? Does the latest version of K8S currently not support this interface?

mafei-github commented 3 months ago

图片 Does this not support v1alpha1 version?

rohanKanojia commented 3 months ago

@mafei-github : No, it doesn't look like we support it at the moment.

Would it be possible for you to contribute these to KubernetesClient ?

mafei-github commented 3 months ago

Of course I am willing, what should I do? 图片

I am using this template Do I need any more information to create this error message using the k8s client in Java?

rohanKanojia commented 3 months ago

@mafei-github : Okay, let me try to explain the steps:

Model Generation

To add new resources to Volcano Model, you would need to edit extensions/volcano/generator-v1beta1/cmd/generate/generate.go and then issue make (requires GoLang 1.21) in generator-v1beta1 . You can also run build inside a docker container:

sh kubernetes-model-generator/generateModelDocker.sh extensions/volcano/generator-v1beta1

If you want to add other apiGroups v1alpha1 you would need to add new module generator-v1alpha1 andmodel-v1alpha1` respectively

VolcanoClient DSL changes

In order to make these added types available in VolcanoClient, you would need to add new resources in V1beta1APIGroupDSL and V1beta1APIGroupClient . For new resources in v1alpha1 apiGroup, equivalent V1Alpha1APIGroupDSL and V1Alpha1APIGroupClient would need to be created.

Similar Pull Request

There is a similar old pull request that adds some resource types to volcano extension https://github.com/fabric8io/kubernetes-client/pull/3849

manusa commented 3 months ago

Besides this, remember that you can also use the official CRDs published by Volcano in conjunction with the Java generator Maven Plugin: https://github.com/fabric8io/kubernetes-client/blob/main/doc/java-generation-from-CRD.md

mafei-github commented 3 months ago

Do I need to refer to this template myself and write the code for the V1Alpha1APIGroupDSL extension that supports Volcano for this project?https://github.com/fabric8io/kubernetes-client/pull/3849

rohanKanojia commented 3 months ago

@mafei-github : Sorry I don't understand. Is your question reply to Marc's comment about using the Java Generator or to my comment about submitting a PR?

mafei-github commented 3 months ago

图片

rohanKanojia commented 3 months ago

@mafei-github : If you want to solve problem just for yourself (generate Volcano Java classes from CRD) . Follow https://github.com/fabric8io/kubernetes-client/blob/main/doc/java-generation-from-CRD.md?rgh-link-date=2024-07-18T08%3A44%3A53Z

write the code for the V1Alpha1APIGroupDSL extension that supports Volcano for this project?

If you want to modify the codebase to provide support for new Volcano types, you would need to add code

mafei-github commented 3 months ago

According to this tutorial, can I solve the problem I am currently facing

rohanKanojia commented 3 months ago

@mafei-github : I haven't tried it myself but you should be able to do it.

You need to place volcano CRDs in project and then configure java-generator-maven-plugin to generate Java classes corresponding to missing volcano CRDs. See this blogpost for more details : How to generate code using Fabric8 Kubernetes Client Then you can use KubernetesClient to interact with volcano resources like this:

kubernetesClient.resources(VolcanoJob.class, VolcanoJobList.class).inNamespace("default").list()
mafei-github commented 2 months ago

this is why? 图片

rohanKanojia commented 2 months ago

@mafei-github : Have you added entry for v1alpha1 client here?

https://github.com/fabric8io/kubernetes-client/blob/6b7abd95db9ca554b81dee165ec9fb7bfe86ed8d/extensions/volcano/client/src/main/java/io/fabric8/volcano/client/VolcanoExtensionAdapter.java#L37-L38

mafei-github commented 2 months ago

It still doesn't work? 图片

rohanKanojia commented 2 months ago

@mafei-github : You're missing @Override annotation.

You need to add both clients, something like this:

  @Override
  public void registerClients(ClientFactory factory) {
    factory.register(V1beta1APIGroupDSL.class, new V1beta1APIGroupClient());
    factory.register(V1alpha1APIGroupDSL.class, new V1alpha1APIGroupClient());
  }
mafei-github commented 2 months ago

It still doesn't work?? ![Uploading 图片.png…]() I'll interrupt, the program didn't include this method

rohanKanojia commented 2 months ago

@mafei-github : Please push your changes in some branch and share it with us. It's really hard to figure out what you're missing just looking at these screenshots.

mafei-github commented 2 months ago

ok. But I still don't have permission through Gitub or using tokens? remote: Permission to fabric8io/kubernetes-client.git denied to mafei-github. fatal: unable to access 'https://github.com/fabric8io/kubernetes-client/': The requested URL returned error: 403 图片

rohanKanojia commented 2 months ago

@mafei-github : You need to fork the project and push your branch to your fork. Then you can create a pull request to merge your branch (in your fork) to Fabric8 Kubernetes Client main

mafei-github commented 2 months ago

图片 图片 图片 remote: Permission to fabric8io/kubernetes-client.git denied to mafei-github. fatal: unable to access 'https://github.com/fabric8io/kubernetes-client.git/': The requested URL returned error: 403

rohanKanojia commented 2 months ago

@mafei-github : please take a look at my previous comment https://github.com/fabric8io/kubernetes-client/issues/6103#issuecomment-2283089639

You need to push your branch to https://github.com/mafei-github/kubernetes-client.git (You need to fork the project to create this repository) not https://github.com/fabric8io/kubernetes-client.git

mafei-github commented 2 months ago

ok, https://github.com/mafei-github/kubernetes-client.git 图片 图片 Please help me check if there are any issues. Thank you

mafei-github commented 2 months ago

Failure executing: POST at: https://10.196.10.137:6453/apis/batch.volcano.sh/v1alpha1/jobs. Message: Not Found. but 图片 图片 Is it due to inconsistency between the kubectl version and Kubernetes version?

mafei-github commented 2 months ago

357650532-90661f7e-1a4e-4ae3-95e5-81bd8a7a29db

I have written these contents in the local project, which can be done for queue and podgroup, but not for job

mafei-github commented 2 months ago

Can you answer my question?

rohanKanojia commented 2 months ago

@mafei-github : I'll try to pull your branch and check it later today. If I find something wrong, I'll try to push to your branch

mafei-github commented 2 months ago

@rohanKanojia Thank you

mafei-github commented 2 months ago

I have noticed a phenomenon, defaultVolcanoClient.queues().createOrReplace(queue);This code is normal,because By default, client.podGroups() use v1beta1 version, but defaultVolcanoClient.v1beta1().queues().createOrReplace(queue); No adapter available for type:class com.dmai.model.common.k8s.volcano.client.impl.V1beta1APIGroupClient As long as I specify the version, an error will occur,v1beta1 or v1alpha1, 图片

mafei-github commented 2 months ago

@rohanKanojia Can you answer my question? Thank you