2020-05-24 10:06:08 +02:00
---
2020-06-03 12:19:40 +02:00
title: Set Up a Compute-to-Data Environment
2020-12-11 16:44:13 +01:00
description:
2020-05-24 10:06:08 +02:00
---
2020-06-03 12:18:24 +02:00
## Requirements
2020-05-24 10:06:08 +02:00
2020-06-03 12:21:52 +02:00
First, create a folder with the following structure:
2020-05-24 10:06:08 +02:00
2020-06-03 12:50:33 +02:00
```text
2020-06-03 12:44:01 +02:00
ocean/
barge/
operator-service/
operator-engine/
```
Then you need the following parts:
2020-05-24 10:25:58 +02:00
- working [Barge ](https://github.com/oceanprotocol/barge ). For this setup, we will asume the Barge is installed in /ocean/barge/
2021-09-01 20:18:30 +02:00
- a working Kubernetes (K8s) cluster ([Minikube](../compute-to-data-minikube/) is a good start)
2020-06-03 12:21:24 +02:00
- a working `kubectl` connected to the K8s cluster
2020-05-24 10:25:58 +02:00
- one folder (/ocean/operator-service/), in which we will download the following:
2021-04-20 12:10:25 +02:00
- [postgres-configmap.yaml ](https://raw.githubusercontent.com/oceanprotocol/operator-service/main/kubernetes/postgres-configmap.yaml )
- [postgres-storage.yaml ](https://raw.githubusercontent.com/oceanprotocol/operator-service/main/kubernetes/postgres-storage.yaml )
- [postgres-deployment.yaml ](https://raw.githubusercontent.com/oceanprotocol/operator-service/main/kubernetes/postgres-deployment.yaml )
- [postgres-service.yaml ](https://raw.githubusercontent.com/oceanprotocol/operator-service/main/kubernetes/postgresql-service.yaml )
- [deployment.yaml ](https://raw.githubusercontent.com/oceanprotocol/operator-service/main/kubernetes/deployment.yaml )
2020-05-24 10:25:58 +02:00
- one folder (/ocean/operator-engine/), in which we will download the following:
2021-04-20 12:10:25 +02:00
- [sa.yaml ](https://raw.githubusercontent.com/oceanprotocol/operator-engine/main/kubernetes/sa.yml )
- [binding.yaml ](https://raw.githubusercontent.com/oceanprotocol/operator-engine/main/kubernetes/binding.yml )
- [operator.yaml ](https://raw.githubusercontent.com/oceanprotocol/operator-engine/main/kubernetes/operator.yml )
2020-05-24 10:06:08 +02:00
## Customize your Operator Service deployment
2020-06-03 12:29:37 +02:00
The following resources need attention:
2020-06-03 13:49:57 +02:00
2020-06-03 12:29:37 +02:00
| Resource | Variable | Description |
| ------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------ |
| `postgres-configmap.yaml` | | Contains secrets for the PostgreSQL deployment. |
| `deployment.yaml` | `ALGO_POD_TIMEOUT` | Allowed time for a algorithm to run. If it exceeded this value (in minutes), it's going to get killed. |
2020-05-24 10:06:08 +02:00
## Customize your Operator Engine deployment
2021-04-20 12:10:25 +02:00
Check the [README ](https://github.com/oceanprotocol/operator-engine#customize-your-operator-engine-deployment ) section of operator engine to customize your deployment
2020-05-24 10:06:08 +02:00
## Storage class
2021-09-01 20:18:30 +02:00
For minikube, you can use the default 'standard' class.
2020-05-24 10:06:08 +02:00
2021-09-01 20:18:30 +02:00
For AWS, please make sure that your class allocates volumes in the same region and zone in which you are running your pods.
2020-05-24 10:06:08 +02:00
We created our own 'standard' class in AWS:
2020-05-24 10:25:58 +02:00
2020-06-03 12:22:41 +02:00
```bash
2020-05-24 11:09:14 +02:00
kubectl get storageclass standard -o yaml
2020-06-03 12:29:37 +02:00
```
2020-05-24 10:06:08 +02:00
2020-06-03 12:29:37 +02:00
```yaml
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
2020-05-24 10:06:08 +02:00
values:
- us-east-1a
2020-06-03 12:29:37 +02:00
apiVersion: storage.k8s.io/v1
kind: StorageClass
parameters:
fsType: ext4
type: gp2
provisioner: kubernetes.io/aws-ebs
reclaimPolicy: Delete
volumeBindingMode: Immediate
```
2020-05-24 11:09:14 +02:00
2020-06-03 12:19:03 +02:00
For more information, please visit https://kubernetes.io/docs/concepts/storage/storage-classes/
2020-07-01 11:24:21 +02:00
2020-05-24 10:06:08 +02:00
## Create namespaces
2020-06-03 12:29:37 +02:00
```bash
kubectl create ns ocean-operator
kubectl create ns ocean-compute
```
2020-05-24 11:09:14 +02:00
2020-06-03 12:20:41 +02:00
## Deploy Operator Service
2020-05-24 10:06:08 +02:00
2020-06-03 12:29:37 +02:00
```bash
kubectl config set-context --current --namespace ocean-operator
kubectl create -f /ocean/operator-service/postgres-configmap.yaml
kubectl create -f /ocean/operator-service/postgres-storage.yaml
kubectl create -f /ocean/operator-service/postgres-deployment.yaml
kubectl create -f /ocean/operator-service/postgresql-service.yaml
kubectl apply -f /ocean/operator-service/deployment.yaml
```
2020-05-24 11:09:14 +02:00
2020-06-03 12:21:39 +02:00
## Deploy Operator Engine
2020-05-24 10:06:08 +02:00
2020-06-03 12:29:37 +02:00
```bash
kubectl config set-context --current --namespace ocean-compute
kubectl apply -f /ocean/operator-engine/sa.yml
kubectl apply -f /ocean/operator-engine/binding.yml
kubectl apply -f /ocean/operator-engine/operator.yml
kubectl create -f /ocean/operator-service/postgres-configmap.yaml
```
2020-05-24 11:09:14 +02:00
2020-06-03 12:22:00 +02:00
## Expose Operator Service
2020-05-24 10:06:08 +02:00
2020-06-03 12:29:37 +02:00
```bash
kubectl expose deployment operator-api --namespace=ocean-operator --port=8050
```
2020-05-24 11:09:14 +02:00
2020-05-24 10:06:08 +02:00
Run a port forward or create your ingress service (not covered here):
2020-06-03 12:29:37 +02:00
```bash
kubectl -n ocean-operator port-forward svc/operator-api 8050
```
2020-05-24 10:06:08 +02:00
## Initialize database
If your cluster is running on example.com:
2020-06-03 12:29:37 +02:00
```bash
curl -X POST "http://example.com:8050/api/v1/operator/pgsqlinit" -H "accept: application/json"
```
2020-05-24 11:09:14 +02:00
2021-04-20 12:10:25 +02:00
## Update Barge for local testing
2020-05-24 10:06:08 +02:00
2021-04-20 12:10:25 +02:00
Update Barge's Provider by adding or updating the `OPERATOR_SERVICE_URL` env in `/ocean/barge/compose-files/provider.yaml`
2020-05-24 10:06:08 +02:00
2020-06-03 12:19:58 +02:00
```yaml
2020-05-24 10:06:08 +02:00
OPERATOR_SERVICE_URL: http://example.com:8050/
2020-06-03 12:29:37 +02:00
```
2020-05-24 10:25:58 +02:00
2021-04-20 12:10:25 +02:00
Restart Barge with updated provider configuration