mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-03-11 21:11:32 +01:00
feat: Improve managed node group bootstrap revisited (#1577)
This commit is contained in:
@@ -1,13 +1,27 @@
|
||||
#!/bin/bash -e
|
||||
%{ if length(ami_id) == 0 ~}
|
||||
|
||||
# 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
|
||||
# Set bootstrap env
|
||||
printf '#!/bin/bash
|
||||
%{ for k, v in bootstrap_env ~}
|
||||
export ${k}="${v}"
|
||||
%{ endfor ~}
|
||||
export ADDITIONAL_KUBELET_EXTRA_ARGS="${kubelet_extra_args}"
|
||||
' > /etc/profile.d/eks-bootstrap-env.sh
|
||||
|
||||
# Source extra environment variables in bootstrap script
|
||||
sed -i '/^set -o errexit/a\\nsource /etc/profile.d/eks-bootstrap-env.sh' /etc/eks/bootstrap.sh
|
||||
|
||||
# Merge ADDITIONAL_KUBELET_EXTRA_ARGS into KUBELET_EXTRA_ARGS
|
||||
sed -i 's/^KUBELET_EXTRA_ARGS="$${KUBELET_EXTRA_ARGS:-}/KUBELET_EXTRA_ARGS="$${KUBELET_EXTRA_ARGS:-} $${ADDITIONAL_KUBELET_EXTRA_ARGS}/' /etc/eks/bootstrap.sh
|
||||
%{else ~}
|
||||
|
||||
# Set variables for custom AMI
|
||||
API_SERVER_URL=${cluster_endpoint}
|
||||
B64_CLUSTER_CA=${cluster_auth_base64}
|
||||
%{ for k, v in bootstrap_env ~}
|
||||
${k}="${v}"
|
||||
%{ endfor ~}
|
||||
KUBELET_EXTRA_ARGS='--node-labels=eks.amazonaws.com/nodegroup-image=${ami_id},eks.amazonaws.com/capacityType=${capacity_type}${append_labels} ${kubelet_extra_args}'
|
||||
%{endif ~}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user