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

[FEATURE] Get pods status from k8s api #3

Open
kareem-elsayed opened this issue Jun 2, 2020 · 3 comments
Open

[FEATURE] Get pods status from k8s api #3

kareem-elsayed opened this issue Jun 2, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@kareem-elsayed
Copy link
Owner

We can use the /api/v1/watch/pods endpoint to get and watch the status events for the pods instead of using kubectl tool

@kareem-elsayed kareem-elsayed added the enhancement New feature or request label Jun 2, 2020
@kareem-elsayed kareem-elsayed changed the title get pods status from k8s api Get pods status from k8s api Jun 2, 2020
@muhammednagy
Copy link

You could assign this to me if there's no hurry to implement it.

@kareem-elsayed
Copy link
Owner Author

sure @muhammednagy

@kareem-elsayed
Copy link
Owner Author

kareem-elsayed commented Jun 3, 2020

Hi
For now, after first testing how we can deal with /api/v1/watch/pods to fetch the API streaming events
Here's the first approach and what do you think @muhammednagy @MohamedMSaeed @keroloswilliam
here is the reference for more details https://requests.readthedocs.io/en/master/user/advanced/#streaming-requests

import json
import requests

r = requests.get("http://127.0.0.1:8001/api/v1/watch/pods", stream=True)

# fullback encoding for bya-data
if r.encoding is None:
    r.encoding = 'utf-8'
lines = r.iter_lines(decode_unicode=True)
for line in lines:
    if line:
        # load the bya-json to a string
        data = json.loads(line)

        # dumps the json object into an element
        json_data = json.dumps(data['object']['status'], indent=2)
        print(json_data)

@kareem-elsayed kareem-elsayed changed the title Get pods status from k8s api [FEATURE] Get pods status from k8s api Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants