Sign inSign up

davidw135/userbot

By davidw135

Updated over 8 years ago

Run userbot on an existing cluster

Image
0

727

davidw135/userbot repository overview

Tag history: v2 : Runs for a specified amount of time, with each user creating and removing apps at random. v2.1 : Same as V2, except the users run concurrently in go routines. v2.2: each userbot monitors apps it has deployed. v2.3: supports HRM v2.4: HRM where each deployed application provides its own network to ucp-hrm service. v2.5: networks are added by disabling/enabling UCP, instead of via docker service update --network-add ucp-hrm v2.6: networks can optionally be encrypted; ctrl-c will exit gracefully v2.7: support for interlock

Running this docker image will result in multiple (non-admin) UCP users being created. Each user will periodically deploy a new service on UCP, or remove a previously deployed service. For each user, the decision to deploy or remove is a random decision, biased towards converging on a set point that you define. (a biased random walk on a line)

You can control:

  • how many users get created
  • how many deployed apps the users should have running (note: due to randomness, the actual number of deployed apps will be a distribution around this number)
  • how long for the process to run (in minutes)
  • whether to preserve the created users and deployed apps, or tear them down at the end.
  • deploying apps via HRM or interlock

usage:

docker run \
    --rm \
    --stop-timeout=30 \
    -e USERBOT_UCP_HOST \
    -e USERBOT_UCP_ADMIN_PASSWORD \
    -e USERBOT_NUM_USERS \
    -e USERBOT_APPS_PER_USER \
    -e USERBOT_ALLOW_APP_DELETIONS \
    -e USERBOT_ROUTING_MESH_CONFIG \
    -e USERBOT_USE_ENCRYPTED_NETWORKS \
    -e USERBOT_APP_BASE_PORT \
    -e USERBOT_DURATION_MINUTES \
    -e USERBOT_DO_CLEANUP \
    davidw135/userbot:v2.7

where: USERBOT_UCP_ADMIN_PASSWORD=<string> The admin-password-for-UCP

USERBOT_UCP_HOST=<string> IP or DNS entry to reach your UCP cluster via port 443. e.g., export USERBOT_UCP_HOST='34.229.73.196'

USERBOT_NUM_USERS=<int> Number of users to create. Users are non-admin users. e.g., export USERBOT_NUM_USERS=5

USERBOT_APPS_PER_USER=<int> is Number of apps to deploy for each user. e.g., export USERBOT_APPS_PER_USER=25

USERBOT_ALLOW_APP_DELETIONS=true|false randomly delete as well as create deployed apps, or only create apps.

USERBOT_ROUTING_MESH_CONFIG=none|hrm|interlock Note: if you choose hrm or interlock, userbot will enable routing mesh if necessary.

USERBOT_USE_ENCRYPTED_NETWORKS='true|false'

USERBOT_APP_BASE_PORT=<int> Port to publish the app on. First deployed service will publish on this port, second will publish on port $((USERBOT_APP_BASE_PORT + 1 )), etc. It is up to you to ensure the ports in the range USERBOT_APP_BASE_PORT ... USERBOT_APP_BASE_PORT + (USERBOT_NUM_USERS * USERBOT_APPS_PER_USER) are not firewalled and not already in use by other apps. e.g., export USERBOT_APP_BASE_PORT=30000

USERBOT_DURATION_MINUTES=<int> Number of minutes for the userbots to run, creating and removing docker services. During this time, the individual userbots will be randomly walking towards USERBOT_APPS_PER_USER apps. e.g., export USERBOT_DURATION_MINUTES=30 Note since we start with zero deployed apps per user, it takes some time for each user to reach the requested USERBOT_APPS_PER_USER number of deployed apps. The amount of time required is not deterministic, because each user randomly deploys new apps and removes existing apps; moreover, there is no guarentee that there will ever be a point in time where all users have exactly USERBOT_APPS_PER_USER apps deployed at the same time.

USERBOT_DO_CLEANUP=ture|false Control how we behave after USERBOT_DURATION_MINUTES has elapsed. If 'true', will remove all created docker services and users. If 'false', will leave all created docker services and users on the UCP cluster.

So assuming we have an existing UCP cluster with one of the managers IP address 34.229.73.196 and the UCP admin password is someS3cret, and the UCP cluster has ports 3000 - 30125 available, we can run userbot for 30 minutes with:

export USERBOT_UCP_ADMIN_PASSWORD=`someS3cret`
export USERBOT_UCP_HOST='34.229.73.196'
export USERBOT_NUM_USERS=5
export USERBOT_APPS_PER_USER=25
export USERBOT_APP_BASE_PORT=30000
export USERBOT_DURATION_MINUTES=30
export USERBOT_DO_CLEANUP='true'
env | grep USERBOT
cmd="docker run \
    --rm \
    -e USERBOT_UCP_HOST \
    -e USERBOT_UCP_ADMIN_PASSWORD \
    -e USERBOT_NUM_USERS \
    -e USERBOT_APPS_PER_USER \
    -e USERBOT_APP_BASE_PORT \
    -e USERBOT_DURATION_MINUTES \
    -e USERBOT_DO_CLEANUP \
    davidw135/userbot:v2.7"
echo $cmd
eval $cmd

At the end of the 30 minute period, all the deployed apps and created users will be removed, since we set USERBOT_DO_CLEANUP to true

Tag summary

Content type

Image

Digest

Size

4.6 MB

Last updated

over 8 years ago

docker pull davidw135/userbot:v2.7