kubernetes-client / java

Official Java client library for kubernetes
http://kubernetes.io/
Apache License 2.0
3.59k stars 1.91k forks source link

deploy a pod from a Yaml file in kubeadm cluster #653

Closed smaillns closed 4 years ago

smaillns commented 5 years ago

I get this error while trying to deploy a pod from yaml file using k8s client api

java.io.IOException: Unknown apiVersionKind: v1/Pod known kinds are: {} at io.kubernetes.client.util.Yaml.modelMapper(Yaml.java:490) ~[client-java-4.0.0.jar!/:na] at io.kubernetes.client.util.Yaml.load(Yaml.java:184) ~[client-java-4.0.0.jar!/:na] at io.kubernetes.client.util.Yaml.load(Yaml.java:172) ~[client-java-4.0.0.jar!/:na]

The problem occured while using kubeadm, but in minikube it works well !

public void deployPodFromFile(@PathVariable String name) throws IOException, ApiException{

        File file = new File("/~ path"+ name);

        //connect to the API Server
        ApiClient client = Config.defaultClient();
        Configuration.setDefaultApiClient(client);

        V1Pod pod = (V1Pod) Yaml.load(file);
        System.out.println(pod.toString());

        CoreV1Api api = new CoreV1Api();
        api.createNamespacedPod("default",pod,null, null, null);
brendandburns commented 5 years ago

Your cluster is broken in some way (not sure what it is) or your not actually talking to the cluster.

Does kubectl work with the kubeadm cluster?

fejta-bot commented 4 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot commented 4 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot commented 4 years ago

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

k8s-ci-robot commented 4 years ago

@fejta-bot: Closing this issue.

In response to [this](https://github.com/kubernetes-client/java/issues/653#issuecomment-573900074): >Rotten issues close after 30d of inactivity. >Reopen the issue with `/reopen`. >Mark the issue as fresh with `/remove-lifecycle rotten`. > >Send feedback to sig-testing, kubernetes/test-infra and/or [fejta](https://github.com/fejta). >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.