apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
  name: demo-nodepool
  annotations:
    karpenter.sh/description: "Demo NodePool for asciinema recording"
spec:
  # Template for nodes created by this NodePool
  template:
    metadata:
      labels:
        karpenter-demo: "true"
        provisioner: "karpenter-ibm"
    spec:
      # Reference to our IBMNodeClass
      nodeClassRef:
        group: karpenter.ibm.sh
        kind: IBMNodeClass
        name: demo-vpc-nodeclass
      
      # Instance requirements
      requirements:
      - key: karpenter.sh/capacity-type
        operator: In
        values: ["on-demand"]
      - key: node.kubernetes.io/instance-type
        operator: In
        values: ["bx2-2x8", "bx2-4x16"]  # Include NodeClass instanceProfile bx2-2x8
      - key: kubernetes.io/arch
        operator: In
        values: ["amd64"]
      # Zone is specified in NodeClass, no need to restrict here
      # - key: topology.kubernetes.io/zone
      #   operator: In
      #   values: ["eu-de-2"]
      
      # Node expiry after 30 days
      expireAfter: 1h
  
  # Resource limits for this NodePool
  limits:
    cpu: 100      # Maximum 100 vCPUs
    memory: 200Gi # Maximum 200Gi memory
  
  # Disruption settings for consolidation
  disruption:
    consolidationPolicy: WhenEmpty
    consolidateAfter: 30s
    budgets:
    - nodes: 10%  # Don't disrupt more than 10% of nodes at once
  
  # Lower weight means higher priority
  weight: 10