Skip to main content

Infrastructure Operator Micro-service

Project description

banner

Nevermined Compute API

Compute to the Data Infrastructure Operator Micro-service

Table of Contents

About

The Compute API is a micro-service implementing the Nevermined Compute to the Data use case, in charge of managing the workflow executing requests. Typically the Compute Service is integrated with the Nevermined Gateway, but can be called independently of it.

The Compute API is in charge of establishing the communication with the K8s cluster, allowing to:

  • Register workflows as K8s objects
  • List the workflows registered in K8s
  • Stop a running workflow execution
  • Get information about the state of execution of a workflow

The Compute API doesn't provide any storage capability for workflows, all the state is stored directly in the K8s cluster.

Getting Started

Local Environment

The Compute API is in charge of receiving the requests for running compute workflows and the setup of those in the K8s infrastructure. To do that, in a local environment the Compute API needs connectivity to you K8s environment.

There are multiple configurations and deployments of K8s possible, but here we are going to show how to connect to an existing K8s cluster running in Amazon Web Services (AWS).

Installing AWS & K8s tools

First is necessary to install the AWS CLI:

$ sudo pip3 install awscli --upgrade

$ aws --version
aws-cli/1.16.225 Python/3.7.3 Linux/5.0.0-25-generic botocore/1.12.215

You need to install the aws-iam-authenticator

$ curl -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.13.7/2019-06-11/bin/linux/amd64/aws-iam-authenticator
chmod +x ./aws-iam-authenticator 

And later the Kubectl tool:

$ curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
$ chmod +x ./kubectl
$ sudo mv ./kubectl /usr/local/bin/kubectl
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:13:54Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}

To connect to your specific Kubernetes cluster you need to setup the ~/.kube/config file with your environment setup.

You can find the complete tutorials here:

Running the Service

Once you have Kubectl able to connect you your K8s cluster, run the service is as simple as running the following commands:

export FLASK_APP=operator_service/run.py

flask run --host=0.0.0.0 --port 8050

Having the server running you can find the complete Swagger API documentation here:

http://0.0.0.0:8050/api/v1/docs/

And check some of the API functions like the create or the list of the existing workflow executions:

$ curl -X GET "http://localhost:8050/api/v1/operator/list" -H "accept: application/json"
["9f9178dcffd34130a3158ce9ca3d15ff"]

ENV Vars

     ALGO_POD_TIMEOUT  = the maximum amount of time in seconds that an algorithm can use before it is killed
     POSTGRES_DB = Postgres database
     POSTGRES_USER = Postgresql user
     POSTGRES_PASSWORD = Postgresql password
     POSTGRES_HOST = Postgresql host
     POSTGRES_PORT = Postgresql port
     SIGNATURE_REQUIRED = 0 -> no signature required, 1 -> request brizo signature
     ALLOWED_PROVIDERS = Json array with allowed providers that can access the endpoints

Testing

Automatic tests are set up via GitHub actions.

New Version

The bumpversion.sh script helps bump the project version. You can execute the script using {major|minor|patch} as first argument, to bump the version accordingly.

Attribution

This library service in the Ocean Protocol Operator Service. It keeps the same Apache v2 License and adds some improvements. See NOTICE file.

License

Copyright 2020 Keyko GmbH
This product includes software developed at
BigchainDB GmbH and Ocean Protocol (https://www.oceanprotocol.com/)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nevermined-compute-api-0.1.0.tar.gz (14.3 kB view hashes)

Uploaded Source

Built Distribution

nevermined_compute_api-0.1.0-py2.py3-none-any.whl (13.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page