java icon indicating copy to clipboard operation
java copied to clipboard

Improved documentation for watching custom resources

Open jmcrawford45 opened this issue 2 years ago • 3 comments

I've been trying for a few hours to figure out what the expected workflow is for watching custom objects. Basically, I want to setup something in scala similar to https://www.baeldung.com/java-kubernetes-watch for custom objects. I followed https://github.com/kubernetes-client/java/wiki/5.-Generate-Java-CRD-Model for generating custom resource classes. I was able to get a resource version by applying a hack I saw in another github issue val tsdList = { clients.head.listClusterCustomObjectCall( ... ) } val response = tsdList.execute() if (response.isSuccessful) { val body = response.body().string() gson .fromJson(body, classOf[CustomResourceList]).getMetadata.getResourceVersion } else null

But, when I try to watch the resource, I get a response with everything (status, type, object) set to null and no clear indicator of what's happening.

val call = clients.head.listClusterCustomObjectCall( ... resourceVersion, if (resourceVersion != null) "NotOlderThan" else null, ... ) val watch: Watch[Object] = Watch.createWatch( clients.head.getApiClient, call, new TypeToken[Response[Object]]() {}.getType)

Is there some other way that custom resources are expected to be handled?

jmcrawford45 avatar May 05 '22 00:05 jmcrawford45

I don't really know Scala, but I assume that Watch[Object] means Watch which returns Object. I think that you want to parameterize your Watch with the concrete type that you generated for your CRD.

The watch example is here: https://github.com/kubernetes-client/java/blob/master/examples/examples-release-15/src/main/java/io/kubernetes/client/examples/WatchExample.java

It is for a built-in type, but I think it should work if you use your generated types.

If it doesn't let us know.

Note that we will need standard Java, not Scala code, since the authors of this project are not necessarily Scala experts.

brendandburns avatar May 06 '22 16:05 brendandburns

I haven't been able to get the watch to work even when using the type of the implementor of KubernetesListObject. I'll try to repro in java or translate what I have currently and share tomorrow. Thanks for looking into this.

jmcrawford45 avatar May 18 '22 23:05 jmcrawford45

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Aug 17 '22 00:08 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Sep 16 '22 00:09 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Oct 16 '22 01:10 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Oct 16 '22 01:10 k8s-ci-robot