Terraform for Edge Node Clusters: A Use Case

Introduction

Assuming that you already know about Terraform and edge node clusters, this article covers specifically how to use Terraform for automating the creation, replacement, and deletion of edge node clusters. See ZEDEDA Terraform Provider for details about Terraform. See the Edge Node Cluster Overview for more info about edge node clusters.

Prerequisites

This is a series of articles. You will likely follow them in this order.

  1. Terraform Quickstart 
  2. ZEDEDA Terraform Provider
  3. Renaming ZEDEDA Terraform objects
  4. Terraform for Edge Node Clusters: A Use Case - You are here!

Create an Edge Node Cluster

Before you create the edge node cluster, you need to create the dependencies. 

Dependencies

The edge node cluster uses the IDs from the following resources:

  • Project
  • Edge Nodes running the EVE-OS Kubevirt image so that an edge node cluster can be formed

Populate the Plan

The Terraform registry contains the ZEDEDA Cloud Edge Node Cluster Schema for all the required and optional parameters. See the Most Common Terraform Commands if you need more info about initializing or applying the changes.

Populate the plan (main.tf) based on the following. This is a minimum proof of concept example. You wouldn’t copy and paste this directly into your configuration. You would revise it to match your own configuration. 

terraform {
  required_providers {
    zedcloud = {
      source = "zededa/zedcloud"
      version = "2.4.0"
    }
  }
}

resource "zedcloud_project" "test_tf_provider" {
  name = "test_tf_provider"
  title = "test_tf_provider"

  type = "TAG_TYPE_PROJECT"
}

resource "zedcloud_brand" "test_tf_provider" {
  name = "test_tf_provider"
  title = "test_tf_provider"
  description = "description"
  origin_type = "ORIGIN_LOCAL"
}

resource "zedcloud_model" "test_tf_provider" {
  brand_id = zedcloud_brand.test_tf_provider.id
  name = "test_tf_provider"
  title = "test_tf_provider"
  type = "AMD64"
  origin_type = "ORIGIN_LOCAL"
  state = "SYS_MODEL_STATE_ACTIVE"
  attr = {
    memory = "8G"
    storage = "100G"
    Cpus = "4"
  }
  io_member_list {
    ztype = "IO_TYPE_ETH"
    phylabel =  "firstEth"
    usage = "ADAPTER_USAGE_MANAGEMENT"
    assigngrp = "eth0"
    phyaddrs = {
      Ifname = "eth0"
      PciLong = "0000:02:00.0"
    }
    logicallabel = "ethernet0"
    usage_policy = {
      FreeUplink = true
    }
    cost = 0
  }
  io_member_list {
    ztype = "IO_TYPE_ETH"
    phylabel = "secondEth"
    assigngrp = "eth1"
    phyaddrs = {
      Ifname = "eth1"
      PciLong = "0000:03:00.0"
    }
    logicallabel = "ethernet1"
    usage_policy = {
      FreeUplink = true
    }
    cost = 0
  }
  io_member_list {
    ztype = "IO_TYPE_USB"
    phylabel = "USB-C"
    assigngrp = "USB-C"
    phyaddrs = {
      PciLong = "0000:05:00.0"
    }
    logicallabel = "USB6"
    cost = 0
  }
}

resource "zedcloud_edgenode" "test_tf_provider_cluster_node_1" {
   name = "test_tf_provider_cluster_node_1"
   model_id = zedcloud_model.test_tf_provider.id
   project_id = data.zedcloud_project.test_tf_provider.id
   title = "test_tf_provider-create_edgenode-title"

   description = "description"
   generate_soft_serial = true
 }

resource "zedcloud_edgenode" "test_tf_provider_cluster_node_2" {
   name = "test_tf_provider_cluster_node_2"
   model_id = zedcloud_model.test_tf_provider.id
   project_id = data.zedcloud_project.test_tf_provider.id
   title = "test_tf_provider-create_edgenode-title"

   description = "description"
   generate_soft_serial = true
}

resource "zedcloud_edgenode" "test_tf_provider_cluster_node_3" {
   name = "test_tf_provider_cluster_node_3"
   model_id = zedcloud_model.test_tf_provider.id
   project_id = data.zedcloud_project.test_tf_provider.id
   title = "test_tf_provider-create_edgenode-title"

   description = "description"
   generate_soft_serial = true
}

resource "zedcloud_edgenode_cluster" "test_tf_provider" {
   project_id = data.zedcloud_project.test_tf_provider.id
   name = "test_tf_provider_cluster"
   title = "test_tf_provider_cluster"
   description = "description"
   nodes {
     id = zedcloud_edgenode.test_tf_provider_cluster_node_1.id
     cluster_interface = "ethernet0"
   }
   nodes {
     id = zedcloud_edgenode.test_tf_provider_cluster_node_2.id
     cluster_interface = "ethernet0"
   }
   nodes {
     id = zedcloud_edgenode.test_tf_provider_cluster_node_3.id
     cluster_interface = "ethernet0"
   }
}
}

Replace an Edge Node Cluster

To replace a node in the cluster, you need to replace the ID of a node in your "zedcloud_edgenode_cluster" resource to match the new node ID in the plan.

  • Original
    nodes {
         id = zedcloud_edgenode.test_tf_provider_cluster_node_original.id
         cluster_interface = "ethernet0"
       }
    
  • New
    nodes {
         id = zedcloud_edgenode.test_tf_provider_cluster_node_new.id
         cluster_interface = "ethernet0"
       }

Adding or deleting an edge node to or from the cluster is not supported. Only replace is supported. 

Delete an Edge Node Cluster

To delete an edge node cluster, you need to remove the "zedcloud_edgenode_cluster" resource from the plan.

You cannot delete an edge node from a cluster if an application instance, network instance, or volume instance is running on it. 

Next Steps

This is a series of articles. You will likely follow them in this order.

  1. Terraform Quickstart 
  2. ZEDEDA Terraform Provider
  3. Renaming ZEDEDA Terraform objects
  4. Terraform for Edge Node Clusters: A Use Case - You are here!
Was this article helpful?
0 out of 0 found this helpful