Skip to content

Commit

Permalink
update after second PR review comment
Browse files Browse the repository at this point in the history
replaced chaos- by chaos_

chaos-mesh : mobed data block and use output

rename modules/k8s/chaos-mesh to modules/k8s/chaos)mesh

infrastructure/modules/k8s/chaos_mesh/variables.tf : update

debug

versions.tfvars.json : debug

infrastructure/quick-deploy/localhost/all-in-one/variables.tf : debug

infrastructure/quick-deploy/localhost/all-in-one/variables.tf : debug

infrastructure/modules/k8s/chaos_mesh/main.tf : debug

terraform fmt  -recursive

tryinh kubernetes_service

infrastructure/modules/k8s/chaos_mesh/outputs.tf : debug

debug

debug

terraform fmt  -recursive

sync localhost

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

terraform fmt  -recursive

debug
  • Loading branch information
egermaneau-aneo committed Feb 14, 2024
1 parent e1d86c9 commit 6566b65
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 115 deletions.
36 changes: 0 additions & 36 deletions infrastructure/modules/k8s/chaos-mesh/main.tf

This file was deleted.

11 changes: 0 additions & 11 deletions infrastructure/modules/k8s/chaos-mesh/outputs.tf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Module for deploying Chaos Mesh

https://chaos-mesh.org/docs/production-installation-using-helm/
https://chaos-mesh.org/docs/offline-installation/
https://chaos_mesh.org/docs/production-installation-using-helm/
https://chaos_mesh.org/docs/offline-installation/
https://github.com/3191110276/terraform-kubernetes-chaosmesh/blob/main/main.tf
70 changes: 70 additions & 0 deletions infrastructure/modules/k8s/chaos_mesh/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

resource "kubernetes_namespace" "chaosmesh" {
metadata {
name = var.namespace
}
}

resource "helm_release" "chaosmesh" {
name = "chaosmesh"
namespace = kubernetes_namespace.chaosmesh.metadata[0].name
chart = "chaos-mesh"
repository = var.helm_chart_repository
version = var.helm_chart_version

set {
name = "image.chaosmesh.repository"
value = var.docker_image.chaosmesh.image
}
set {
name = "image.chaosdaemon.tag"
value = var.docker_image.chaosdaemon.tag
}
set {
name = "image.chaosdashboard.tag"
value = var.docker_image.chaosdashboard.tag
}

set {
name = "dashboard.service.type"
value = var.service_type
}

# commented coz it crash with the error :
# var.node_selector is object with no attributes
# Inappropriate value for attribute "value": string required

#set {
# name = "controllerManager.nodeSelector"
# value = var.node_selector
#}

#set {
# name = "chaosDaemon.nodeSelector"
# value = var.node_selector
#}

#set {
# name = "dashboard.nodeSelector"
# value = var.node_selector
#}

#set {
# name = "dnsServer.nodeSelector"
# value = var.node_selector
#}

#set {
# name = "prometheus.nodeSelector"
# value = var.node_selector
#}

}

data "kubernetes_service" "chaos_dashboard" {
metadata {
name = "chaos-dashboard"
namespace = var.namespace
}
depends_on = [resource.helm_release.chaosmesh]
}
4 changes: 4 additions & 0 deletions infrastructure/modules/k8s/chaos_mesh/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "chaos_mesh_url" {
description = "Chaos Mesh endpoint URL"
value = "http://${data.kubernetes_service.chaos_dashboard.status.0.load_balancer.0.ingress.0.ip}:${data.kubernetes_service.chaos_dashboard.spec.0.port.0.node_port}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ variable "service_type" {
type = string
}

variable "node_selector" {
description = "node selector : {}"
type = any
}

# Docker image
variable "docker_image" {
description = "Docker image for Chaos Mesh"
Expand Down Expand Up @@ -40,3 +45,4 @@ variable "helm_chart_version" {
description = "Version of chart helm for Chaos Mesh"
type = string
}

38 changes: 14 additions & 24 deletions infrastructure/quick-deploy/gcp/all-in-one/chaos-mesh.tf
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
# Chaos Mesh
module "chaos-mesh" {
count = var.chaos-mesh.enable ? 1 : 0
source = "../../../modules/k8s/chaos-mesh/"
namespace = var.chaos-mesh.namespace
module "chaos_mesh" {
count = var.chaos_mesh != null ? 1 : 0
source = "../../../modules/k8s/chaos_mesh/"
namespace = var.chaos_mesh.namespace
docker_image = {
chaosmesh = {
image = var.chaos-mesh.chaosmesh_image_name
tag = try(coalesce(var.chaos-mesh.chaosmesh_image_tag), local.default_tags[var.chaos-mesh.chaosmesh_image_name])
image = var.chaos_mesh.chaosmesh_image_name
tag = try(coalesce(var.chaos_mesh.chaosmesh_image_tag), local.default_tags[var.chaos_mesh.chaosmesh_image_name])
}
chaosdaemon = {
image = var.chaos-mesh.chaosdaemon_image_name
tag = try(coalesce(var.chaos-mesh.chaosdaemon_image_tag), local.default_tags[var.chaos-mesh.chaosdaemon_image_name])
image = var.chaos_mesh.chaosdaemon_image_name
tag = try(coalesce(var.chaos_mesh.chaosdaemon_image_tag), local.default_tags[var.chaos_mesh.chaosdaemon_image_name])
}
chaosdashboard = {
image = var.chaos-mesh.chaosdashboard_image_name
tag = try(coalesce(var.chaos-mesh.chaosdashboard_image_tag), local.default_tags[var.chaos-mesh.chaosdashboard_image_name])
image = var.chaos_mesh.chaosdashboard_image_name
tag = try(coalesce(var.chaos_mesh.chaosdashboard_image_tag), local.default_tags[var.chaos_mesh.chaosdashboard_image_name])
}
}
helm_chart_repository = try(coalesce(var.chaos-mesh.helm_chart_repository), var.helm_charts.chaos-mesh.repository)
helm_chart_version = try(coalesce(var.chaos-mesh.helm_chart_verison), var.helm_charts.chaos-mesh.version)
service_type = var.chaos-mesh.service_type
helm_chart_repository = try(coalesce(var.chaos_mesh.helm_chart_repository), var.helm_charts.chaos_mesh.repository)
helm_chart_version = try(coalesce(var.chaos_mesh.helm_chart_verison), var.helm_charts.chaos_mesh.version)
service_type = var.chaos_mesh.service_type
node_selector = var.chaos_mesh.node_selector
}

data "external" "get_chaos_dashboard_port" {
program = ["sh", "-c", "kubectl get svc chaos-dashboard -n chaos-mesh -o jsonpath='{\"{\"}\"nodeport\": \"{.spec.ports[0].nodePort}\"}'"]
depends_on = [module.chaos-mesh]
}

data "external" "get_chaos_dashboard_ip" {
program = ["sh", "-c", "kubectl get svc chaos-dashboard -n chaos-mesh -o jsonpath='{\"{\"}\"ip\": \"{.status.loadBalancer.ingress[0].ip}\"}'"]
depends_on = [module.chaos-mesh]
}

6 changes: 3 additions & 3 deletions infrastructure/quick-deploy/gcp/all-in-one/gar.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ locals {
var.seq != null ? [var.seq.image_name, var.seq.image_tag] : null,
var.seq != null ? [var.seq.cli_image_name, var.seq.cli_image_tag] : null,
var.grafana != null ? [var.grafana.image_name, var.grafana.image_tag] : null,
var.chaos-mesh != null ? [var.chaos-mesh.chaosmesh_image_name, var.chaos-mesh.chaosmesh_image_tag] : null,
var.chaos-mesh != null ? [var.chaos-mesh.chaosdaemon_image_name, var.chaos-mesh.chaosdaemon_image_tag] : null,
var.chaos-mesh != null ? [var.chaos-mesh.chaosdashboard_image_name, var.chaos-mesh.chaosdashboard_image_tag] : null,
var.chaos_mesh != null ? [var.chaos_mesh.chaosmesh_image_name, var.chaos_mesh.chaosmesh_image_tag] : null,
var.chaos_mesh != null ? [var.chaos_mesh.chaosdaemon_image_name, var.chaos_mesh.chaosdaemon_image_tag] : null,
var.chaos_mesh != null ? [var.chaos_mesh.chaosdashboard_image_name, var.chaos_mesh.chaosdashboard_image_tag] : null,
var.node_exporter != null ? [var.node_exporter.image_name, var.node_exporter.image_tag] : null,
var.partition_metrics_exporter != null ? [
var.partition_metrics_exporter.image_name, var.partition_metrics_exporter.image_tag
Expand Down
6 changes: 1 addition & 5 deletions infrastructure/quick-deploy/gcp/all-in-one/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ output "armonik" {
grafana_url = module.armonik.endpoint_urls.grafana_url
seq_web_url = module.armonik.endpoint_urls.seq_web_url
admin_app_url = module.armonik.endpoint_urls.admin_app_url
chaos_mesh_url = module.chaos_mesh[0].chaos_mesh_url
}
}

output "chaos-mesh" {
description = "Chaos Mesh endpoint URL"
value = "http://${data.external.get_chaos_dashboard_ip.result.ip}:${data.external.get_chaos_dashboard_port.result.nodeport}"
}

output "gke" {
description = "GKE cluster"
value = {
Expand Down
9 changes: 5 additions & 4 deletions infrastructure/quick-deploy/gcp/all-in-one/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,20 @@ variable "keda" {
}

# Chaos Mesh
variable "chaos-mesh" {
variable "chaos_mesh" {
description = "Chaos Mesh configuration"
type = object({
namespace = optional(string, "chaos-mesh")
chaosmesh_image_name = optional(string, "ghcr.io/chaos-mesh/chaos-mesh"),
chaosmesh_image_tag = optional(string, "v2.6.3"),
chaosmesh_image_tag = optional(string),
chaosdaemon_image_name = optional(string, "ghcr.io/chaos-mesh/chaos-daemon"),
chaosdaemon_image_tag = optional(string, "v2.6.3"),
chaosdaemon_image_tag = optional(string),
chaosdashboard_image_name = optional(string, "ghcr.io/chaos-mesh/chaos-dashboard"),
chaosdashboard_image_tag = optional(string, "v2.6.3"),
chaosdashboard_image_tag = optional(string),
helm_chart_repository = optional(string)
helm_chart_version = optional(string)
service_type = optional(string, "LoadBalancer")
node_selector = optional(any, {})
endpoint_url = optional(string)
})
default = {}
Expand Down
37 changes: 14 additions & 23 deletions infrastructure/quick-deploy/localhost/all-in-one/chaos-mesh.tf
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
# Chaos Mesh
module "chaos-mesh" {
count = var.chaos-mesh.enable ? 1 : 0
source = "../../../modules/k8s/chaos-mesh/"
namespace = var.chaos-mesh.namespace
module "chaos_mesh" {
count = var.chaos_mesh != null ? 1 : 0
source = "../../../modules/k8s/chaos_mesh/"
namespace = var.chaos_mesh.namespace
docker_image = {
chaosmesh = {
image = var.chaos-mesh.chaosmesh_image_name
tag = try(coalesce(var.chaos-mesh.chaosmesh_image_tag), local.default_tags[var.chaos-mesh.chaosmesh_image_name])
image = var.chaos_mesh.chaosmesh_image_name
tag = try(coalesce(var.chaos_mesh.chaosmesh_image_tag), local.default_tags[var.chaos_mesh.chaosmesh_image_name])
}
chaosdaemon = {
image = var.chaos-mesh.chaosdaemon_image_name
tag = try(coalesce(var.chaos-mesh.chaosdaemon_image_tag), local.default_tags[var.chaos-mesh.chaosdaemon_image_name])
image = var.chaos_mesh.chaosdaemon_image_name
tag = try(coalesce(var.chaos_mesh.chaosdaemon_image_tag), local.default_tags[var.chaos_mesh.chaosdaemon_image_name])
}
chaosdashboard = {
image = var.chaos-mesh.chaosdashboard_image_name
tag = try(coalesce(var.chaos-mesh.chaosdashboard_image_tag), local.default_tags[var.chaos-mesh.chaosdashboard_image_name])
image = var.chaos_mesh.chaosdashboard_image_name
tag = try(coalesce(var.chaos_mesh.chaosdashboard_image_tag), local.default_tags[var.chaos_mesh.chaosdashboard_image_name])
}
}
helm_chart_repository = try(coalesce(var.chaos-mesh.helm_chart_repository), var.helm_charts.chaos-mesh.repository)
helm_chart_version = try(coalesce(var.chaos-mesh.helm_chart_verison), var.helm_charts.chaos-mesh.version)
service_type = var.chaos-mesh.service_type
helm_chart_repository = try(coalesce(var.chaos_mesh.helm_chart_repository), var.helm_charts.chaos_mesh.repository)
helm_chart_version = try(coalesce(var.chaos_mesh.helm_chart_verison), var.helm_charts.chaos_mesh.version)
service_type = var.chaos_mesh.service_type
node_selector = var.chaos_mesh.node_selector
}

data "external" "get_chaos_dashboard_port" {
program = ["sh", "-c", "kubectl get svc chaos-dashboard -n chaos-mesh -o jsonpath='{\"{\"}\"nodeport\": \"{.spec.ports[0].nodePort}\"}'"]
depends_on = [module.chaos-mesh]
}

data "external" "get_chaos_dashboard_ip" {
program = ["sh", "-c", "kubectl get svc chaos-dashboard -n chaos-mesh -o jsonpath='{\"{\"}\"ip\": \"{.status.loadBalancer.ingress[0].ip}\"}'"]
depends_on = [module.chaos-mesh]
}
5 changes: 1 addition & 4 deletions infrastructure/quick-deploy/localhost/all-in-one/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ output "armonik" {
admin_api_url = module.armonik.endpoint_urls.admin_api_url
admin_0_9_url = module.armonik.endpoint_urls.admin_0_9_url
admin_0_8_url = module.armonik.endpoint_urls.admin_0_8_url
chaos_mesh_url = module.chaos_mesh[0].chaos_mesh_url
}
}

output "chaos-mesh" {
description = "Chaos Mesh endpoint URL"
value = "http://${data.external.get_chaos_dashboard_ip.result.ip}:${data.external.get_chaos_dashboard_port.result.nodeport}"
}
4 changes: 2 additions & 2 deletions infrastructure/quick-deploy/localhost/all-in-one/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ variable "keda" {
}

# Chaos Mesh
variable "chaos-mesh" {
variable "chaos_mesh" {
description = "Chaos Mesh configuration"
type = object({
enable = optional(bool, true)
namespace = optional(string, "chaos-mesh")
chaosmesh_image_name = optional(string, "ghcr.io/chaos-mesh/chaos-mesh"),
chaosmesh_image_tag = optional(string),
Expand All @@ -90,6 +89,7 @@ variable "chaos-mesh" {
helm_chart_repository = optional(string)
helm_chart_version = optional(string)
service_type = optional(string, "LoadBalancer")
node_selector = optional(any, {})
endpoint_url = optional(string)
})
default = {}
Expand Down
2 changes: 1 addition & 1 deletion versions.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@
"cluster_autoscaler" : {"repository" : "https://kubernetes.github.io/autoscaler" , "version" : "9.24.0"},
"termination_handler" : {"repository" : "https://aws.github.io/eks-charts" , "version" : "0.21.0" },
"efs_csi_driver" : { "repository" :"https://kubernetes-sigs.github.io/aws-efs-csi-driver/" , "version": "2.3.0" },
"chaos-mesh" : { "repository" : "https://charts.chaos-mesh.org" , "version" : "2.6.3"}
"chaos_mesh" : { "repository" : "https://charts.chaos-mesh.org" , "version" : "2.6.3"}
}
}

0 comments on commit 6566b65

Please sign in to comment.