From 0e226f5affea347ff3563547dee95c97163bda9f Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 18 Nov 2021 12:18:54 -0800 Subject: [PATCH] early experiments in woring with k8s --- detectors/ntech/app.py | 1 + detectors/selimsef/app.py | 1 + ff-deployments.yaml | 88 +++++++++++++++++++++++++++++++++++++++ ff-networks.yaml | 41 ++++++++++++++++++ ff-services.yaml | 49 ++++++++++++++++++++++ ff-volumes.yaml | 29 +++++++++++++ 6 files changed, 209 insertions(+) create mode 100644 ff-deployments.yaml create mode 100644 ff-networks.yaml create mode 100644 ff-services.yaml create mode 100644 ff-volumes.yaml diff --git a/detectors/ntech/app.py b/detectors/ntech/app.py index f118f64..9347183 100644 --- a/detectors/ntech/app.py +++ b/detectors/ntech/app.py @@ -47,6 +47,7 @@ def predict(): score = model.inference(video_path) pred={'filename': video} pred[MODEL_NAME]=score + predictions.append(pred) else: return make_response(f"File {video} not found.", 400) except ValidationError as e: diff --git a/detectors/selimsef/app.py b/detectors/selimsef/app.py index c312ce4..be14822 100644 --- a/detectors/selimsef/app.py +++ b/detectors/selimsef/app.py @@ -32,6 +32,7 @@ def predict(): score = model.inference(video_path) pred={'filename': video} pred[MODEL_NAME]=score + predictions.append(pred) else: return make_response(f"File {video} not found.", 400) except ValidationError as e: diff --git a/ff-deployments.yaml b/ff-deployments.yaml new file mode 100644 index 0000000..ede1e5b --- /dev/null +++ b/ff-deployments.yaml @@ -0,0 +1,88 @@ +# apiVersion: v1 +# kind: Pod +# metadata: +# labels: +# service: api +# name: api +# spec: +# containers: +# - image: iqtlabs/fakefinder-api +# imagePullPolicy: Never +# name: api +# ports: +# - containerPort: 5000 +# resources: {} +# volumeMounts: +# - mountPath: /uploads +# name: uploads +# restartPolicy: Always +# volumes: +# - name: uploads +# hostPath: +# path: ./uploads/ +# type: Directory +# status: {} + +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + service: api + name: api +spec: + replicas: 1 + selector: + matchLabels: + service: api + strategy: + type: Recreate + template: + metadata: + labels: + api: "true" + detectors: "true" + frontend: "true" + service: api + spec: + containers: + - image: iqtlabs/fakefinder-api + imagePullPolicy: Never + name: api + ports: + - containerPort: 5000 + resources: {} + volumeMounts: + - mountPath: /uploads + name: uploads + restartPolicy: Always + volumes: + - name: uploads +status: {} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + service: dash + name: dash +spec: + replicas: 1 + selector: + matchLabels: + service: dash + strategy: {} + template: + metadata: + labels: + frontend: "true" + service: dash + spec: + containers: + - image: iqtlabs/fakefinder-dash + imagePullPolicy: Never + name: dash + ports: + - containerPort: 8050 + resources: {} + restartPolicy: Always +status: {} \ No newline at end of file diff --git a/ff-networks.yaml b/ff-networks.yaml new file mode 100644 index 0000000..d900d67 --- /dev/null +++ b/ff-networks.yaml @@ -0,0 +1,41 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: api +spec: + ingress: + - from: + - podSelector: + matchLabels: + api: "true" + podSelector: + matchLabels: + api: "true" +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: detectors +spec: + ingress: + - from: + - podSelector: + matchLabels: + detectors: "true" + podSelector: + matchLabels: + detectors: "true" +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: frontend +spec: + ingress: + - from: + - podSelector: + matchLabels: + frontend: "true" + podSelector: + matchLabels: + frontend: "true" \ No newline at end of file diff --git a/ff-services.yaml b/ff-services.yaml new file mode 100644 index 0000000..674540a --- /dev/null +++ b/ff-services.yaml @@ -0,0 +1,49 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + service: detector + name: detector +spec: + ports: + - name: "detector-port" + port: 5000 + targetPort: 5000 + selector: + service: detector +status: + loadBalancer: {} +--- +apiVersion: v1 +kind: Service +metadata: + labels: + service: api + name: api +spec: + ports: + - name: "api-port" + port: 5000 + targetPort: 5000 + selector: + service: api +status: + loadBalancer: {} +--- +apiVersion: v1 +kind: Service +metadata: + labels: + service: dash + name: dash +spec: + type: NodePort + ports: + - name: "http" + port: 80 + targetPort: 8050 + nodePort: 30080 + selector: + service: dash +status: + loadBalancer: {} \ No newline at end of file diff --git a/ff-volumes.yaml b/ff-volumes.yaml new file mode 100644 index 0000000..5b5cd3c --- /dev/null +++ b/ff-volumes.yaml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: weights + labels: + type: local +spec: + capacity: + storage: 100Gi + accessModes: + - ReadOnlyMany + hostPath: + path: ./weights + type: Directory +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: uploads + labels: + type: local +spec: + capacity: + storage: 100Gi + accessModes: + - ReadWriteMany + hostPath: + path: ./uploads + type: Directory \ No newline at end of file