Official Terraform provider for Liqo operations, enabling seamless resource management across Kubernetes clusters.
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
- ✅ Peer resource with automatic status monitoring
- ✅ Offload resource for namespace extension
- ✅ Built-in timeout and error handling
- Terraform >= 0.14
- Go >= 1.19 (for building from source)
- Liqo installed on your Kubernetes clusters
- Valid kubeconfig access to your clusters
terraform {
required_providers {
liqo = {
source = "liqotech/liqo"
version = "~> 0.1.0"
}
}
}-
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) -
Build and install the provider:
go build -o ~/.terraform.d/plugins/liqo-provider/liqo/liqo/0.0.1/<architecture>/terraform-provider-liqo
-
Configure Terraform to use the local provider:
terraform { required_providers { liqo = { source = "liqo-provider/liqo/liqo" } } }
# 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]
}Detailed documentation is available in the docs/ directory:
Complete examples are available in the examples/ directory:
├── 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
-
Generate version constants (required before building):
go generate ./liqo
This automatically extracts the liqo version from
go.modand generates compile-time constants. -
Build the provider:
go build -o terraform-provider-liqo
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 generatecommand extracts the liqo version fromgo.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 versiongo test ./...Contributions are welcome! Please see our contributing guidelines and submit pull requests to the main repository.
For issues and questions: