8000 GitHub - wushirenfei/k8s-web-terminal
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

wushirenfei/k8s-web-terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K8S web terminal

A light K8S web terminal demo.

The demo refer to personal blog https://blog.csdn.net/duxiangwushirenfei/article/details/83341574.

Please visit link given to get detail.

Optimize

1, CPU Occupation

Refer to issue: #1, it'll consistently occupy server cup resource, when read data from container by using while True.

This will be resolve by use IO multiplexing just as epoll or select.

You can get container connection socket object in Stream object by stream.sock.sock, for example use select implement async read listen.

class NewK8sThread(threading.Thread):
    
    def __init__(self, ws, stream):
        super(NewK8sThread, self).__init__()
        self.ws = ws
        self.stream = stream
        self.selector = select.epoll()
    
    
    def read(self):
        self.selector.register(self.stream.sock.sock.fileno(), 
                               selectors.EVENT_READ, 
                               self.readable)
    
    def readable(self):
        self.selector.unregister(self.stream.sock.sock.fileno())
        data = self.stream.read_stdout()
        self.ws.send(data)
    
    def run(self):
        self.read()
    

Above NewK8sThread just a pseudocode demo cannot run immediately.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0