-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Installing Elasticsearch inside a Kubernetes cluster with Helm and Te…
…rraform
- Loading branch information
0 parents
commit 8fed507
Showing
3 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
resource kubernetes_cluster_role_binding "tiller-crb" { | ||
metadata { | ||
name = "tiller-crb" | ||
} | ||
|
||
role_ref { | ||
api_group = "rbac.authorization.k8s.io" | ||
kind = "ClusterRole" | ||
name = "cluster-admin" | ||
} | ||
|
||
subject { | ||
kind = "ServiceAccount" | ||
name = "tiller" | ||
namespace = "kube-system" | ||
} | ||
} | ||
|
||
resource kubernetes_service_account "tiller" { | ||
depends_on = [kubernetes_cluster_role_binding.tiller-crb] | ||
metadata { | ||
name = "tiller" | ||
namespace = "kube-system" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
provider "helm" { | ||
kubernetes { | ||
config_path = var.kubeconfig_file_path | ||
} | ||
version = "~> 0.10.4" | ||
service_account = kubernetes_service_account.tiller.metadata[0].name | ||
install_tiller = true | ||
} | ||
|
||
data "helm_repository" "stable" { | ||
name = "elastic" | ||
url = "https://helm.elastic.co" | ||
} | ||
|
||
resource helm_release "elasticsearch_master" { | ||
name = "elasticsearch-master" | ||
repository = data.helm_repository.stable.metadata[0].name | ||
chart = "elasticsearch" | ||
version = "7.6.1" | ||
timeout = 900 | ||
|
||
values = [ | ||
<<RAW_VALUES | ||
volumeClaimTemplate: | ||
accessModes: [ "ReadWriteOnce" ] | ||
storageClassName: "alicloud-disk-ssd" | ||
resources: | ||
requests: | ||
storage: ${var.elasticsearch.master_node.volume_size}Gi | ||
resources: | ||
requests: | ||
cpu: ${var.elasticsearch.master_node.cpu} | ||
memory: ${var.elasticsearch.data_node.memory}Gi | ||
roles: | ||
master: "true" | ||
ingest: "false" | ||
data: "false" | ||
RAW_VALUES | ||
] | ||
|
||
set { | ||
name = "imageTag" | ||
value = "7.6.2" | ||
} | ||
|
||
set { | ||
name = "clusterName" | ||
value = "elasticsearch-cluster" | ||
} | ||
|
||
set { | ||
name = "nodeGroup" | ||
value = "master" | ||
} | ||
} | ||
|
||
resource helm_release "elasticsearch_data" { | ||
name = "elasticsearch-data" | ||
repository = data.helm_repository.stable.metadata[0].name | ||
chart = "elasticsearch" | ||
version = "7.6.1" | ||
timeout = 900 | ||
|
||
values = [ | ||
<<RAW_VALUES | ||
volumeClaimTemplate: | ||
accessModes: [ "ReadWriteOnce" ] | ||
storageClassName: "alicloud-disk-ssd" | ||
resources: | ||
requests: | ||
storage: ${var.elasticsearch.data_node.volume_size}Gi | ||
resources: | ||
requests: | ||
cpu: ${var.elasticsearch.data_node.cpu} | ||
memory: ${var.elasticsearch.data_node.memory}Gi | ||
roles: | ||
master: "false" | ||
ingest: "true" | ||
data: "true" | ||
RAW_VALUES | ||
] | ||
|
||
set { | ||
name = "imageTag" | ||
value = "7.6.2" | ||
} | ||
|
||
set { | ||
name = "clusterName" | ||
value = "elasticsearch-cluster" | ||
} | ||
|
||
set { | ||
name = "nodeGroup" | ||
value = "data" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
variable "elasticsearch" { | ||
type = object({ | ||
master_node = object({ | ||
volume_size = number | ||
cpu = number | ||
memory = number | ||
}) | ||
|
||
data_node = object({ | ||
volume_size = number | ||
cpu = number | ||
memory = number | ||
}) | ||
}) | ||
} | ||
|
||
variable "kubeconfig_file_path" { | ||
type = string | ||
default = "/my/file/path" | ||
} |