in internal/deployers/eksapi/static_cluster.go [70:110]
func (s *StaticClusterManager) CreateNodePool() error {
if !strings.Contains(strings.ToLower(s.options.StaticClusterName), "nvidia") {
klog.Info("NVIDIA not in cluster name, skipping node pool creation")
return nil
}
var arch string
if strings.Contains(s.options.StaticClusterName, "x86_64") {
arch = "amd64"
} else if strings.Contains(s.options.StaticClusterName, "aarch64") {
arch = "arm64"
} else {
return fmt.Errorf("unable to determine architecture from cluster name")
}
t := templates.NvidiaStaticClusterNodepool
var buf bytes.Buffer
if err := t.Execute(&buf, templates.NvidiaStaticClusterNodepoolTemplateData{
Arch: arch,
InstanceTypes: s.options.InstanceTypes,
}); err != nil {
return err
}
nodePool := &karpv1.NodePool{}
if err := yaml.Unmarshal(buf.Bytes(), nodePool); err != nil {
return fmt.Errorf("failed to unmarshal nodepool YAML: %v", err)
}
ctx := context.TODO()
existing := &karpv1.NodePool{}
err := s.karpenterClient.Get(ctx, client.ObjectKey{Name: nodePool.Name}, existing)
if client.IgnoreNotFound(err) != nil {
return err
}
if errors.IsNotFound(err) {
return s.karpenterClient.Create(ctx, nodePool)
}
return nil
}