# An advanced example of ClusterConfig object with customised nodegroups:
---
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
  name: cluster-5
  region: eu-west-2

nodeGroups:
  - name: ng1-public
    instanceType: m5.xlarge
    minSize: 2
    maxSize: 8
    volumeSize: 100
    volumeType: gp2
    ami: ami-05ecac759c81e0b0c
    amiFamily: AmazonLinux2
    # defaults to true, which enforces the use of IMDSv2 tokens
    disableIMDSv1: false
    labels:
      nodegroup-type: frontend-workloads
    iam:
      withAddonPolicies:
        autoScaler: true

  - name: ng2-private-a
    instanceType: m5.large
    desiredCapacity: 2
    labels:
      nodegroup-type: backend-cluster-addons
    targetGroupARNs:
      - arn:aws:elasticloadbalancing:eu-west-2:01234567890:targetgroup/target-group-1/abcdef0123456789
    privateNetworking: true
    preBootstrapCommands:
      # allow docker registries to be deployed as cluster service
      - "sed '2i \"insecure-registries\": [\"172.20.0.0/16\",\"10.100.0.0/16\"],'  /etc/docker/daemon.json"
      - "systemctl restart docker"

  - name: ng3-private-b
    instanceType: c3.8xlarge
    desiredCapacity: 4
    labels:
      nodegroup-type: very-special-science-workloads
    classicLoadBalancerNames:
      - ng3-classic-load-balancer
    asgMetricsCollection:
      - granularity: 1Minute
        metrics:
          - GroupMinSize
          - GroupMaxSize
          - GroupDesiredCapacity
          - GroupInServiceInstances
          - GroupPendingInstances
          - GroupStandbyInstances
          - GroupTerminatingInstances
          - GroupTotalInstances
    taints:
      - key: special
        value: "true"
        effect: NoSchedule
    privateNetworking: true
    availabilityZones: ["eu-west-2a"] # use single AZ to optimise data transfer between instances
    preBootstrapCommands:
      # disable hyperthreading
      - "for n in $(cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | cut -s -d, -f2- | tr ',' '\n' | sort -un); do echo 0 > /sys/devices/system/cpu/cpu${n}/online; done"

# cluster AZs must be set explicitly for single AZ nodegroup example to work
availabilityZones: ["eu-west-2a", "eu-west-2b", "eu-west-2c"]
