Skip to content

liqotech/terraform-provider-liqo

Repository files navigation

Liqo Terraform Provider

Official Terraform provider for Liqo operations, enabling seamless resource management across Kubernetes clusters.

Overview

The Liqo Terraform Provider allows you to manage Liqo resources declaratively using Terraform. It supports:

  • Cluster Peering: Establish secure peering relationships between Kubernetes clusters
  • Namespace Offloading: Extend namespaces across cluster boundaries

Features

  • ✅ Peer resource with automatic status monitoring
  • ✅ Offload resource for namespace extension
  • ✅ Built-in timeout and error handling

Prerequisites

  • Terraform >= 0.14
  • Go >= 1.19 (for building from source)
  • Liqo installed on your Kubernetes clusters
  • Valid kubeconfig access to your clusters

Installation

Method 1: Using Terraform Registry (Recommended)

terraform {
  required_providers {
    liqo = {
      source  = "liqotech/liqo"
      version = "~> 0.1.0"
    }
  }
}

Method 2: Local Development Build

  1. Create the local plugin directory:

    mkdir -p ~/.terraform.d/plugins/liqo-provider/liqo/liqo/0.0.1/<architecture>/

    Replace <architecture> with your system architecture (e.g., linux_amd64, linux_arm64, darwin_amd64)

  2. Build and install the provider:

    go build -o ~/.terraform.d/plugins/liqo-provider/liqo/liqo/0.0.1/<architecture>/terraform-provider-liqo
  3. Configure Terraform to use the local provider:

    terraform {
      required_providers {
        liqo = {
          source = "liqo-provider/liqo/liqo"
        }
      }
    }

Quick Start

# Configure the Liqo Provider
provider "liqo" {
  kubernetes = {
    config_path    = "~/.kube/config"
    config_context = "my-local-cluster"  # Optional: specify local cluster context
  }
}

# Establish a peer relationship
resource "liqo_peer" "example" {
  remote_kubeconfig = "/path/to/remote/kubeconfig"
  remote_context    = "my-remote-context"  # Optional: specify remote cluster context
  timeout           = "10m"  # Optional: wait timeout for peering completion
}

# Offload a namespace
resource "liqo_offload" "example" {
  namespace                = "my-namespace"
  namespace_mapping_strategy = "EnforceSameName"
  pod_offloading_strategy   = "Remote"
  
  depends_on = [liqo_peer.example]
}

Documentation

Detailed documentation is available in the docs/ directory:

Examples

Complete examples are available in the examples/ directory:

Project Structure

├── docs/                    # Documentation
│   ├── index.md            # Provider documentation
│   └── resources/          # Resource-specific docs
├── examples/               # Usage examples
│   ├── provider/          # Provider configuration examples
│   └── resources/         # Resource usage examples
├── liqo/                  # Provider source code
│   ├── provider.go        # Provider implementation
│   ├── peer_resource.go   # Peer resource
│   ├── peer_resource_status.go  # Peer status monitoring
│   ├── offload_resource.go      # Offload resource
│   └── attribute_plan_modifier/  # Custom plan modifiers
└── main.go               # Provider entry point

Development

Building the Provider

  1. Generate version constants (required before building):

    go generate ./liqo

    This automatically extracts the liqo version from go.mod and generates compile-time constants.

  2. Build the provider:

    go build -o terraform-provider-liqo

Version Management

The provider automatically uses the same liqo version as specified in go.mod for downloading liqoctl binaries. This is achieved through:

  • Compile-time extraction: The go generate command extracts the liqo version from go.mod
  • Generated constants: Version information is embedded as Go constants during build
  • Zero runtime overhead: No file parsing or version detection at runtime

When you update the liqo dependency version:

go mod edit -require=github.com/liqotech/[email protected]
go mod tidy
go generate ./liqo  # Updates version constants
go build           # Build with new version

Running Tests

go test ./...

Contributing

Contributions are welcome! Please see our contributing guidelines and submit pull requests to the main repository.

Support

For issues and questions:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •