apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: test
  region: us-east-1
vpc:
  id: vpc-0d2122788fc944c5c
  subnets:
    private:
      us-east-1a:
        id: subnet-0e21d7a0141d077c9
      us-east-1b:
        id: subnet-0e456422a94266cff
      us-east-1c:
        id: subnet-08a374994d1a8c902
  securityGroup: sg-0895b0453ec48180c
addons:
  - name: aws-ebs-csi-driver

nodeGroups:
  - name: admin
    desiredCapacity: 1
    privateNetworking: true
    labels:
      dedicated: admin
      fast-disk-node: "pv-nvme"
    iam:
      withAddonPolicies:
        ebs: true

  # TiDB node groups using m6id.xlarge
  - name: tidb-01
    desiredCapacity: 1
    privateNetworking: true
    availabilityZones: ["us-east-1a"]
    instanceType: m6id.xlarge
    preBootstrapCommands:
      - |
        # Install NVMe CLI
        yum install -y nvme-cli
        
        # Get a list of instance-store NVMe drives
        nvme_drives=$(nvme list | grep "Amazon EC2 NVMe Instance Storage" | awk '{print $1}')
        
        for disk in $nvme_drives; do
          mkfs.ext4 -F $disk
          uuid=$(blkid -o value -s UUID $disk)
          mount_location="/mnt/ssd/${uuid}"
          mkdir -p $mount_location
          mount $disk $mount_location
          echo "$disk $mount_location ext4 defaults,noatime 0 2" >> /etc/fstab
        done
    labels:
      dedicated: tidb
    taints:
      dedicated: tidb:NoSchedule
    iam:
      withAddonPolicies:
        ebs: true
  - name: tidb-02
    desiredCapacity: 1
    privateNetworking: true
    availabilityZones: ["us-east-1b"]
    instanceType: m6id.xlarge
    preBootstrapCommands:
      - |
        # Install NVMe CLI
        yum install -y nvme-cli
        
        # Get a list of instance-store NVMe drives
        nvme_drives=$(nvme list | grep "Amazon EC2 NVMe Instance Storage" | awk '{print $1}')
        
        for disk in $nvme_drives; do
          mkfs.ext4 -F $disk
          uuid=$(blkid -o value -s UUID $disk)
          mount_location="/mnt/ssd/${uuid}"
          mkdir -p $mount_location
          mount $disk $mount_location
          echo "$disk $mount_location ext4 defaults,noatime 0 2" >> /etc/fstab
        done
    labels:
      dedicated: tidb
    taints:
      dedicated: tidb:NoSchedule
    iam:
      withAddonPolicies:
        ebs: true

  # PD node groups remain unchanged
  - name: pd-01
    desiredCapacity: 1
    privateNetworking: true
    availabilityZones: ["us-east-1a"]
    instanceType: c7g.xlarge
    labels:
      dedicated: pd
    taints:
      dedicated: pd:NoSchedule
    iam:
      withAddonPolicies:
        ebs: true
  - name: pd-02
    desiredCapacity: 1
    privateNetworking: true
    availabilityZones: ["us-east-1b"]
    instanceType: c7g.xlarge
    labels:
      dedicated: pd
    taints:
      dedicated: pd:NoSchedule
    iam:
      withAddonPolicies:
        ebs: true
  - name: pd-03
    desiredCapacity: 1
    privateNetworking: true
    availabilityZones: ["us-east-1c"]
    instanceType: c7g.xlarge
    labels:
      dedicated: pd
    taints:
      dedicated: pd:NoSchedule
    iam:
      withAddonPolicies:
        ebs: true
  # TiKV node groups using im4gn.4xlarge with local NVMe fully used for testing
  - name: tikv-01
    desiredCapacity: 1
    privateNetworking: true
    availabilityZones: ["us-east-1a"]
    instanceType: im4gn.xlarge
    preBootstrapCommands:
      - |
        # Install NVMe CLI
        yum install -y nvme-cli
        
        # Get a list of instance-store NVMe drives
        nvme_drives=$(nvme list | grep "Amazon EC2 NVMe Instance Storage" | awk '{print $1}')
        
        for disk in $nvme_drives; do
          mkfs.ext4 -F $disk
          uuid=$(blkid -o value -s UUID $disk)
          mount_location="/mnt/ssd/${uuid}"
          mkdir -p $mount_location
          mount $disk $mount_location
          echo "$disk $mount_location ext4 defaults,noatime 0 2" >> /etc/fstab
        done
    labels:
      dedicated: tikv
    taints:
      dedicated: tikv:NoSchedule
    iam:
      withAddonPolicies:
        ebs: true
  - name: tikv-02
    desiredCapacity: 1
    privateNetworking: true
    availabilityZones: ["us-east-1b"]
    instanceType: im4gn.xlarge
    preBootstrapCommands:
      - |
        # Install NVMe CLI
        yum install -y nvme-cli
        
        # Get a list of instance-store NVMe drives
        nvme_drives=$(nvme list | grep "Amazon EC2 NVMe Instance Storage" | awk '{print $1}')
        
        for disk in $nvme_drives; do
          mkfs.ext4 -F $disk
          uuid=$(blkid -o value -s UUID $disk)
          mount_location="/mnt/ssd/${uuid}"
          mkdir -p $mount_location
          mount $disk $mount_location
          echo "$disk $mount_location ext4 defaults,noatime 0 2" >> /etc/fstab
        done
    labels:
      dedicated: tikv
    taints:
      dedicated: tikv:NoSchedule
    iam:
      withAddonPolicies:
        ebs: true
  - name: tikv-03
    desiredCapacity: 1
    privateNetworking: true
    availabilityZones: ["us-east-1c"]
    instanceType: im4gn.xlarge
    preBootstrapCommands:
      - |
        # Install NVMe CLI
        yum install -y nvme-cli
        
        # Get a list of instance-store NVMe drives
        nvme_drives=$(nvme list | grep "Amazon EC2 NVMe Instance Storage" | awk '{print $1}')
        
        for disk in $nvme_drives; do
          mkfs.ext4 -F $disk
          uuid=$(blkid -o value -s UUID $disk)
          mount_location="/mnt/ssd/${uuid}"
          mkdir -p $mount_location
          mount $disk $mount_location
          echo "$disk $mount_location ext4 defaults,noatime 0 2" >> /etc/fstab
        done
    labels:
      dedicated: tikv
    taints:
      dedicated: tikv:NoSchedule
    iam:
      withAddonPolicies:
        ebs: true