Giter VIP home page Giter VIP logo

Comments (8)

brosner avatar brosner commented on July 28, 2024

I am excited to see this feature. The best place to start is to scope out the API call(s) needed to accomplish this. If I were implementing this, I would start with dissecting what kubectl logs does and translate it to API calls that can be made by pykube.

from pykube.

pcm32 avatar pcm32 commented on July 28, 2024

Thanks @brosner. According to http://kubernetes.io/docs/api-reference/v1/operations/ this implies making a GET request to

/api/v1/namespaces/{namespace}/pods/{name}/log

plus some query parameters for the GET. I presume that this should be a method on the Pod object, right, something like

def get_logs(self, container=None):
    url_base = some_pykube_method_that_does_this()
    query_params = { 'pretty': True, ... other query_params}
    if container is not None:
        query_params['container'] = container
    return self.api.get( url_base + 
             '/api/v1/namespaces/' + self.namespace() + '/pods/' +  + '/log', query_params )

this leads me to the following questions:

  • from where in pykube API do I get the base URL for the call?
  • am I correct in passing the GET query parameters as kwargs?

from pykube.

pcm32 avatar pcm32 commented on July 28, 2024

Have made a pull request to solve this issue. Usage is as follows:

pykube_api = HTTPClient(KubeConfig.from_file("/path/to/your/.kube/config_kubecluster"))
pre_pod = Pod.objects(pykube_api).filter(selector="app=yourApp") 
# line above can be changed by any query that returns a Pod
pod_obj = Pod(pykube_api, pre_pod.response['items'][0]) 
log_txt = pod_obj.logs()

from pykube.

Chris-Dee avatar Chris-Dee commented on July 28, 2024

Has there been any progress on this since ? Or is unmerged #38 above still the latest progress?

from pykube.

brosner avatar brosner commented on July 28, 2024

The PR is the latest progress. I hope to spend a few hour session on pykube this week to get many of the PRs wrapped up and merged in.

from pykube.

pcm32 avatar pcm32 commented on July 28, 2024

This is now fixed, and awaiting to be merged on #38 !

from pykube.

tobegit3hub avatar tobegit3hub commented on July 28, 2024

Thanks @pcm32 👍

Looking forward to this feature as well. Can anyone help to review and merge this?

from pykube.

brosner avatar brosner commented on July 28, 2024

This feature will be in 0.14.0.

from pykube.

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.