From ddb2f8413f00cb4b4e74b85e44e50016fd8c9cb7 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 3 Oct 2024 12:18:03 +0530 Subject: [PATCH 1/3] Handle deployment auction requests --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++-------------- run.sh | 21 ++++++++++++++++++ 2 files changed, 70 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 5948151..cc4032b 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ files used by those requests. ## Build and Run -``` -$ yarn -$ yarn build -$ yarn start +```bash +yarn +yarn build +yarn start ``` ## Configuration @@ -20,22 +20,22 @@ On upload, the configuration is temporarily decrypted for validation, but stored To create and export a key in the necessary format use: -``` +```bash # Create a key -$ gpg --batch --passphrase "SECRET" --quick-generate-key webapp-deployer-api.my.domain.com default default never +gpg --batch --passphrase "SECRET" --quick-generate-key webapp-deployer-api.my.domain.com default default never # Export the public key -$ gpg --export webapp-deployer-api.my.domain.com > webapp-deployer-api.my.domain.com.pgp.pub +gpg --export webapp-deployer-api.my.domain.com > webapp-deployer-api.my.domain.com.pgp.pub # Export the private key -$ gpg --export-secret-keys webapp-deployer-api.my.domain.com > webapp-deployer-api.my.domain.com.pgp.key +gpg --export-secret-keys webapp-deployer-api.my.domain.com > webapp-deployer-api.my.domain.com.pgp.key ``` ### Create the Deployer Record Every webapp deployer should have `WebappDeployer` record in the registry which looks something like: -``` +```yml record: type: WebappDeployer version: 1.0.0 @@ -48,16 +48,34 @@ record: This record can most easily be created using `laconic-so publish-deployer-to-registry`. -``` -$ laconic-so publish-deployer-to-registry \ +```bash +laconic-so publish-deployer-to-registry \ --laconic-config ~/.laconic/registry.yml \ - --api-url https://webapp-deployer-api.my.domain.com + --api-url https://webapp-deployer-api.my.domain.com --public-key-file webapp-deployer-api.my.domain.com.pgp.pub \ --lrn lrn://laconic/deployers/webapp-deployer-api.my.domain.com \ --min-required-payment 100 ``` -This will create the record in the proper format and assign its LRN. +This will create the record in the proper format and assign its LRN. + +### Publish Deployment Auction + +Users can optionally create an auction for app deployment with desired number of providers and max price they are willing to pay for a deployment: + +```bash +laconic-so publish-deployment-auction \ + --laconic-config ./config.yml \ + --app lrn://deepstack/applications/pwa-test-13 \ + --commits-duration 3600 \ + --reveals-duration 3600 \ + --commit-fee 10000 \ + --reveal-fee 10000 \ + --max-price 5000000 \ + --num-providers 3 +``` + +This will create a `provider` auction with given params and publish a deployment auction record. ### Request Deployment @@ -70,8 +88,8 @@ Users can now request deployment using the LRN of the deployer. This will allow The request can be made using `laconic-so request-webapp-deployment`. This will handle encrypting and uploading the config automatically, as well as making a payment (if necessary). -``` -$ laconic-so request-webapp-deployment \ +```bash +laconic-so request-webapp-deployment \ --laconic-config ~/.laconic/registry.yml \ --deployer lrn://laconic/deployers/webapp-deployer-api.my.domain.com \ --app lrn://cerc-io/applications/webapp-hello-world@0.1.3 \ @@ -79,9 +97,21 @@ $ laconic-so request-webapp-deployment \ --make-payment auto ``` +Alternatively, users can also use a deployment auction they created instead of making the payment to any specific deployer directly: + +```bash +laconic-so request-webapp-deployment \ + --laconic-config ~/.laconic/registry.yml \ + --app lrn://cerc-io/applications/webapp-hello-world@0.1.3 \ + --env-file hello.env \ + --auction-id 4c9701c22651e143202e991056b6e7649853acc5bc0e97e3a98e09c9f3355909 +``` + +Similar to requests with payments, the config is automatically encrypted and uploaded to all the deployers who have won the auction. + ### Example Config -``` +```bash UPLOAD_DIRECTORY="/srv/uploads/config" UPLOAD_MAX_SIZE="1MB" DEPLOYER_STATE="/srv/deployments/autodeploy.state" @@ -90,4 +120,7 @@ BUILD_LOGS="/srv/logs" OPENPGP_PASSPHRASE="SECRET" OPENPGP_PRIVATE_KEY_FILE="/etc/config/webapp-deployer-api.my.domain.com.pgp.key" LACONIC_CONFIG="/etc/config/registry.yml" +LRN=lrn://laconic/deployers/webapp-deployer-api.my.domain.com +HANDLE_AUCTION_REQUESTS=true +AUCTION_BID_AMOUNT=50000 ``` diff --git a/run.sh b/run.sh index 39badb3..1e1a60c 100755 --- a/run.sh +++ b/run.sh @@ -35,6 +35,13 @@ if [ ! -f "/etc/config/kube.yml" ]; then exit 2 fi +if [ "$HANDLE_AUCTION_REQUESTS" = "true" ]; then + if [ -z "$AUCTION_BID_AMOUNT" ]; then + echo "AUCTION_BID_AMOUNT is required when handling auction requsts." + exit 2 + fi +fi + STORAGE_ROOT="${STORAGE_ROOT:-/srv}" DEPLOYMENTS_DIR="${DEPLOYMENTS_DIR:-$STORAGE_ROOT/deployments}" LOG_DIR="${LOG_DIR:-$STORAGE_ROOT/logs}" @@ -163,6 +170,20 @@ while true; do echo "############ DEPLOY FAILURE STATUS $rc #############" fi + if [ "$HANDLE_AUCTION_REQUESTS" = "true" ]; then + echo "############ DEPLOYMENT AUCTION #############" + laconic-so handle-deployment-auction \ + --laconic-config /etc/config/laconic.yml \ + --state-file "${DEPLOYMENTS_DIR}/autoauction.state" \ + --bid-amount ${AUCTION_BID_AMOUNT} + rc=$? + if [ $rc -eq 0 ]; then + echo "############ DEPLOYMENT AUCTION SUCCESS #############" + else + echo "############ DEPLOYMENT AUCTION FAILURE STATUS $rc #############" + fi + fi + # Cleanup any build leftovers if [[ "${SYSTEM_PRUNE:-false}" == "true" ]]; then docker system prune --all --force -- 2.45.2 From c9fc9ad53a776e045a54b1d2f98c7d7c9d903f3e Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 3 Oct 2024 17:19:08 +0530 Subject: [PATCH 2/3] Pass flag to allow auction requests --- run.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/run.sh b/run.sh index 1e1a60c..8b144ed 100755 --- a/run.sh +++ b/run.sh @@ -35,11 +35,14 @@ if [ ! -f "/etc/config/kube.yml" ]; then exit 2 fi +AUCTION_OPTS="" if [ "$HANDLE_AUCTION_REQUESTS" = "true" ]; then if [ -z "$AUCTION_BID_AMOUNT" ]; then echo "AUCTION_BID_AMOUNT is required when handling auction requsts." exit 2 fi + + AUCTION_OPTS="--auction-requests" fi STORAGE_ROOT="${STORAGE_ROOT:-/srv}" @@ -159,6 +162,7 @@ while true; do --config-upload-dir "$UPLOAD_DIRECTORY" \ --private-key-file "$OPENPGP_PRIVATE_KEY_FILE" \ --private-key-passphrase "$OPENPGP_PASSPHRASE" \ + $AUCTION_OPTS \ $LOG_OPTS \ $EXTRA_DEPLOY_OPTS \ $UPDATE_OPTS \ -- 2.45.2 From 8fc3d99135e777deacfdfb38d6372afa6e0e676d Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Mon, 7 Oct 2024 15:18:20 +0530 Subject: [PATCH 3/3] Update instructions --- README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cc4032b..3a7d448 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Users can optionally create an auction for app deployment with desired number of ```bash laconic-so publish-deployment-auction \ --laconic-config ./config.yml \ - --app lrn://deepstack/applications/pwa-test-13 \ + --app lrn://cerc-io/applications/webapp-hello-world@0.1.3 \ --commits-duration 3600 \ --reveals-duration 3600 \ --commit-fee 10000 \ @@ -85,7 +85,7 @@ Users can now request deployment using the LRN of the deployer. This will allow 1. Obtain the public key for encrypting config. 1. See the minimum required payment. -The request can be made using `laconic-so request-webapp-deployment`. This will handle encrypting and uploading the +The request can be made using `laconic-so request-webapp-deployment`. This will handle encrypting and uploading the config automatically, as well as making a payment (if necessary). ```bash @@ -107,7 +107,19 @@ laconic-so request-webapp-deployment \ --auction-id 4c9701c22651e143202e991056b6e7649853acc5bc0e97e3a98e09c9f3355909 ``` -Similar to requests with payments, the config is automatically encrypted and uploaded to all the deployers who have won the auction. +This creates deployment requests targeted towards all the deployers who have won the auction. Similar to requests with payments, the config is automatically encrypted and uploaded to all the deployers. + +### Request Undeployment + +Users can also request removal of an existing deployment using the deployment record id: + +```bash +laconic-so request-webapp-undeployment \ + --laconic-config ~/.laconic/registry.yml \ + --deployer lrn://laconic/deployers/webapp-deployer-api.my.domain.com \ + --deployment bafyreigeopr72dmp6rhvnomgdz3cljbqzhh75epcrigit7ue6i6vjullme \ + --make-payment auto +``` ### Example Config -- 2.45.2