Skip to content

elohmeier/nomad-hcloud-autoscaler

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hetzner Cloud Server Target Plugin

The hcloud-server target plugin allows for the scaling of the Nomad cluster clients via manipulating Hetzner Cloud Servers.

Agent Configuration Options

To use the hcloud-server target plugin, the agent configuration needs to be populated with the appropriate target block.

target "hcloud-server" {
  driver = "hcloud-server"
  config = {
    hcloud_token = "YOUR_HCLOUD_TOKEN"
  }
}
  • hcloud_token (string: required) - The Hetzner Cloud token used to authenticate to connect to and where resources should be managed.

  • hcloud_random_suffix_len (string: "10") - Random Server name suffix length

  • hcloud_retry_interval (string: "1m") - Hetzner Cloud API retry interval

  • hcloud_retry_limit (string: "5") - Hetzner Cloud API retry limit

  • hcloud_items_per_page (string: "50") - Hetzner Cloud API request page size

  • hcloud_group_id_label_selector (string: "group-id") - Server group id label selector

  • hcloud_node_attr_id (string: "unique.hostname") - Nomad Node attribute id

Nomad ACL

When using a Nomad cluster with ACLs enabled, the plugin will require an ACL token which provides the following permissions:

node {
  policy = "write"
}

Policy Configuration Options

check "hashistack-allocated-cpu" {
  # ...
  target "hcloud-server" {
    datacenter                   = "XXX"
    node_class                   = "XXX"
    node_drain_deadline          = "5m"
    node_purge                   = "true"
    node_selector_strategy       = "newest_create_index"
    hcloud_location              = "XXX"
    hcloud_image                 = "XXX"
    hcloud_user_data             = "#cloud-config\npackages:\n - jq"
    hcloud_b64_user_data_encoded = "false"
    hcloud_ssh_keys              = "XXX"
    hcloud_server_type           = "cx11"
    hcloud_group_id              = "XXX"
    hcloud_labels                = "XXX_node=true"
    hcloud_networks              = "XXX"
  }
  # ...
}
  • hcloud_location (string: "") - ID or name of Location to create Server in (must not be used together with hcloud_datacenter).

  • hcloud_datacenter (string: "") - ID or name of Datacenter to create Server in (must not be used together with hcloud_location).

  • hcloud_firewalls (string: "") - Comma-separated list of Firewall IDs

  • hcloud_placement_group (string: "") - Placement Group ID

  • hcloud_image (string: required) - ID or name of the Image the Server is created from.

  • hcloud_group_id (string: required) - Server group name used for filtering targeted HCloud hosts. group-id label is attached to a server during creation.

  • hcloud_user_data (string: required) - Cloud-Init user data to use during Server creation. This field is limited to 32KiB (must not be used together with hcloud_user_data_file).

  • hcloud_b64_user_data_encoded (string: "false") - Identifies if hcloud_user_data (or the content of the file specified in hcloud_user_data_file) is base64 encoded or not.

  • hcloud_user_data_file (string: required) - Cloud-Init user data file to use during Server creation (must not be used together with hcloud_user_data).

  • hcloud_ssh_keys (string: required) - Comma-separated IDs or names of SSH keys which should be injected into the server at creation time.

  • hcloud_labels (string: "") - User-defined labels (key-value pairs) string in a format key1=value1,key2=value2,...,keyN=valueN.

  • hcloud_networks (string: "") - Network IDs which should be attached to the server private network interface at the creation time.

  • hcloud_public_net_enable_ipv4 (bool: "true") - Enable IPV4 address for HCloud instances

  • hcloud_public_net_enable_ipv6 (bool: "false") - Enable IPV6 address for HCloud instances

  • datacenter (string: "") - The Nomad client datacenter identifier used to group nodes into a pool of resource.

  • node_class (string: "") - The Nomad client node class identifier used to group nodes into a pool of resource.

  • node_drain_deadline (duration: "15m") The Nomad drain deadline to use when performing node draining actions.

  • node_drain_ignore_system_jobs (bool: "false") A boolean flag used to control if system jobs should be stopped when performing node draining actions.

  • node_purge (bool: "false") A boolean flag to determine whether Nomad clients should be purged when performing scale in actions.

  • node_selector_strategy (string: "least_busy") The strategy to use when selecting nodes for termination. Refer to the node selector strategy documentation for more information.

Demo

Run terraform apply in demo folder to create:

  • nomad server which runs services for:
    • nomad-autoscaler
    • prometheus
    • redis

Autoscaler scales hcloud nodes for redis. After successful run both Nomad and Consul are wide-world open and credentials for both you can find in terraform output and in creds.json file

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 92.6%
  • Makefile 7.1%
  • Dockerfile 0.3%