added an API Server event, also added port 443 to ports discovery

This commit is contained in:
daniel_sagi
2018-08-15 16:46:21 +03:00
parent 615f3d3ace
commit a4dbaaf446
2 changed files with 15 additions and 3 deletions

View File

@@ -2,7 +2,18 @@ import requests
from ...core.types import Hunter
from ...core.events import handler
from ...core.events.types import OpenPortEvent
from ...core.events.types import OpenPortEvent, Service, Event
class ReadOnlyKubeletEvent(Service, Event):
"""The read-only port on the kubelet serves health probing endpoints, and is relied upon by many kubernetes componenets"""
def __init__(self):
Service.__init__(self, name="Kubelet API (readonly)")
class ApiServer(Service, Event):
"""The API server is in charge of all operations on the cluster."""
def __init__(self):
Service.__init__(self, name="API Server")
@handler.subscribe(OpenPortEvent, predicate=lambda x: x.port==443)
class ApiServerDiscovery(Hunter):
@@ -15,4 +26,5 @@ class ApiServerDiscovery(Hunter):
def execute(self):
main_request = requests.get("https://{}:{}".format(self.event.host, self.event.port), verify=False).text
if "code" in main_request:
self.event.role = "Master"
self.event.role = "Master"
self.publish_event(ApiServer())

View File

@@ -5,7 +5,7 @@ from ...core.events import handler
from ...core.events.types import NewHostEvent, OpenPortEvent
default_ports = [8001, 10250, 10255, 30000]
default_ports = [8001, 10250, 10255, 30000, 443]
@handler.subscribe(NewHostEvent)
class PortDiscovery(Hunter):