Skip to content

Any planned support for the Apps endpoints? #369

New issue

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

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

Already on GitHub? # to your account

Closed
cschiewek opened this issue Nov 24, 2018 · 5 comments
Closed

Any planned support for the Apps endpoints? #369

cschiewek opened this issue Nov 24, 2018 · 5 comments

Comments

@cschiewek
Copy link

The Apps endpoint group (Deployments, StatefulSets, DaemonSets, and ReplicaSets) all went GA in 1.9. Are there any plans to add support for these resources?!

@cben
Copy link
Collaborator

cben commented Nov 25, 2018

Kubeclient should support all API groups. Alas, the README is quite unclear about how this works :-(
Try constructing a client with:

Kubeclient::Client.new('https://example.com/apis/apps', 'v1')

(possibly the more logical 'https://example.com/apis', 'apps/v1' works too but that's untested and not yet guaranteed, hope to make it official later)

@cben
Copy link
Collaborator

cben commented Nov 27, 2018

The example you sent me works for me, except you defined apps_endpoint but used api_endpoint — maybe you had a variable with that name too but containing a different url?

pry(main)> config = Kubeclient::Config.read(ENV['KUBECONFIG'] || "#{ENV['HOME']}/.kube/config"); context = config.context
=> #<Kubeclient::Config::Context:0x0000555a0a340fd0
 @api_endpoint="https://127.0.0.1:8443",
...

pry(main)> apps_endpoint = [context.api_endpoint, 'apis/apps'].join('/')
=> "https://127.0.0.1:8443/apis/apps"

pry(main)> apps_client = Kubeclient::Client.new(apps_endpoint, context.api_version, ssl_options: context.ssl_options, auth_options: context.auth_options)
=> #<Kubeclient::Client:0x0000555a0d381d20
 @api_endpoint=#<URI::HTTPS https://127.0.0.1:8443/apis/apps>,
 @api_group="apps/",
 @api_version="v1",
...

pry(main)> RestClient.log = 'stderr'
=> "stderr"

pry(main)> apps_client.discover
RestClient.get "https://127.0.0.1:8443/apis/apps/v1", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "User-Agent"=>"rest-client/2.0.2 (linux-gnu x86_64) ruby/2.4.4p296"
# => 200 OK | application/json 2016 bytes
=> true

pry(main)> apps_client.methods
=> [:get_controller_revisions,
 :watch_controller_revisions,
 :get_controller_revision,
 :delete_controller_revision,
 :create_controller_revision,
 :update_controller_revision,
 :patch_controller_revision,
 :get_daemon_sets,
 :watch_daemon_sets,
 :get_daemon_set,
 :delete_daemon_set,
 :create_daemon_set,
 :update_daemon_set,
 :patch_daemon_set,
 :get_deployments,
 :watch_deployments,
 :get_deployment,
 :delete_deployment,
 :create_deployment,
 :update_deployment,
 :patch_deployment,
 :get_replica_sets,
 :watch_replica_sets,
 :get_replica_set,
 :delete_replica_set,
 :create_replica_set,
 :update_replica_set,
 :patch_replica_set,
 :get_stateful_sets,
 :watch_stateful_sets,
 :get_stateful_set,
 :delete_stateful_set,
 :create_stateful_set,
 :update_stateful_set,
 :patch_stateful_set,
 :method_missing,
...

pry(main)> puts apps_client.rest_client.get.body
RestClient.get "https://127.0.0.1:8443/apis/apps/v1", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "User-Agent"=>"rest-client/2.0.2 (linux-gnu x86_64) ruby/2.4.4p296"
# => 200 OK | application/json 2016 bytes
{"kind":"APIResourceList","apiVersion":"v1","groupVersion":"apps/v1","resources":[{"name":"controllerrevisions","singularName":"","namespaced":true,"kind":"ControllerRevision","verbs":["create","delete","deletecollection","get","list","patch","update","watch"]},{"name":"daemonsets","singularName":"","namespaced":true,"kind":"DaemonSet","verbs":["create","delete","deletecollection","get","list","patch","update","watch"],"shortNames":["ds"],"categories":["all"]},{"name":"daemonsets/status","singularName":"","namespaced":true,"kind":"DaemonSet","verbs":["get","patch","update"]},{"name":"deployments","singularName":"","namespaced":true,"kind":"Deployment","verbs":["create","delete","deletecollection","get","list","patch","update","watch"],"shortNames":["deploy"],"categories":["all"]},{"name":"deployments/scale","singularName":"","namespaced":true,"group":"autoscaling","version":"v1","kind":"Scale","verbs":["get","patch","update"]},{"name":"deployments/status","singularName":"","namespaced":true,"kind":"Deployment","verbs":["get","patch","update"]},{"name":"replicasets","singularName":"","namespaced":true,"kind":"ReplicaSet","verbs":["create","delete","deletecollection","get","list","patch","update","watch"],"shortNames":["rs"],"categories":["all"]},{"name":"replicasets/scale","singularName":"","namespaced":true,"group":"autoscaling","version":"v1","kind":"Scale","verbs":["get","patch","update"]},{"name":"replicasets/status","singularName":"","namespaced":true,"kind":"ReplicaSet","verbs":["get","patch","update"]},{"name":"statefulsets","singularName":"","namespaced":true,"kind":"StatefulSet","verbs":["create","delete","deletecollection","get","list","patch","update","watch"],"shortNames":["sts"],"categories":["all"]},{"name":"statefulsets/scale","singularName":"","namespaced":true,"group":"autoscaling","version":"v1","kind":"Scale","verbs":["get","patch","update"]},{"name":"statefulsets/status","singularName":"","namespaced":true,"kind":"StatefulSet","verbs":["get","patch","update"]}]}
=> nil

pry(main)> apps_client.get_deployments
RestClient.get "https://127.0.0.1:8443/apis/apps/v1/deployments", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "User-Agent"=>"rest-client/2.0.2 (linux-gnu x86_64) ruby/2.4.4p296"
# => 200 OK | application/json 3030 bytes
=> [#<Kubeclient::Deployment metadata={:name=>"webconsole", :namespace=>"openshift-web-console", ...>]

pry(main)> apps_client.get_stateful_sets
RestClient.get "https://127.0.0.1:8443/apis/apps/v1/statefulsets", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "User-Agent"=>"rest-client/2.0.2 (linux-gnu x86_64) ruby/2.4.4p296"
# => 200 OK | application/json 140 bytes
=> []

pry(main)> apps_client.get_replica_sets
RestClient.get "https://127.0.0.1:8443/apis/apps/v1/replicasets", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "User-Agent"=>"rest-client/2.0.2 (linux-gnu x86_64) ruby/2.4.4p296"
# => 200 OK | application/json 2891 bytes
=> [#<Kubeclient::ReplicaSet metadata={:name=>"webconsole-7dfbffd44d", :namespace=>"openshift-web-console", ...>]

pry(main)> apps_client.get_daemon_sets
RestClient.get "https://127.0.0.1:8443/apis/apps/v1/daemonsets", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "User-Agent"=>"rest-client/2.0.2 (linux-gnu x86_64) ruby/2.4.4p296"
# => 200 OK | application/json 136 bytes
=> []

If this still doesn't work for you, please show output of:

RestClient.log = 'stderr'
apps_client.discover
apps_client.methods
puts apps_client.rest_client.get.body  # this is what `discover` got

(calling discover is optional, it's done automatically as soon as you call methods like .get_daemon_sets, just helps to separately see the request that performs)

Another guess: if your k8s API is not at the root of the domain, you might be hitting #318.

@cschiewek
Copy link
Author

I got it working. It's somewhat unfortunate that you have to make 2 clients, but so be it! Thank you for the clarification!

@siegy22
Copy link

siegy22 commented May 19, 2023

@cben Is this still the same as of now? I still need to make two separate kubeclient instances to be able to handle pods and deployments for example?

@cben
Copy link
Collaborator

cben commented May 21, 2023

Same. Nobody is working on this currently that i know.

If you want to get into it, see issues labeled "api groups & versions". imho the first groundwork worth doing is #332, though it's lower-level.

siegy22 added a commit to Prism-Hosting/web that referenced this issue May 24, 2023
Right now as of ManageIQ/kubeclient#369 (comment)
it's not supported that the client can discover multiple APIs at once. Thus we
need to use 3 different ones depending on the API.
This is a preparation to be able to retrieve logs and scale the deployment.
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants