Skip to content

Commit

Permalink
Merge pull request #25 from AxonIQ/11-avoid-co-location-of-the-replic…
Browse files Browse the repository at this point in the history
…as-on-the-same-node

Avoid co location of the replicas on the same node
  • Loading branch information
checco authored Aug 28, 2024
2 parents 528109b + 442fdd0 commit 5a28eb4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@

```terraform
module "as_demo" {
source = "[email protected]:AxonIQ/terraform-axonserver-k8s.git?ref=v1.9"
source = "[email protected]: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")
}
Expand Down Expand Up @@ -57,6 +57,7 @@ module "as_demo" {
| <a name="input_data_storage"></a> [data\_storage](#input\_data\_storage) | Data PVC storage | `string` | `"10Gi"` | no |
| <a name="input_plugins_storage"></a> [plugins\_storage](#input\_plugins\_storage) | Plugins PVC storage | `string` | `"1Gi"` | no |
| <a name="input_devmode_enabled"></a> [devmode\_enabled](#input\_devmode\_enabled) | Axon Server devmode | `bool` | `false` | no |
| <a name="input_assign_pods_to_different_nodes"></a> [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

Expand Down
23 changes: 23 additions & 0 deletions statefulset.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 5a28eb4

Please sign in to comment.