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

create on subresource defunct #173

Open
scones opened this issue Feb 25, 2021 · 1 comment
Open

create on subresource defunct #173

scones opened this issue Feb 25, 2021 · 1 comment

Comments

@scones
Copy link

scones commented Feb 25, 2021

i am trying to create an eviction for a pod using the eviction api.

using

    eviction = K8s::Resource.new(
      apiVersion: "policy/v1beta1",
      "kind": "Eviction",
      "metadata": {
        "name": pod.metadata.name,
        "namespace": pod.metadata.namespace
      }
    )
    $client.api('v1').resource('pods/eviction').create_resource(eviction)

i get:

/gem/path/k8s-client-35b5020f99de/lib/k8s/transport.rb:261:in `parse_response': POST /cluster/path/api/v1/namespaces/some-namespace/pods => HTTP 400 Bad Request: Eviction in version "v1beta1" cannot be handled as a Pod: converting (v1beta1.Eviction) to (core.Pod): Spec not present in src (K8s::Error::BadRequest)

considering https://kubernetes.io/docs/tasks/administer-cluster/safely-drain-node/ the correct path for the post should be
/api/v1/namespaces/some-namespace/pods/some-pod/eviction

this obviously can't work right now, as i have no interface to set the pod within the request.

leaving me to ask for a feature to cover this :)

@scones
Copy link
Author

scones commented Feb 25, 2021

i made a workaround for myself using this:

module K8s
  class ResourceClient
    def create_sub_resource resource
      @transport.request(
        method: 'POST',
        path: path(resource.metadata.name, namespace: resource.metadata.namespace),
        request_object: resource,
        response_class: @resource_class
      )
    end
  end
end

if others have a similar problem.

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