fabric8io / kubernetes-client

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

How to load Istio resource in kubernetes java client ? #5486

Closed shubhampanth-fareye closed 9 months ago

rohanKanojia commented 1 year ago

@shubhampanth-fareye : Could you please check if this works?

Gateway gateway = client.v1beta1().gateways().load(GatewayExample.class.getResource("/gateway.yml")).get();

You can also check examples section in Istio extension.

shubhampanth-fareye commented 1 year ago

Hi @rohanKanojia

I am using KubernetesClient java client (6.3.1) and i have a virtual service yaml and i want to add this virtual service in the client could you help in the same

rohanKanojia commented 1 year ago

You can check out VirtualServiceExample, you have to load the YAML into object like I showed in previous comment

shubhampanth-fareye commented 1 year ago
    VirtualService virtualService = istioClient.v1beta1().virtualServices().load(
            VirtualServiceExample.class.getResourceAsStream("/virtualService.yaml")
    ).get();  

Can i skip using the POJO VirtualServiceExample in above

rohanKanojia commented 1 year ago

@shubhampanth-fareye : What do you mean by skipping POJO? You can directly apply the YAML like this:

istioClient.v1beta1().virtualServices().inNamespace("default").load(
            VirtualServiceExample.class.getResourceAsStream("/virtualService.yaml")
    ).serverSideApply();
shubhampanth-fareye commented 1 year ago

Actually my yaml is stored in S3 and will be downloading it from there so i cannot use any class as VirtualServiceExample.class

shubhampanth-fareye commented 1 year ago

@rohanKanojia If i already have a targetStream of the yaml file can i directly load it into it

VirtualService virtualService = istioClient.v1beta1().virtualServices().load(targetStream).get();

rohanKanojia commented 1 year ago

@rohanKanojia If i already have a targetStream of the yaml file can i directly load it into it

VirtualService virtualService = istioClient.v1beta1().virtualServices().load(targetStream).get();

I think that should work. Are you facing some error when you run it?

You'd also need to specify namespace using .inNamespace if it's not specified in YAML

sunix commented 1 year ago

hi @shubhampanth-fareye Is your issue resolved ? let us know. Thanks

stale[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!