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

Querying for an event based on InvolvedObject fields #2460

Closed
nathanieltalbot opened this issue Sep 2, 2020 · 4 comments · Fixed by #2498
Closed

Querying for an event based on InvolvedObject fields #2460

nathanieltalbot opened this issue Sep 2, 2020 · 4 comments · Fixed by #2498
Assignees
Labels

Comments

@nathanieltalbot
Copy link

I'm currently trying to write queries for the kubernetes client that allow me to get all of the events for a given deployment. Based on the --v=8 output from kubectl, the URL for the raw GET request to the API should look something like this:

GET
/api/v1/namespaces/{namespace}/events?fieldSelector=involvedObject.name={name}&involvedObject.namespace={namespace}&involvedObject.kind=Deployment&involvedObject.uid={UID}

However, it doesn't seem as if I can make the same query with the DSL syntax. kubernetesClient.v1().events().inNamespace(namespace) doesn't seem to offer a withObject or withInvolvedObject or similar syntax, unless I'm mistaken. Is this possible or is there a reason why it isn't?

The involvedObject field is documented in the Kubernetes API spec here: https://v1-15.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.15/#deploymentcondition-v1-apps

@nathanieltalbot nathanieltalbot changed the title Querying for an event based InvolvedObject fields Querying for an event based on InvolvedObject fields Sep 2, 2020
@rohanKanojia
Copy link
Member

hmm, I think we're just missing it's support in DSL

@rohanKanojia
Copy link
Member

I don't see any problem in adding it :-)

@rohanKanojia
Copy link
Member

@nathanieltalbot : Is this only applicable to Events? On a closer look, I think you should be able to do it by just adding a field selector:

            Map<String, String> fields = new HashMap<>();
            fields.put("involvedObject.name", "foo");
            fields.put("involvedObject.namespace", "rokumar");
            fields.put("involvedObject.kind", "Deployment");
            fields.put("involvedObject.uid", "6d71451a-f8df-11ea-a8ac-0e13a02d8ebd");
            client.v1().events().inNamespace("rokumar")
                    .withFields(fields)
                    .list();

@rohanKanojia
Copy link
Member

But this looks cleaner if we had support for this:

            client.v1().events().inNamespace("rokumar").withInvolvedObject(new ObjectReferenceBuilder()
                    .withName("foo")
                    .withNamespace("rokumar")
                    .withKind("Deployment")
                    .withUid("6d71451a-f8df-11ea-a8ac-0e13a02d8ebd")
                    .build()).list();

rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Sep 17, 2020
Added an `withInvolvedObject(ObjectReference objectReference)` method in Filterable
interface which would transform object references into fieldsSelector values
@rohanKanojia rohanKanojia self-assigned this Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants