<p>I'm using AWS EKS with Auto Scaler for the worker nodes. I've private Artifactory docker registry.</p>

<p>Now in order to download docker images from private registry, I've read many documents including kubernetes docs for - how to pull docker image from private docker registry.</p>

<p>There are three steps in the solution:</p>

<ul>
<li>Create <code>kubectl secret</code> which contains docker registry credentials</li>
<li>Add <code>"insecure-registries":["privateRegistryAddress:port"]</code> in <code>/etc/docker/daemon.json</code></li>
<li>Restart docker service</li>
</ul>

<p>I've manually SSH into worker nodes and ran 2nd and 3rd step which works for temporary but as EKS Auto Scaler finds if that worker nodes is not in use then kill it and create new one as needed, where in this new worker node <code>"insecure-registries":["privateRegistryAddress:port"]</code> in <code>/etc/docker/daemon.json</code> is not added, and due to which pod scheduling fails.</p>

<p>There are two solutions I can think of here -</p>

<ul>
<li>Configure AWS EC2 AMI which contains <code>"insecure-registries":["privateRegistryAddress:port"]</code> in <code>/etc/docker/daemon.json</code> default and use that image in auto scaler configuration</li>
<li>Create pod which has node level permission to edit the mentioned file and restart docker service - but I doubt if docker service restarted then that pod itself would go down and if that works or not</li>
</ul>

<p>Please advise. Thanks.</p>

<p>Solved this from first approach I mentioned in question.</p>

<ul>
<li>First of course created <code>kubectl secret</code> to login to private registry</li>
<li>SSHed into kubernetes worker nodes and added <code>["privateRegistryAddress:port"]</code> in <code>/etc/docker/daemon.json</code></li>
<li>Created AMI image out of that node</li>
<li>Updated EC2 launch template with the new AMI and set new template version as default</li>
<li>Updated Ec2 Auto scaling group with new launch template version</li>
<li>Killed previous worker nodes and let auto scaling group created new nodes</li>
</ul>

<p>and voila!! :)</p>

<p>Now whenever EKS using Auto Scaling group increase/decrease EC2 instances, they will be able to download docker images from private docker registry.</p>
