Skip to content

Commit

Permalink
AWS EKS tutorial change to new terraform script (#463)
Browse files Browse the repository at this point in the history
* Extracts certain values to variables

* Adds TF variables for AWS EKS tutorial, generalizes userdata.sh script

* Adds some small corrections

* Modifies aws-eks-tutorial to use the deploy/aws terraform script

* Removes comments from variables.tf

* Adds step in tutorial introduction

* Adds explanation why scaling out is done with terraform

* Adds warning about instance types breaking user data setup

* Changes tutorial instace types of monitor and tidb to not use local ssd

* Updates tutorial docs to reflect instances in tutorial var file
  • Loading branch information
jlerche authored and tennix committed May 9, 2019
1 parent 7f1d85b commit 162cf4c
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 367 deletions.
2 changes: 1 addition & 1 deletion deploy/aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The default setup will create a new VPC and a t2.micro instance as bastion machi

``` shell
$ git clone https://github.com/pingcap/tidb-operator
$ cd tidb-operator/cloud/aws
$ cd tidb-operator/deploy/aws
$ terraform init
$ terraform apply
```
Expand Down
11 changes: 11 additions & 0 deletions deploy/aws/aws-tutorial.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pd_instance_type = "c5d.large"
tikv_instance_type = "c5d.large"
tidb_instance_type = "c4.large"
monitor_instance_type = "c5.large"

pd_count = 1
tikv_count = 1
tidb_count = 1

cluster_name = "aws_tutorial"
tikv_root_volume_size = "50"
12 changes: 6 additions & 6 deletions deploy/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,31 @@ module "eks" {
key_name = "${module.key-pair.key_name}"
# WARNING: if you change instance type, you must also modify the corresponding disk mounting in pd-userdata.sh script
# instance_type = "c5d.xlarge" # 4c, 8G, 100G NVMe SSD
instance_type = "m5d.xlarge" # 4c, 16G, 150G NVMe SSD
instance_type = "${var.pd_instance_type}" # m5d.xlarge 4c, 16G, 150G NVMe SSD
root_volume_size = "50" # rest NVMe disk for PD data
public_ip = false
kubelet_extra_args = "--register-with-taints=dedicated=pd:NoSchedule --node-labels=dedicated=pd"
asg_desired_capacity = "${var.pd_count}"
asg_max_size = "${var.pd_count + 2}"
additional_userdata = "${file("pd-userdata.sh")}"
additional_userdata = "${file("userdata.sh")}"
},
{ # tikv
name = "tikv_worker_group"
key_name = "${module.key-pair.key_name}"
# WARNING: if you change instance type, you must also modify the corresponding disk mounting in tikv-userdata.sh script
instance_type = "i3.2xlarge" # 8c, 61G, 1.9T NVMe SSD
instance_type = "${var.tikv_instance_type}" # i3.2xlarge 8c, 61G, 1.9T NVMe SSD
root_volume_type = "gp2"
root_volume_size = "100"
public_ip = false
kubelet_extra_args = "--register-with-taints=dedicated=tikv:NoSchedule --node-labels=dedicated=tikv"
asg_desired_capacity = "${var.tikv_count}"
asg_max_size = "${var.tikv_count + 2}"
additional_userdata = "${file("tikv-userdata.sh")}"
additional_userdata = "${file("userdata.sh")}"
},
{ # tidb
name = "tidb_worker_group"
key_name = "${module.key-pair.key_name}"
instance_type = "c4.4xlarge" # 16c, 30G
instance_type = "${var.tidb_instance_type}" # c4.4xlarge 16c, 30G
root_volume_type = "gp2"
root_volume_size = "100"
public_ip = false
Expand All @@ -134,7 +134,7 @@ module "eks" {
{ # monitor
name = "monitor_worker_group"
key_name = "${module.key-pair.key_name}"
instance_type = "c5.xlarge" # 4c, 8G
instance_type = "${var.monitor_instance_type}" # c5.xlarge 4c, 8G
root_volume_type = "gp2"
root_volume_size = "100"
public_ip = false
Expand Down
35 changes: 35 additions & 0 deletions deploy/aws/userdata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# set ulimits
cat <<EOF > /etc/security/limits.d/99-tidb.conf
root soft nofile 1000000
root hard nofile 1000000
root soft core unlimited
root soft stack 10240
EOF
# config docker ulimit
cp /usr/lib/systemd/system/docker.service /etc/systemd/system/docker.service
sed -i 's/LimitNOFILE=infinity/LimitNOFILE=1048576/' /etc/systemd/system/docker.service
sed -i 's/LimitNPROC=infinity/LimitNPROC=1048576/' /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl restart docker

# format and mount nvme disk
if grep nvme0n1 /etc/fstab || grep nvme1n1 /etc/fstab; then
echo "disk already mounted"
else
if mkfs -t ext4 /dev/nvme1n1 ; then

mkdir -p /mnt/disks/ssd1
cat <<EOF >> /etc/fstab
/dev/nvme1n1 /mnt/disks/ssd1 ext4 defaults,nofail,noatime,nodelalloc 0 2
EOF
mount -a
else
mkfs -t ext4 /dev/nvme0n1
mkdir -p /mnt/disks/ssd1
cat <<EOF >> /etc/fstab
/dev/nvme0n1 /mnt/disks/ssd1 ext4 defaults,nofail,noatime,nodelalloc 0 2
EOF
mount -a
fi
fi

22 changes: 22 additions & 0 deletions deploy/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,25 @@ variable "tikv_count" {
variable "tidb_count" {
default = 2
}

// Be careful about changing the instance types, it may break the user data and local volume setup
variable "pd_instance_type" {
default = "m5d.xlarge"
}

variable "tikv_instance_type" {
default = "i3.2xlarge"
}

variable "tidb_instance_type" {
default = "c4.4xlarge"
}

variable "monitor_instance_type" {
default = "c5.xlarge"
}

variable "tikv_root_volume_size" {
default = "100"
}

Loading

0 comments on commit 162cf4c

Please sign in to comment.