1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-02 08:20:22 +01:00
docs/content/setup/ctd.md

148 lines
5.8 KiB
Markdown
Raw Normal View History

2020-05-24 10:06:08 +02:00
---
title: Set Up a Compute-to-Data Environment
2020-05-24 10:06:08 +02:00
description: Set Up a Compute-to-Data enviroment.
---
## Requirements
2020-05-24 10:06:08 +02:00
At the time of writing, we need the following:
First, create a folder with the following structure:
2020-05-24 10:06:08 +02:00
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/
- a working Kubernetes (K8s) cluster (Minikube is a good start)
- 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:
2020-06-03 07:37:44 +02:00
- [postgres-configmap.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-service/develop/deploy_on_k8s/postgres-configmap.yaml)
- [postgres-storage.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-service/develop/deploy_on_k8s/postgres-storage.yaml)
- [postgres-deployment.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-service/develop/deploy_on_k8s/postgres-deployment.yaml)
- [postgres-service.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-service/develop/deploy_on_k8s/postgresql-service.yaml)
- [deployment.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-service/develop/deploy_on_k8s/deployment.yaml)
- [role_binding.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-service/develop/deploy_on_k8s/role_binding.yaml)
- [service_account.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-service/develop/deploy_on_k8s/service_account.yaml)
2020-05-24 10:25:58 +02:00
- one folder (/ocean/operator-engine/), in which we will download the following:
2020-06-03 07:37:44 +02:00
- [sa.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-engine/develop/k8s_install/sa.yml)
- [binding.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-engine/develop/k8s_install/binding.yml)
- [operator.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-engine/develop/k8s_install/operator.yml)
- [computejob-crd.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-engine/develop/k8s_install/computejob-crd.yaml)
- [workflow-crd.yaml](https://raw.githubusercontent.com/oceanprotocol/operator-engine/develop/k8s_install/workflow-crd.yaml)
2020-05-24 10:06:08 +02:00
## Customize your Operator Service deployment
The following resources need attention:
2020-05-24 10:06:08 +02:00
2020-05-24 10:25:58 +02:00
- 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
The following resources need attention:
2020-05-24 10:06:08 +02:00
2020-05-24 10:25:58 +02:00
- operator.yaml - contains configuration variabiles
- ACCOUNT_JSON , ACCOUNT_PASSWORD = Defines the account that is going to be used when publishing results back to OceanProtocol
- AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID , AWS_REGION = S3 credidentials for the logs and output buckets
- AWS_BUCKET_OUTPUT = Bucket that will hold the output data (algorithm logs & algorithm output)
- AWS_BUCKET_ADMINLOGS = Bucket that will hold the admin logs (logs from pod-configure & pod-publish)
- STORAGE_CLASS = Storage class to use (see next section)
2020-05-24 10:06:08 +02:00
## Storage class
For minikube, you can use 'standard' class.
For AWS , please make sure that your class allocates volumes in the same region and zone in which you are running your pods.
We created our own 'standard' class in AWS:
2020-05-24 10:25:58 +02:00
2020-05-24 11:09:14 +02:00
kubectl get storageclass standard -o yaml
2020-05-24 10:06:08 +02:00
2020-05-24 10:25:58 +02:00
2020-05-24 10:06:08 +02:00
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- us-east-1a
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-05-28 07:34:08 +02:00
Or we can use this for minikube:
2020-05-24 11:09:14 +02:00
2020-05-28 07:34:08 +02:00
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: standard
provisioner: docker.io/hostpath
reclaimPolicy: Retain
2020-05-24 10:06:08 +02:00
2020-06-03 08:46:39 +02:00
For more information, please visit https://kubernetes.io/docs/concepts/storage/storage-classes/
2020-06-03 08:46:39 +02:00
2020-05-24 10:06:08 +02:00
## Create namespaces
2020-05-24 11:09:14 +02:00
kubectl create ns ocean-operator
kubectl create ns ocean-compute
2020-05-24 10:06:08 +02:00
## Deploy Operator Service
2020-05-24 10:06:08 +02:00
2020-05-24 11:09:14 +02:00
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
kubectl apply -f /ocean/operator-service/role_binding.yaml
kubectl apply -f /ocean/operator-service/service_account.yaml
2020-05-24 10:06:08 +02:00
## Deploy Operator Engine
2020-05-24 10:06:08 +02:00
2020-05-24 11:09:14 +02:00
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 apply -f /ocean/operator-engine/computejob-crd.yaml
kubectl apply -f /ocean/operator-engine/workflow-crd.yaml
kubectl create -f /ocean/operator-service/postgres-configmap.yaml
2020-05-24 10:06:08 +02:00
## Expose Operator - Service
2020-05-24 11:09:14 +02:00
kubectl expose deployment operator-api --namespace=ocean-operator --port=8050
2020-05-24 10:06:08 +02:00
Run a port forward or create your ingress service (not covered here):
2020-05-24 11:09:14 +02:00
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-05-24 11:09:14 +02:00
curl -X POST "http://example.com:8050/api/v1/operator/pgsqlinit" -H "accept: application/json"
2020-05-24 10:06:08 +02:00
## Update Brizo
Update Brizo by adding or updating the `OPERATOR_SERVICE_URL` env in `/ocean/barge/compose-files/brizo.yaml`
2020-05-24 10:06:08 +02:00
```yaml
2020-05-24 10:06:08 +02:00
OPERATOR_SERVICE_URL: http://example.com:8050/
2020-05-24 10:25:58 +02:00
2020-05-24 10:06:08 +02:00
## Restart Barge with updated Brizo configuration