feat: Fix custom AMI bootstrap (#1580)

This commit is contained in:
Steve Hipwell
2021-10-08 15:41:10 +01:00
committed by GitHub
parent b177806614
commit f198efd2c4
4 changed files with 32 additions and 9 deletions

View File

@@ -1,9 +1,20 @@
#!/bin/bash -e
%{ if length(ami_id) == 0 ~}
# Allow user supplied pre userdata code
${pre_userdata}
# Set variables directly into bootstrap.sh for default AMI
sed -i '/^KUBELET_EXTRA_ARGS=/a KUBELET_EXTRA_ARGS+=" ${kubelet_extra_args}"' /etc/eks/bootstrap.sh
%{ if run_bootstrap_script }
/etc/eks/bootstrap.sh ${cluster_name}
%{ endif }
%{else ~}
# Set variables for custom AMI
API_SERVER_URL=${cluster_endpoint}
B64_CLUSTER_CA=${cluster_ca}
KUBELET_EXTRA_ARGS='--node-labels=eks.amazonaws.com/nodegroup-image=${ami_id},eks.amazonaws.com/capacityType=${capacity_type}${append_labels} ${kubelet_extra_args}'
%{endif ~}
# User supplied pre userdata
${pre_userdata}
%{ if length(ami_id) > 0 && ami_is_eks_optimized ~}
# Call bootstrap for EKS optimised custom AMI
/etc/eks/bootstrap.sh ${cluster_name} --apiserver-endpoint "$${API_SERVER_URL}" --b64-cluster-ca "$${B64_CLUSTER_CA}" --kubelet-extra-args "$${KUBELET_EXTRA_ARGS}"
%{ endif ~}