Skip to content

spectrocloud/terraform-spectrocloud-edge

Repository files navigation

License: GPL v3 Developed by: Spectro Cloud

Palette Edge Native Terraform Module

The Spectro Cloud Provider for Palette is available in the Terraform Registry. This repository contains the module and examples to create a Kubernetes Edge Cluster using Palette.

Assumptions

Addon profiles that will be used for the cluster creation have already been defined. This module will reference those resources rather than create them. Profiles can be created through the Cluster Profile Resource

Usage

Module Version Required Terraform Version
<= 1.0.0 <= 1.2.9
>= 1.1.0 >= 1.3.0

See the Examples for usage of this module. This module is written for the Edge Native Deployment option.

This is a sample "main.tf" file. In this example, we are creating a 3-node Ubuntu-PXKE 1.24 cluster. This cluster has a basic profile for the Ubuntu Operating System, PXK-E (Palette Optimized Kubernetes for the Edge), a CNI, and a few other example profiles. These profiles were created ahead of time.

Additionally, with the "VIP" tag, we enable Kubevip for HA. The Edge Host is now looked up via the "tag" on the Edge Host. Multiple tags can be used for this purpose. See the example for usage with multiple pools. The Tag(s) should be added to the Edge Host before running the plan. This applies to virtual machines as well. For ease of use, we have provided a QRCode giving you the ability to easily copy the UID of the device.

QR Code UID Copy
QRCode UID Copy
module "edge-demo-module" {
  source  = "spectrocloud/edge/spectrocloud"
  version = "1.5.0"
  # Store Number/Location
  name = "demo"
  # add tags to the cluster (optional) list(strings)
  cluster_tags = ["origin:terraform"]
  ssh_keys = [
    "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbm test2",
  "ecdsa-sha2-nistp256 AAAAE2VjZHNhL test1"]
  ntp_servers = [
    "10.10.10.1",
    "10.10.10.2"
  ]

  # Cluster VIP to be used with KubeVIP If not using Overlay
  # cluster_vip = "10.10.100.5"

  # Overlay CIDR Range
  overlay_cidr_range = "100.64.128.0/18"

  # Node Pools for Cluster
  machine_pools = [
    # Control Plane Node Pool
    {
      name                    = "control-plane"
      control_plane           = true
      control_plane_as_worker = false
      additional_labels = {
        "region" : "east"
      }
      edge_host = [
        {
          host_uid  = "edge12345"
          host_name = "edge1"
          static_ip = "10.100.100.31"
          subnet_mask = "255.255.255.0"
          default_gateway = "10.100.100.1"
          dns_servers = ["10.100.100.1","10.100.100.2"]

        },
                {
          host_uid  = "edge123456"
          host_name = "edge2"
          static_ip = "10.100.100.32"
          subnet_mask = "255.255.255.0"
          default_gateway = "10.100.100.1"
          dns_servers = ["10.100.100.1","10.100.100.2"]
          nic_name = "auto"

        }
      ]
    },
    # Add additional node pools
    {
      name          = "gpu"
      control_plane = false
      edge_host = [

        {
          host_uid  = "123test"
          static_ip = "2.2.2.2"
        }
      ]
      additional_labels = {
        "type" : "gpu",
        "region" : "east"
      }
    }

  ]

  # Profiles to be added Profile should be an Edge-Native Infra or Full Profile with the OS, Kubernetes Distribution and CNI of choice
  cluster_profiles = [
    {
      name    = "edge-profile"
      tag     = "1.30.5-ubuntu"
      context = "project"
    },
    {
      name    = "edge-services"
      tag     = "1.0.0"
      context = "project"
    },
    {
      name    = "edge-logging"
      tag     = "1.0.0"
      context = "project"
    }
  ]
  # Cluster Geolocation (Optional)
  location = {
    latitude  = 40.442829
    longitude = -79.950432
  }
  rbac_bindings = [
    {
      rbac_type = "ClusterRoleBinding"
      rbac_role = {
        name = "cluster-admin"
        kind = "ClusterRole"
      }
      subjects = [
        {
          name      = "k8s-admin"
          rbac_type = "Group"
        }
      ]
    }
  ]

}

Requirements

Name Version
terraform >= 1.3.0
spectrocloud >= 0.22.0

Providers

Name Version
spectrocloud 0.22.0

Modules

No modules.

Resources

Name Type
spectrocloud_cluster_edge_native.this resource
spectrocloud_cluster_profile.this data source

Inputs

Name Description Type Default Required
cluster_profiles Values for the profile(s) to be used for cluster creation. For context a value of [project tenant system] is expected.
list(object({
name = string
tag = optional(string)
context = string # project tenant system
packs = optional(list(object({
name = string
tag = string
values = optional(string)
manifest = optional(list(object({
name = string
tag = string
content = string
})))
})))
}))
n/a yes
cluster_tags Tags to be added to the profile. key:value list(string) [] no
cluster_vip IP Address for Cluster VIP for HA. Must be unused on on the same layer 2 segment as the node IPs. string "" no
location Optional - If used Latitude and Longitude represent the coordinates of the location you wish to assign to the cluster. https://www.latlong.net/ is one tool that can be used to find this.
object({
latitude = optional(number)
longitude = optional(number)
})
{
"latitude": 0,
"longitude": 0
}
no
machine_pools Values for the attributes of the Node Pools. 'edge_host_tags' is used to lookup the Edge Host already registered with Palette.
list(object({
name = string
additional_labels = optional(map(string))
control_plane = optional(bool)
control_plane_as_worker = optional(bool)
taints = optional(list(object({
effect = string
key = string
value = string
})))
edge_host = list(object({
host_uid = string
host_name = optional(string)
nic_name = optional(string)
static_ip = optional(string)
subnet_mask = optional(string)
default_gateway = optional(string)
dns_servers = optional(list(string))
two_node_role = optional(string)
}))
}))
n/a yes
name Name of the cluster to be created. string n/a yes
ntp_servers n/a list(string) [] no
overlay_cidr_range CIDR range for the overlay network. string "" no
rbac_bindings RBAC Bindings to be added to the cluster
list(object({
rbac_type = string
namespace = optional(string)
rbac_role = optional(map(string))
subjects = optional(list(object({
name = string
rbac_type = string
namespace = optional(string)
})))
}))
[] no
skip_wait_for_completion n/a bool true no
ssh_keys n/a list(string) [] no

Outputs

Name Description
admin_kube_config n/a
id n/a
kubeconfig n/a
name n/a

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages