diff --git a/README.md b/README.md
index a5caf74..b2a7217 100644
--- a/README.md
+++ b/README.md
@@ -19,16 +19,16 @@
```terraform
module "as_demo" {
- source = "git@github.com:AxonIQ/terraform-axonserver-k8s.git?ref=v1.9"
+ source = "git@github.com:AxonIQ/terraform-axonserver-k8s.git?ref=v1.10"
- axonserver_release = "2024.1.0"
+ axonserver_release = "2024.1.1"
java_version = "17"
nodes_number = 3
cluster_name = "axonserver"
public_domain = "axoniq.net"
namespace = "axonserver"
-
+
axonserver_license_path = file("${path.module}/axoniq.license")
axonserver_properties = file("${path.module}/axonserver.properties")
}
@@ -57,6 +57,7 @@ module "as_demo" {
| [data\_storage](#input\_data\_storage) | Data PVC storage | `string` | `"10Gi"` | no |
| [plugins\_storage](#input\_plugins\_storage) | Plugins PVC storage | `string` | `"1Gi"` | no |
| [devmode\_enabled](#input\_devmode\_enabled) | Axon Server devmode | `bool` | `false` | no |
+| [assign\_pods\_to\_different\_nodes](#input\_assign\_pods\_to\_different\_nodes) | Avoid the co location of the replicas on the same node | `bool` | `false` | no |
## Outputs
diff --git a/statefulset.tf b/statefulset.tf
index dce81db..c7ead5c 100755
--- a/statefulset.tf
+++ b/statefulset.tf
@@ -33,6 +33,29 @@ resource "kubernetes_stateful_set" "axonserver" {
spec {
termination_grace_period_seconds = 120
+ dynamic "affinity" {
+ for_each = var.assign_pods_to_different_nodes == true ? [1] : [ ]
+ content {
+ pod_anti_affinity {
+ preferred_during_scheduling_ignored_during_execution {
+ weight = "20"
+
+ pod_affinity_term {
+ topology_key = "kubernetes.io/hostname"
+
+ label_selector {
+ match_expressions {
+ key = "cluster"
+ operator = "In"
+ values = [ var.cluster_name ]
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
container {
name = "${var.cluster_name}-${count.index + 1}"
image = "axoniq/axonserver:${var.axonserver_release}-jdk-${var.java_version}"
diff --git a/variables.tf b/variables.tf
index adcdb25..a5f324e 100755
--- a/variables.tf
+++ b/variables.tf
@@ -105,3 +105,9 @@ variable "devmode_enabled" {
type = bool
default = false
}
+
+variable "assign_pods_to_different_nodes" {
+ description = "Avoid co location of the replicas on the same node"
+ type = bool
+ default = false
+}