From a02e59ef9754c8636ffc4a24614fbc5cb355cc2a Mon Sep 17 00:00:00 2001 From: dasbd72 Date: Sun, 24 Sep 2023 21:09:53 +0800 Subject: [PATCH] read ETCD_HOST from env var --- pkg/ETCD_HOST | 1 - pkg/wrapper.py | 11 ++--------- yamls/apps-disk.yaml | 8 ++++---- yamls/apps.yaml | 8 ++++---- yamls/manager-disk.yaml | 2 ++ yamls/manager.yaml | 2 ++ yamls/new-apps.yaml | 6 ++++++ 7 files changed, 20 insertions(+), 18 deletions(-) delete mode 100644 pkg/ETCD_HOST diff --git a/pkg/ETCD_HOST b/pkg/ETCD_HOST deleted file mode 100644 index a85ca0c..0000000 --- a/pkg/ETCD_HOST +++ /dev/null @@ -1 +0,0 @@ -10.121.240.143 \ No newline at end of file diff --git a/pkg/wrapper.py b/pkg/wrapper.py index 559e6fc..9eae16c 100644 --- a/pkg/wrapper.py +++ b/pkg/wrapper.py @@ -45,11 +45,7 @@ def __init__( self.endpoint: str = endpoint self.force_remote: bool = force_remote - if os.path.exists("ETCD_HOST"): - with open("ETCD_HOST", "r") as f: - self.etcd_host = f.read() - else: - self.etcd_host = None + self.etcd_host = os.getenv("ETCD_HOST", "localhost:2379") logging.info(f"ETCD_HOST: {self.etcd_host}") try: @@ -57,10 +53,7 @@ def __init__( except Exception as e: logging.error("Initialize etcd fail: {}".format(e)) - if "STORAGE_PATH" in os.environ.keys(): - self.storage_path = os.environ["STORAGE_PATH"] - else: - self.storage_path = None + self.storage_path = os.getenv("STORAGE_PATH", None) logging.info(f"STORAGE_PATH: {self.storage_path}") # Read data serve ip:port from storage diff --git a/yamls/apps-disk.yaml b/yamls/apps-disk.yaml index 147b427..52059a6 100644 --- a/yamls/apps-disk.yaml +++ b/yamls/apps-disk.yaml @@ -34,8 +34,8 @@ spec: value: /shared - name: LOG_LEVEL value: INFO - - name: MANAGER_PORT - value: "12346" + - name: ETCD_HOST + value: "10.121.240.143:2379" resources: requests: cpu: 1000m @@ -85,8 +85,8 @@ spec: value: /shared - name: LOG_LEVEL value: INFO - - name: MANAGER_PORT - value: "12346" + - name: ETCD_HOST + value: "10.121.240.143:2379" resources: requests: cpu: 1000m diff --git a/yamls/apps.yaml b/yamls/apps.yaml index ba7a494..a3c0e29 100644 --- a/yamls/apps.yaml +++ b/yamls/apps.yaml @@ -34,8 +34,8 @@ spec: value: /shared - name: LOG_LEVEL value: INFO - - name: MANAGER_PORT - value: "12345" + - name: ETCD_HOST + value: "10.121.240.143:2379" resources: requests: cpu: 1000m @@ -84,8 +84,8 @@ spec: value: /shared - name: LOG_LEVEL value: INFO - - name: MANAGER_PORT - value: "12345" + - name: ETCD_HOST + value: "10.121.240.143:2379" resources: requests: cpu: 1000m diff --git a/yamls/manager-disk.yaml b/yamls/manager-disk.yaml index 1b68b66..9cf408f 100644 --- a/yamls/manager-disk.yaml +++ b/yamls/manager-disk.yaml @@ -42,6 +42,8 @@ spec: env: - name: STORAGE_PATH value: /shared + - name: ETCD_HOST + value: "10.121.240.143:2379" volumes: - name: shared-volume hostPath: diff --git a/yamls/manager.yaml b/yamls/manager.yaml index 307ac52..b5c79c7 100644 --- a/yamls/manager.yaml +++ b/yamls/manager.yaml @@ -43,6 +43,8 @@ spec: env: - name: STORAGE_PATH value: /shared + - name: ETCD_HOST + value: "10.121.240.143:2379" volumes: - name: shared-volume hostPath: diff --git a/yamls/new-apps.yaml b/yamls/new-apps.yaml index 1f3d6ad..7e229bf 100644 --- a/yamls/new-apps.yaml +++ b/yamls/new-apps.yaml @@ -35,6 +35,8 @@ spec: value: /shared - name: LOG_LEVEL value: INFO + - name: ETCD_HOST + value: "10.121.240.143:2379" resources: requests: cpu: 1000m @@ -85,6 +87,8 @@ spec: value: /shared - name: LOG_LEVEL value: INFO + - name: ETCD_HOST + value: "10.121.240.143:2379" resources: requests: cpu: 1000m @@ -135,6 +139,8 @@ spec: value: /shared - name: LOG_LEVEL value: INFO + - name: ETCD_HOST + value: "10.121.240.143:2379" resources: requests: cpu: 1000m