0
votes

I have followed the terraform azure documentation to create service fabric cluster which is successfully being created . But also I need to create a single node in the cluster which is not getting created.

What do I need to add to create nodes in the terraform script ?

# Create a resource group if it doesn’t exist
resource "azurerm_resource_group" "rg-terraform-group" {
    name     = "rg-terraform-group"
    location = "eastus"

    tags = {
        environment = "Terraform Node Demo"
    }
}

#Create a service fabric cluster
resource "azurerm_service_fabric_cluster" "rg-terraform-sf" {
  name                 = "myServicefabric"
  resource_group_name  = "${azurerm_resource_group.rg-terraform-group.name}"
  location             = "${azurerm_resource_group.rg-terraform-group.location}"
  reliability_level    = "Bronze"
  upgrade_mode         = "Manual"
  cluster_code_version = "6.5.466.1"
  vm_image             = "Linux"
  management_endpoint  = "https://test.eastus.cloudapp.azure.com:19080"

  node_type {
    name                 = "first"
    instance_count       = 3
    is_primary           = true
    client_endpoint_port = 19000
    http_endpoint_port   = 19080
  }
}
1
@NancyXiong ok ,let me try this.NoobCoder
@NancyXiong the documentation is not complete. And still now no one has able to solve how to create nodes in cluster. there are few errors in the documentation as well.NoobCoder

1 Answers

0
votes

As mentioned in the below Github issues:

https://github.com/terraform-providers/terraform-provider-azurerm/issues/1948#issuecomment-433851818

As mentioned above the azurerm_service_fabric_cluster resource only creates the Service Fabric Cluster within Azure (since this is the way the Service Fabric API is designed). Whilst Terraform supports all the individual components required for Service Fabric (e.g. VM Scale Sets/Extensions for building the Compute nodes / Load Balancers etc) - unfortunately we don't have a sample for spinning up all of the dependencies for a Service Fabric Cluster at this time - but as @steve-hawkins has mentioned this should be possible to port from the documentation/an ARM Template.

Again as @steve-hawkins has mentioned, the newer Service Fabric Mesh could be a better fit for your use-case if you're looking for Azure to manage all of these resources for you (rather than managing the Service Fabric nodes yourself) - but we don't currently support this in Terraform. If you're looking for Terraform to support this please open a Feature Request for this - but since this question appears to be resolved I'm going to close this issue for the moment.

https://github.com/terraform-providers/terraform-provider-azurerm/issues/2360#issuecomment-446695918

@iharrington this is also achievable through Terraform using a Virtual Machine Scale Set with the Service Fabric Virtual Machine Extension installed (which is the key component here) - as such the ARM Template should be portable to Terraform :)

You can use the below Terraform resource to deploy Service Fabric Cluster using an ARM template:

https://www.terraform.io/docs/providers/azurerm/r/template_deployment.html

ARM Template: https://github.com/Azure/azure-quickstart-templates/blob/master/service-fabric-secure-cluster-5-node-1-nodetype/azuredeploy.json