Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getStream() on CRD resources #637

Open
fvedad opened this issue May 20, 2020 · 1 comment
Open

getStream() on CRD resources #637

fvedad opened this issue May 20, 2020 · 1 comment

Comments

@fvedad
Copy link

fvedad commented May 20, 2020

Hi guys,

we realised that using:
client.apis['some.api'].watch.some_plural.getStream()
is no longer supported in 9.0.0.

We tried to do:

const stream = await client.apis["dtk.io"].v1alpha1.some_plural.getStream();
const jsonStream = new JSONStream();
stream.pipe(jsonStream);
jsonStream.on("data", async (event: any) => {
   ...
}

We realise getStream() is deprecated, but getObjectStream() is undefined for this path. If the custom resource is v1alpha1 not sure if there is a better way to watch changes on it?

Using the deprecated getStream(), the event is triggered only the first time. When editing the resource again, this event does not get triggered at all from that point on.

Not sure if there is a new way to approach this problem of doing a watch event on custom resources that may have different versions (v1, v1beta1, v1alpha1, etc)?

Edit: The way the client is loaded is:

let Client = require('kubernetes-client').Client;
let Request = require('kubernetes-client/backends/request');

backend = new Request(Request.config.getInCluster());
client = new Client({ backend: backend });
await client.loadSpec();

Thanks

@fvedad
Copy link
Author

fvedad commented May 21, 2020

Update:

realised it is necessary to addCustomResourceDefinition in order for path to .watch be available. Is there a way to do this without explicitly loading each custom resource definition to the client?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant