From 2d000d529150da753bac70ed0102f8cdd8b95c62 Mon Sep 17 00:00:00 2001 From: jfaldanam Date: Sat, 15 Jun 2024 21:57:12 +0200 Subject: [PATCH 1/3] feat: add reference Kubernetes manifests --- README.md | 2 ++ deployments/README.md | 8 ++++++ deployments/eidos-deployment.yaml | 42 +++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 deployments/README.md create mode 100644 deployments/eidos-deployment.yaml diff --git a/README.md b/README.md index 140f5e5..f532880 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,8 @@ Example: curl -X POST -H "Content-Type: application/json" -d '{"who": "me"}' http://localhost:8090/api/v1/execution/salute ``` +To deploy the container in Kubernetes, a reference deployment is available and documented at [deployments](deployments/). + ## Testing `pytest` is used for testing. You can run the tests with the following command: diff --git a/deployments/README.md b/deployments/README.md new file mode 100644 index 0000000..64ebcc2 --- /dev/null +++ b/deployments/README.md @@ -0,0 +1,8 @@ +# Kubernetes deployment of eidos +This folder contains all required files and configuration to have a working deployment of `eidos` in Kubernetes. + +The configuration provided creates a deployment with 3 replicas using the base `eidos` instance (to deploy a instance with custom functions just change the docker image) behind a service for load balancing between the different pods. + +# Disclaimer + +The provided Kubernetes manifests are for reference only. You must review and adjust these manifests to suit your specific cluster and configuration. Ensure that resource requests and limits, image names, environment variables, and other configurations are appropriate for your setup. \ No newline at end of file diff --git a/deployments/eidos-deployment.yaml b/deployments/eidos-deployment.yaml new file mode 100644 index 0000000..8db6d16 --- /dev/null +++ b/deployments/eidos-deployment.yaml @@ -0,0 +1,42 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: eidos-deployment + labels: + app: eidos +spec: + replicas: 3 + selector: + matchLabels: + app: eidos + template: + metadata: + labels: + app: eidos + spec: + containers: + - name: eidos + image: ghcr.io/khaosresearch/eidos:v1.0.0 # This image must be changed to deploy a custom functions + imagePullPolicy: Always + ports: + - containerPort: 80 + resources: + limits: + memory: "1Gi" + cpu: "1" + requests: + memory: "256Mi" + cpu: "500m" +--- +apiVersion: v1 +kind: Service +metadata: + name: eidos-service +spec: + type: NodePort + selector: + app: eidos + ports: + - protocol: TCP + port: 80 + targetPort: 80 From 7db27b0f1964bc0bb943209451c099e8e8a56238 Mon Sep 17 00:00:00 2001 From: jfaldanam Date: Mon, 17 Jun 2024 15:54:33 +0200 Subject: [PATCH 2/3] feat: add config map for setting env variables --- deployments/eidos-deployment.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/deployments/eidos-deployment.yaml b/deployments/eidos-deployment.yaml index 8db6d16..6833164 100644 --- a/deployments/eidos-deployment.yaml +++ b/deployments/eidos-deployment.yaml @@ -27,6 +27,22 @@ spec: requests: memory: "256Mi" cpu: "500m" + env: + - name: API_KEY + valueFrom: + configMapKeyRef: + name: eidos-configmap + key: EIDOS_API_KEY + - name: ROOT_PATH + valueFrom: + configMapKeyRef: + name: eidos-configmap + key: EIDOS_ROOT_PATH + - name: FUNCTIONS_FOLDER + valueFrom: + configMapKeyRef: + name: eidos-configmap + key: EIDOS_FUNCTIONS_FOLDER --- apiVersion: v1 kind: Service @@ -40,3 +56,12 @@ spec: - protocol: TCP port: 80 targetPort: 80 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: eidos-configmap +data: + EIDOS_API_KEY: "Sample_API_key_for_eidos" + EIDOS_ROOT_PATH: "/eidos" + EIDOS_FUNCTIONS_FOLDER: "functions" \ No newline at end of file From 2657bae07d93af399a282f634eb93815a9f8004d Mon Sep 17 00:00:00 2001 From: jfaldanam Date: Mon, 17 Jun 2024 16:55:01 +0200 Subject: [PATCH 3/3] feat: create custom namespace for reference deployment --- deployments/eidos-deployment.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/deployments/eidos-deployment.yaml b/deployments/eidos-deployment.yaml index 6833164..2e44069 100644 --- a/deployments/eidos-deployment.yaml +++ b/deployments/eidos-deployment.yaml @@ -1,9 +1,17 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: eidos-namespace + labels: + app: eidos +--- apiVersion: apps/v1 kind: Deployment metadata: name: eidos-deployment labels: app: eidos + namespace: eidos-namespace spec: replicas: 3 selector: @@ -13,6 +21,7 @@ spec: metadata: labels: app: eidos + namespace: eidos-namespace spec: containers: - name: eidos @@ -48,6 +57,7 @@ apiVersion: v1 kind: Service metadata: name: eidos-service + namespace: eidos-namespace spec: type: NodePort selector: @@ -61,6 +71,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: eidos-configmap + namespace: eidos-namespace data: EIDOS_API_KEY: "Sample_API_key_for_eidos" EIDOS_ROOT_PATH: "/eidos"