<p>I'm following the example for creating an EKS managed node group from <a href="https://docs.aws.amazon.com/eks/latest/userguide/cni-increase-ip-addresses.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/eks/latest/userguide/cni-increase-ip-addresses.html</a></p>
<p>The configuration requires me to pass additional arguments to the <code>/etc/eks/bootstrap.sh</code> script via the <code>--kubelet-extra-args</code> argument.</p>
<p>My EKS worker nodes are configured via a Terraform resource <a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_node_group" rel="nofollow noreferrer"><code>aws_eks_node_group</code></a></p>
<p>I can't find any option for configuring the resource that would allow me to pass the <code>--kubelet-extra-args</code> arguments.</p>
<p>Am I looking at the wrong place or is there no way to achieve this?</p>

Christian Seifert
<p>If you need to pass the <code>--kubelet-extra-args</code> you have the option of passing user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts.</p>
<p>In my point of view, you should have a tpl (template) file with the script you will need to run when the node is created.</p>
<p>userdata.tpl file like <a href="https://github.com/cloudposse/terraform-aws-eks-node-group/blob/61ac9304b3f4e7383639fdca4712a4580535f461/userdata.tpl#L17" rel="noreferrer">this</a></p>
<pre><code>#!/bin/bash
%{ if length(kubelet_extra_args) &gt; 0 }
export KUBELET_EXTRA_ARGS=&quot;${kubelet_extra_args}&quot;
%{ endif }
%{ if length(kubelet_extra_args) &gt; 0 || length (bootstrap_extra_args) &gt; 0 || length (after_cluster_joining_userdata) &gt; 0 }

/etc/eks/bootstrap.sh --apiserver-endpoint '${cluster_endpoint}' --b64-cluster-ca '${certificate_authority_data}' ${bootstrap_extra_args} '${cluster_name}'
</code></pre>
<p>The previous userdata.tpl file was called using a <a href="https://github.com/cloudposse/terraform-aws-eks-node-group/blob/61ac9304b3f4e7383639fdca4712a4580535f461/userdata.tf#L51" rel="noreferrer">templatefile</a> function that renders all the values on the script.</p>
<p>In another file you gonna have, for instance, a resource called <code>aws_launch_template</code> or <code>aws_launch_configuration</code> that includes an user_data <code>base64encode</code> input like <a href="https://github.com/cloudposse/terraform-aws-eks-node-group/blob/813c88fdc18f10026c8b4fc85b386af2df67e1e0/launch-template.tf#L108" rel="noreferrer">this</a>.</p>
<p>Finally, apply all the changes and then create new nodes, they will be created with the new configuration.</p>
<p>Complete EKS node groups implementation <a href="https://github.com/cloudposse/terraform-aws-eks-node-group" rel="noreferrer">here</a> and an example of how to deploy it <a href="https://github.com/cloudposse/terraform-aws-eks-node-group/tree/master/examples/complete" rel="noreferrer">here</a></p>
<p>I hope it may useful for you.</p>
