-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkubernetes-lb-controller.py
52 lines (42 loc) · 1.51 KB
/
kubernetes-lb-controller.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# kubernetes-lb-controller - Main Controller Module
# This is where we instantiate everything.
#
# Marcelo Feitoza Parisi ([email protected])
import sys
from helpers import globalholders
from helpers import database
from helpers import logutil
from helpers import kubeclient
from helpers import events
# Main :-)
def main():
# Initiate the Database Connection
if(database.connectDB() is False):
logutil.printMessage("Error creating in-memory database")
sys.exit(1)
# Create our "in-memory" Route Table
if(database.createDB() is False):
logutil.printMessage("Error creating in-memory route table")
sys.exit(1)
# Load the IPs into the Route Table
if(database.loadIPList() is False):
logutil.printMessage("Error loading IPs into route table")
sys.exit(1)
# Load Kubernetes API Configuration
if(kubeclient.loadConfig() is False):
logutil.printMessage("Error loading Kubernetes Config")
sys.exit(1)
# Create Kubernetes API Connection
if(kubeclient.connectApi() is False):
logutil.printMessage("Error connecting to Kubernetes API")
sys.exit(1)
# Print the first route table to the file
if(database.readDB() is not False):
logutil.printRoutes(database.readDB())
# Launch our Event Monitor/Handler
logutil.printMessage("Starting the event handler.")
events.launchHandler()
logutil.printMessage("Event handler terminated.")
sys.exit(1)
if __name__ == '__main__':
main()