AWS EKS托管节点组自定义AMI支持:无法通过包含bootstrap.sh的YAML配置文件创建节点组
Let's break down the issue and fix it step by step:
Root Cause
The error you're seeing is a YAML syntax parsing failure at line 15. This typically happens when YAML misinterprets part of your content as a key-value mapping when it shouldn't. In your case, the problem stems from the double quotes wrapping the --kubelet-extra-args parameter in the overrideBootstrapCommand block. The parameter string contains multiple colons that YAML tries to treat as mapping separators, triggering the parsing error.
Also, double-check that you're using spaces for indentation (not tabs) in your YAML file—tabs are invalid in YAML and often cause unexpected parsing issues.
Solution
Modify the overrideBootstrapCommand to use single quotes for the --kubelet-extra-args parameter instead of double quotes. This avoids YAML parsing conflicts while still working correctly in bash. Here's the corrected YAML file:
apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: ginny region: us-west-2 version: '1.17' managedNodeGroups: - name: ginny-mng-custom-ami instanceType: t3.small desiredCapacity: 2 labels: {role: worker} ami: ami-0030109261aa0205b ssh: publicKeyName: bastion preBootstrapCommands: - kubelet --version > /etc/eks/test-preBootstrapCommands overrideBootstrapCommand: | #!/bin/bash set -ex /etc/eks/bootstrap.sh ginny --kubelet-extra-args '--node-labels=alpha.eksctl.io/cluster-name=ginny,alpha.eksctl.io/nodegroup-name=ginny-mng-custom-ami,eks.amazonaws.com/nodegroup=ginny-mng-custom-ami,eks.amazonaws.com/nodegroup-image=ami-0030109261aa0205b'
Verification Steps
- Save the corrected YAML file (note: you had a typo in the filename
maanged-nodegroup.yaml—make sure it'smanaged-nodegroup.yamlwhen running the command). - Re-run your eksctl command:
eksctl create nodegroup --config-file managed-nodegroup.yaml - Check the node group creation progress with:
eksctl get nodegroups --cluster ginny
This change ensures YAML parses the bootstrap command correctly, and the single quotes will be handled properly by bash when executing the bootstrap script.
内容的提问来源于stack exchange,提问作者Gowmi

