diff --git a/__pycache__/k8s.cpython-38.pyc b/__pycache__/k8s.cpython-38.pyc index 62a6f1f..e799446 100644 Binary files a/__pycache__/k8s.cpython-38.pyc and b/__pycache__/k8s.cpython-38.pyc differ diff --git a/__pycache__/main.cpython-38.pyc b/__pycache__/main.cpython-38.pyc index 8c4648c..8cc028a 100644 Binary files a/__pycache__/main.cpython-38.pyc and b/__pycache__/main.cpython-38.pyc differ diff --git a/k8s.py b/k8s.py index 4771ae4..9bfa0a1 100644 --- a/k8s.py +++ b/k8s.py @@ -30,6 +30,6 @@ def get_used_port(): print(unusedport) return unusedport -def update_port(name): - cp = subprocess.run(['kubectl' 'patch' 'service' name '--type=\'json\'' '-p=\'[{"op": "replace", "path": "/spec/ports/0/nodePort", "value": 31600}]\''], encoding='utf-8', stdout=subprocess.PIPE) +def update_port(name, port): + cp = subprocess.run(['kubectl', 'patch', 'service', name, '--type=\'json\'', '-p=\'[{"op": "replace", "path": "/spec/ports/0/nodePort", "value": {}}]\''.format(port)], encoding='utf-8', stdout=subprocess.PIPE) return cp.stdout diff --git a/main.py b/main.py index 1af8bdd..8776935 100644 --- a/main.py +++ b/main.py @@ -31,11 +31,11 @@ def create_pod(pod: Pod): @app.get("/pods/") def get_pod(): - return {"output": k8s.get_pod()} + return {"pods": k8s.get_pod()} @app.post("/services/") def create_service(service: Service): - callback = k8s.change_port(name) + callback = k8s.change_port(service.name,service.port) return {"result": callback} @app.get("/ports_suggest/")