Skip to content

Commit

Permalink
Add filewatcher namespace env and defaults with ir
Browse files Browse the repository at this point in the history
  • Loading branch information
Pasarus committed Dec 13, 2023
1 parent 86f2882 commit 63a2a01
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions file_watcher_operator/file_watcher_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,22 @@ def generate_deployment_body(spec, name):
def deploy_deployment(deployment_spec, name, children):
app_api = kubernetes.client.AppsV1Api()
logger.info(f"Starting deployment of: {name} filewatcher")
depl = app_api.create_namespaced_deployment(namespace="ir-file-watcher", body=deployment_spec)
namespace = os.environ.get("FILEWATCHER_NAMESPACE", "ir")
depl = app_api.create_namespaced_deployment(namespace=namespace, body=deployment_spec)
children.append(depl.metadata.uid)
logger.info(f"Deployed: {name} filewatcher")


def deploy_pvc(pvc_spec, name, children):
namespace = os.environ.get("FILEWATCHER_NAMESPACE", "ir")
core_api = kubernetes.client.CoreV1Api()
# Check if PVC exists else deploy a new one:
if pvc_spec["metadata"]["name"] not in [
ii.metadata.name
for ii in core_api.list_namespaced_persistent_volume_claim(pvc_spec["metadata"]["namespace"]).items
]:
logger.info(f"Starting deployment of PVC: {name} filewatcher")
pvc = core_api.create_namespaced_persistent_volume_claim(namespace="ir-file-watcher", body=pvc_spec)
pvc = core_api.create_namespaced_persistent_volume_claim(namespace=namespace, body=pvc_spec)
children.append(pvc.metadata.uid)
logger.info(f"Deployed PVC: {name} filewatcher")

Expand Down

0 comments on commit 63a2a01

Please sign in to comment.