Git Product home page Git Product logo

Comments (9)

abonas avatar abonas commented on August 16, 2024

cc @simon3z
@iterion
There is currently an api that should provide you with this functionality via the generic update_entityType methods. (update_pod, update_service, etc) It is not very tested at the moment since so far the gem was more focused on the "GET" part and less on create and updates.
So, you can fetch a replication controller, fill the new number of replicas in the right field, and call to client.update_replication_controller with that entity.
Please check if that api works for you and let me know.
Thank you.

from kubeclient.

iterion avatar iterion commented on August 16, 2024

Thanks, I'll try that out, it'll be useful in the interim.

I think scaling of replicas is something that users might do fairly often, so it'd be useful to have a method to do just that. But, I suppose it's up for discussion if that should be part of this gem or part of a gem that utilizes this one. A specific utility for scaling replicas is part of the Kubernetes CLI, so it might be good to mirror what is offered there.

from kubeclient.

iterion avatar iterion commented on August 16, 2024

Ok, I tried what you suggested but ran into some issues:
My method for scaling:

rc = client.get_replication_controller(rc_name, namespace)
rc.spec.replicas = scale
begin
  resp = client.update_replication_controller(rc)
  puts "Updated rc #{rc.metadata.name}"
  resp
rescue KubeException => e
  puts "Failed to update replication controller: #{e}"
end

I'm guessing it has to do with the difference between PUT and PATCH in the API, I'll do some more investigation.

from kubeclient.

iterion avatar iterion commented on August 16, 2024

Nvm, above issue was due to bug that has already been patched by #97. Scaling as @abonas outlined works correctly!

from kubeclient.

abonas avatar abonas commented on August 16, 2024

Thanks, I'll try that out, it'll be useful in the interim.

I think scaling of replicas is something that users might do fairly often, so it'd be useful to have a method to do just that. But, I suppose it's up for discussion if that should be part of this gem or part of a gem that utilizes this one. A specific utility for scaling replicas is part of the Kubernetes CLI, so it might be good to mirror what is offered there.

I'm currently not in favor of adding custom methods per entity, it's hard to maintain and the goal here is not to mimic the cli, but to allow the work with REST api which is by itself pretty standard and has no custom actions/methods for those things in the server.
Having said that, nothing is carved in stone, and it can be re-evaluated in the future.

from kubeclient.

abonas avatar abonas commented on August 16, 2024

Nvm, above issue was due to bug that has already been patched by #97. Scaling as @abonas outlined works correctly!

Glad to hear! If you want/can add tests for that, you're more than welcome, the gem currently lacks tests for update, and since they also serve as examples for other users, it has a broader impact.

from kubeclient.

abonas avatar abonas commented on August 16, 2024

@iterion I'm closing the issue, feel free to reopen if needed.

from kubeclient.

iterion avatar iterion commented on August 16, 2024

No problem, I totally understand your position and appreciate that this gem even exists! Users might want some utilities around the API, but, I dunno what those are yet and they could be very use case specific (which only strengthens your argument). I'll try to open source any solutions I come up with if they're generic enough.

I do wonder if we could make this gem pluggable in some way? It would be nice if other gems could hook into kubeclient and add any utility methods they like. It might be the best way to preserve the stability of this gem while adding great flexibility and usability for end users. I'd be happy to open an issue for discussion on this topic if you think it might fit within the scope of kubeclient.

from kubeclient.

abonas avatar abonas commented on August 16, 2024

I do wonder if we could make this gem pluggable in some way? It would be nice if other gems could hook into kubeclient and add any utility methods they like. It might be the best way to preserve the stability of this gem while adding great flexibility and usability for end users. I'd be happy to open an issue for discussion on this topic if you think it might fit within the scope of kubeclient.

Please have a look at openshift_client gem - it reuses most of kubeclient's code - maybe it can give you some ideas.
https://github.com/abonas/openshift_client
Also, Ruby is flexible and dynamic, so there should be no restrictions on dynamically adding additional methods defined on top of the existing ones, I'd just currently prefer to not keep such things as part of kubeclient itself.

from kubeclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.