From 4217506ab757aef7e1aaeba651ab4d6af4ac4528 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Wed, 21 Sep 2022 13:26:19 +0300 Subject: [PATCH] [#217] Add rest-gw service Signed-off-by: Denis Kirillov --- .env | 4 ++ .services | 1 + docs/rest_gate.md | 70 +++++++++++++++++++++++++++ services/rest_gate/.env | 1 + services/rest_gate/.hosts | 1 + services/rest_gate/.int_test.env | 1 + services/rest_gate/docker-compose.yml | 33 +++++++++++++ services/rest_gate/wallet.json | 30 ++++++++++++ 8 files changed, 141 insertions(+) create mode 100644 docs/rest_gate.md create mode 120000 services/rest_gate/.env create mode 100644 services/rest_gate/.hosts create mode 120000 services/rest_gate/.int_test.env create mode 100644 services/rest_gate/docker-compose.yml create mode 100644 services/rest_gate/wallet.json diff --git a/.env b/.env index 3c639b1..d4f7dfa 100644 --- a/.env +++ b/.env @@ -29,6 +29,10 @@ NATS_IMAGE=nats HTTP_GW_VERSION=0.24.0 HTTP_GW_IMAGE=nspccdev/neofs-http-gw +# REST Gate +REST_GW_VERSION=0.4.0 +REST_GW_IMAGE=nspccdev/neofs-rest-gw + # S3 Gate S3_GW_VERSION=0.24.0 S3_GW_IMAGE=nspccdev/neofs-s3-gw diff --git a/.services b/.services index 2c165fa..19b229e 100644 --- a/.services +++ b/.services @@ -2,4 +2,5 @@ # Will start from top to bottom and stop in reverse http_gate s3_gate +rest_gate coredns diff --git a/docs/rest_gate.md b/docs/rest_gate.md new file mode 100644 index 0000000..2597a2c --- /dev/null +++ b/docs/rest_gate.md @@ -0,0 +1,70 @@ +# REST Gateway + +REST Gateway to access data in NeoFS using REST. + +Source code and more information can be found in [project's GitHub repository](https://github.com/nspcc-dev/neofs-rest-gw) + +## .env settings + +### REST_GW_VERSION=0.4.0 + +Image version label to use for containers. + +If you want to use locally built image, just set its label here. +Instead of pulling from DockerHub, the local image will be used. + +### REST_GW_IMAGE=nspccdev/neofs-rest-gw + +Image label prefix to use for containers. + +## Usage example + +- List container for specific owner: + +```shell +$ curl http://rest.neofs.devenv:8090/v1/containers?ownerId=NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM | jq +{ + "containers": [ + { + "attributes": [ + { + "key": "Timestamp", + "value": "1663755230" + } + ], + "basicAcl": "fbfbfff", + "cannedAcl": "eacl-public-read-write", + "containerId": "BKcAvz8awKKy9NGsGKi1Hoxxu9AjTGvjKMNMQamvdLmX", + "containerName": "", + "ownerId": "NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM", + "placementPolicy": "REP 1 IN X\nCBF 1\nSELECT 1 FROM * AS X", + "version": "v2.13" + } + ], + "size": 1 +} +``` + + +- Get container info: + +```shell +$ curl http://rest.neofs.devenv:8090/v1/containers/BKcAvz8awKKy9NGsGKi1Hoxxu9AjTGvjKMNMQamvdLmX | jq +{ + "attributes": [ + { + "key": "Timestamp", + "value": "1663755230" + } + ], + "basicAcl": "fbfbfff", + "cannedAcl": "eacl-public-read-write", + "containerId": "BKcAvz8awKKy9NGsGKi1Hoxxu9AjTGvjKMNMQamvdLmX", + "containerName": "", + "ownerId": "NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM", + "placementPolicy": "REP 1 IN X\nCBF 1\nSELECT 1 FROM * AS X", + "version": "v2.13" +} +``` + +See all available routes http://rest.neofs.devenv:8090/v1/docs diff --git a/services/rest_gate/.env b/services/rest_gate/.env new file mode 120000 index 0000000..c7360fb --- /dev/null +++ b/services/rest_gate/.env @@ -0,0 +1 @@ +../../.env \ No newline at end of file diff --git a/services/rest_gate/.hosts b/services/rest_gate/.hosts new file mode 100644 index 0000000..ee7578e --- /dev/null +++ b/services/rest_gate/.hosts @@ -0,0 +1 @@ +IPV4_PREFIX.83 rest.LOCAL_DOMAIN diff --git a/services/rest_gate/.int_test.env b/services/rest_gate/.int_test.env new file mode 120000 index 0000000..582b6a2 --- /dev/null +++ b/services/rest_gate/.int_test.env @@ -0,0 +1 @@ +../../.int_test.env \ No newline at end of file diff --git a/services/rest_gate/docker-compose.yml b/services/rest_gate/docker-compose.yml new file mode 100644 index 0000000..75b0b7a --- /dev/null +++ b/services/rest_gate/docker-compose.yml @@ -0,0 +1,33 @@ +--- + +version: "2.4" +services: + rest_gate: + image: ${REST_GW_IMAGE}:${REST_GW_VERSION} + domainname: ${LOCAL_DOMAIN} + hostname: rest + container_name: rest_gate + restart: on-failure + networks: + rest_gate_int: + internet: + ipv4_address: ${IPV4_PREFIX}.83 + volumes: + - ./wallet.json:/wallet.json + - ./../../vendor/hosts:/etc/hosts + stop_signal: SIGKILL + env_file: [ ".env", ".int_test.env" ] + environment: + - REST_GW_WALLET_PATH=/wallet.json + - REST_GW_WALLET_PASSPHRASE=one + - REST_GW_LISTEN_ADDRESS=0.0.0.0:8090 + - REST_GW_PEERS_0_ADDRESS=s01.${LOCAL_DOMAIN}:8080 + - REST_GW_PEERS_1_ADDRESS=s02.${LOCAL_DOMAIN}:8080 + - REST_GW_PEERS_2_ADDRESS=s03.${LOCAL_DOMAIN}:8080 + - REST_GW_PEERS_3_ADDRESS=s04.${LOCAL_DOMAIN}:8080 + +networks: + rest_gate_int: + internet: + external: true + name: basenet_internet diff --git a/services/rest_gate/wallet.json b/services/rest_gate/wallet.json new file mode 100644 index 0000000..2b60501 --- /dev/null +++ b/services/rest_gate/wallet.json @@ -0,0 +1,30 @@ +{ + "version": "3.0", + "accounts": [ + { + "address": "NPFCqWHfi9ixCJRu7DABRbVfXRbkSEr9Vo", + "key": "6PYTAGjdaeicUDPqGv9mmgwb9kTwimWJJmmfNqJSDGH9qM79zSRcL9oHiB", + "label": "REST Gateway", + "contract": { + "script": "DCECcuPzZCZ2VyDsm2jKEOMnU6xEWO2bF1dvOvBWTDFYB1ZBVuezJw==", + "parameters": [ + { + "name": "parameter0", + "type": "Signature" + } + ], + "deployed": false + }, + "lock": false, + "isDefault": false + } + ], + "scrypt": { + "n": 16384, + "r": 8, + "p": 8 + }, + "extra": { + "Tokens": null + } +}