File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 99cert_path_default = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
1010token_path_default = "/var/run/secrets/kubernetes.io/serviceaccount/token"
1111
12+ node_name = os .environ .get ("SVC_BGP_NODE_NAME" )
1213api = os .environ .get ("SVC_BGP_API_ENDPOINT" ,"https://kubernetes.default" )
1314cert_path = os .environ .get ("SVC_BGP_API_CERT" , cert_path_default )
1415token_path = os .environ .get ("SVC_BGP_API_TOKEN" , token_path_default )
@@ -89,25 +90,23 @@ def generate_nodes():
8990
9091 return nodes
9192
92- def build_routes ():
93+ def build_routes (node_name ):
9394 endpoints = generate_endpoints ()
9495 services = generate_services ()
9596 nodes = generate_nodes ()
9697 routes = set ()
9798
9899 for svc in services .values ():
99100 for ep in endpoints [(svc .name ,svc .namespace )]:
100- if ep .node == None and ep .ip != None :
101- routes .add (route (svc .ip ,ep .ip ))
102- elif ep .ip != None :
103- routes .add (route (svc .ip ,nodes [ep .node ].ip ))
101+ if ep .ip == nodes [node_name ].ip :
102+ routes .add (route (svc .ip ,node_name ))
104103
105104 return routes
106105
107106def main ():
108107 old_routes = set ()
109108 while True :
110- routes = build_routes ()
109+ routes = build_routes (node_name )
111110
112111 added_routes = routes - old_routes
113112 deleted_routes = old_routes - routes
Original file line number Diff line number Diff line change @@ -61,10 +61,10 @@ spec:
6161 - name : config-volume
6262 mountPath : /etc/exabgp
6363 env :
64- - name : POD_IP
64+ - name : SVC_BGP_NODE_NAME
6565 valueFrom :
6666 fieldRef :
67- fieldPath : status.podIP
67+ fieldPath : spec.nodeName
6868 command : ["/bin/bash", "/etc/exabgp/start-exabgp.sh"]
6969 restartPolicy : Always
7070 terminationGracePeriodSeconds : 30
You can’t perform that action at this time.
0 commit comments