Git Product home page Git Product logo

lkebot's Introduction

LKEBot - A Slack Bot for Deploying Lab LKE Clusters

This is a Slack Bot for managing a dynamic fleet of Linode LKE clusters, with an upper limit on deployment counts and sizing, geared towards chat-ops teams who want short-lived, ephemeral Kubernetes clusters for testing and deployment.

Running the Bot

To run the bot, use the filefrog/lkebot image, and your foavorite orchestrator / command-line flags:

docker run --restart=always -d \
  -e LINODE_TOKEN=$LINODE_TOKEN \
  filefrog/lkebot:latest

Interaction

In direct one-on-one messages, commands can be sent as-is:

Direct Message Session

If you invite the bot to a channel, channel members will be able to interact with it by prefixing the command with a lone @-name:

Channel Session

The following commands are known:

  • help - Print a helpful message about known commands.
  • info - Print the chatbots configuration.
  • list - Print the list of currently deployed clusters.
  • deploy ... - Deploy a new cluster.
  • renew ... - Renew the lease on a cluster.
  • expire ... - Immediately release the lease on a cluster.
  • teardown ... - Immediately delete a cluster.
  • access ... - Retrieve the $KUBECONFIG for a cluster.

help

Prints out a helpful reminder of how to interact with the chatbot.

This command takes no arguments.

help command

info

Prints out the chatbot configuration, including defaults and upper limits.

This command takes no arguments.

info command

list

Queries the Linode API (caching the results) and then prints out the current status of deployed clusters, their sizing, and expiration times (relatively speaking).

This command takes no arguments.

list command

deploy

Deploys a new LKE Kubernetes cluster.

Usage:

deploy NAME [-v K8S-VERSION] [-r REGION] [-i INSTANCE] [-n NODES] [--for HOURS]

deploy command

The following flags are defined:

  • -v or --version - The version of Kubernetes to deploy.

  • -r or --region - The name of the Linode region to deploy the LKE cluster into. This region must support "Kubernetes".

  • -i or --using - The name of the Linode instance type to deploy in this cluster's node pool.

  • -n or --nodes - How many worker nodes (pursuant to operator-imposed upper limits) to deploy.

  • --for - How long (in hours) should this cluster live.

If any or all of these options are omitted, suitable built-in and operator-provided defaults are used.

renew

Renew the lease on a deployed cluster.

Usage:

renew NAME [--for HOURS]

renew command

The following flags are defined:

  • --for - How many more hours to add onto the clusters lease. If not specified, defaults to 1 (hour).

expire

Immediately expires a cluster's lease, making it sweepable (without explicitly tearing it down).

Usage:

expire NAME

This command takes no additional arguments.

expire command

teardown

Immediately tear down a cluster, deleting its worker nodes, and obliterating all workloads running on it.

Usage:

teardown NAME

This command takes no additional arugments

teardown command

access

Retrieves and prints a suitable KUBECONFIG for accessing this cluster via the kubectl CLI.

Usage:

access NAME

This command takes no additional arugments

access command

Configuration

You can configure the bot via either command-line flags or environment variables. Here's the list of knobs and levers you can fiddle with:

  • $APP_TOKEN REQUIRED - Slack Application token. Starts with xapp-.

  • $BOT_TOKEN REQUIRED - Slack Bot token. Starts with xoxb-.

  • $LINODE_TOKEN REQUIRED - Linode API token that the chatbot will use to deploy and tear down LKE clusters.

  • $LKEBOT_SWEEP_INTERVAL - Interval, in minutes, that the bot should look for expired clusters, and schedule their decommission. Defaults to 1; setting it to 0 effectively disables sweep logic.

  • $LKE_MAX_CLUSTERS - An upper limit on how many LKE clusters this chatbot is allowed to deploy. Defaults to 5.

  • $LKE_MAX_NODES - An upper limit on how big of an LKE cluster this chatbot is allowed to deploy. Defaults to 3.

  • $LKE_DEFAULT_REGION - What Linode region should clusters be deployed to if no explicit region is set? Defaults to us-east; make sure the region you choose has "Kubernetes" available.

  • $LKE_DEFAULT_INSTANCE - Instance type to use in the node pool for new clusters. Defaults to g6-standard-2; make sure the instance type you choose actually exists.

  • $LKE_DEFAULT_SIZE - How large of a cluster should the chatbot deploy, if no size is explicitly set? Must not execeed the set upper limit for cluster size.

  • $LKE_DEFAULT_VERSION - What version of Kubernetes should the chatbot deploy, when not told expressly which to use? Defaults to 1.22; make sure the version you specify is known to Linode / LKE.

  • $LKE_DEFAULT_LIFETIME - How long (in hours) should clusters exist for, before the chatbot expires them out and tears them down? Defaults to 8. Must be positive and non-zero.

  • $LKEBOT_OFF_LIMITS - One (or more) cluster names to explicitly prohibit the chatbot from touching, as a comma-separated list. This hs no effect if sweeping is disabled.

lkebot's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.