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

Add support for EndpointSlice in KubernetesClient #2702

Closed
rohanKanojia opened this issue Jan 4, 2021 · 0 comments · Fixed by #2771
Closed

Add support for EndpointSlice in KubernetesClient #2702

rohanKanojia opened this issue Jan 4, 2021 · 0 comments · Fixed by #2771
Assignees
Labels
bug component/kubernetes-model Deals with the kubernetes-model
Milestone

Comments

@rohanKanojia
Copy link
Member

Right now we don't have DSL support for EndpointSlice in KubernetesClient. We should add something like this:

try (KubernetesClient client = new DefaultKubernetesClient()) {
  EndpointSlice endpointSlice = new EndpointSliceBuilder()
                                  // ..
                                  .build();
   
  client.discovery().v1beta1().endpointSlices().inNamespace("ns1").createOrReplace(endpointSlice);
}

When I try to create it using generic resource API, like this:

try (KubernetesClient client = new DefaultKubernetesClient()) {
    EndpointSlice endpointSlice = new EndpointSliceBuilder()
            .withNewMetadata()
            .withName("example-abc")
            .addToLabels("kubernetes.io/service-name", "example")
            .endMetadata()
            .withAddressType("IPv4")
            .addNewPort()
            .withName("http")
            .withPort(80)
            .endPort()
            .addNewEndpoint()
            .withAddresses("10.1.2.3")
            .withNewConditions().withReady(true).endConditions()
            .withHostname("pod-1")
            .addToTopology("kubernetes.io/hostname", "node-1")
            .addToTopology("topology.kubernetes.io/zone", "us-west2-a")
            .endEndpoint()
            .build();

    client.resource(endpointSlice).inNamespace("default").createOrReplace();
}

I get this error:

[main] WARN io.fabric8.kubernetes.client.internal.VersionUsageUtils - The client is using resource type 'endpointslices' with unstable version 'v1beta1'
Exception in thread "main" io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://192.168.39.3:8443/apis/discovery/v1beta1/namespaces/default/endpointslices. Message: 404 page not found
.
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.requestFailure(OperationSupport.java:570)

Looks like this should be modified to discovery.k8s.io:

-    {"k8s.io/api/discovery/v1beta1", "", "io.fabric8.kubernetes.api.model.discovery", "kubernetes_discovery_", true},
+    {"k8s.io/api/discovery/v1beta1", "discovery.k8s.io", "io.fabric8.kubernetes.api.model.discovery", "kubernetes_discovery_", true},

{"k8s.io/api/discovery/v1beta1", "", "io.fabric8.kubernetes.api.model.discovery", "kubernetes_discovery_", true},

@manusa manusa added bug component/kubernetes-model Deals with the kubernetes-model labels Jan 7, 2021
@manusa manusa added this to the 5.0.1 milestone Jan 7, 2021
@manusa manusa modified the milestones: 5.0.1, 5.1.0 Jan 20, 2021
@rohanKanojia rohanKanojia self-assigned this Feb 1, 2021
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Feb 1, 2021
Moving EndpointSlice resource to apiVersion specific package name, I
future if this api gets promoted to v1, we would have lesser problems
adding it.

Related to fabric8io#2702
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Feb 1, 2021
Added DSL method `client.discovery()` which which user should be able
to use `EndpointSlice` resource
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Feb 1, 2021
Added DSL method `client.discovery()` which which user should be able
to use `EndpointSlice` resource
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Feb 1, 2021
Moving EndpointSlice resource to apiVersion specific package name, I
future if this api gets promoted to v1, we would have lesser problems
adding it.

Related to fabric8io#2702
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Feb 1, 2021
Added DSL method `client.discovery()` which which user should be able
to use `EndpointSlice` resource
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Feb 1, 2021
Moving EndpointSlice resource to apiVersion specific package name, I
future if this api gets promoted to v1, we would have lesser problems
adding it.

Related to fabric8io#2702
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Feb 1, 2021
Added DSL method `client.discovery()` which which user should be able
to use `EndpointSlice` resource
manusa pushed a commit that referenced this issue Feb 2, 2021
Moving EndpointSlice resource to apiVersion specific package name, I
future if this api gets promoted to v1, we would have lesser problems
adding it.

Related to #2702
manusa pushed a commit that referenced this issue Feb 2, 2021
Added DSL method `client.discovery()` which which user should be able
to use `EndpointSlice` resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component/kubernetes-model Deals with the kubernetes-model
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants