<p>I want to move all of my operations over to K8S for so long, but am still hesitant to that. This question will likely be broad, but bear with me. Let me first describe the existing system.</p>
<p>I hosts a lot of different websites (&gt;30). A lot of that for my own experimentation, but some are for actual clients. I have 1 VM in New York (I'm using DigitalOcean), with multiple Docker containers, frequently managed using <code>docker-compose</code>. There is 1 container for every site. The request first comes in to <code>front</code> container running HAProxy. This strips away SSL, then forwards the request to 2 <code>proxy</code> container running Nginx. These 2 container then forwards the request to all the other containers for their service. All of my certificates come from LetsEncrypt, and have to be renewed every 3 months. To do so, I stop <code>front</code>, run <code>certbot --apache</code> so it binds to port 80. It gets the certificates, then I stop apache, then recreate <code>front</code> container.</p>
<p>There are several reasons to why I do it this way:</p>
<ul>
<li>I change site configs a lot, and how all of them are wired together. So <code>front</code> is expected to run forever, unless I'm getting certificates, and <code>proxy</code>s are expected to change a lot. I change the <code>proxy</code> image, then stops and recreates the 1st container, then stops and recreates the 2nd container, so that there will be no downtime at all.</li>
<li>I really don't know how to get certificates when there are multiple nodes. In fact, I'm a total noob at the whole certificate thing and <code>LetsEncrypt</code> is pretty much the only way I know of to do this.</li>
<li>I want to directly edit files on the remote server. I have a bad practice of editing production code directly, mainly because I get impatient with setting up dev, staging and production environments. It takes too much time, and the gains feels small. And for clients, they are typically small businesses, with &lt;10 employees, and regularly, they want to have some aesthetic changes to the websites. I can have a video call with them, they tell me exactly what they want, I code that in, it gets uploaded to the server immediately, and they see changes right away. Then they can critique the design, and we can iterate back and forth. If I were to setup different environments, they can't see it right away, and there has to be this long process of committing to git, deploy to staging, then production. This takes a long time, and I don't think is justified.</li>
</ul>
<p>I realize that my systems are not that well maintained. Images are not getting security updates, I don't know if they are still running or not unless I check for them manually, which is tedious, so I don't do them at all. Furthermore, I have an Asian background, that means I have clients from both the US and Asia, pretty much the farthest place possible from each other, which increases latency by a lot. That means client in Asia has to wait for around 1-2 second for the page to actually load, which is eternal. I have also moved to Asia in the past week, so now, accessing the New York server via ssh is incredibly slow, and my productivity just plummets. So now it might be the best time to revamp everything, and move to K8S once and forever. However, there are major problems in the planning process and currently, K8S seems to lack a lot of stuff that are just deal breakers for me. So please criticize my plans, and improve them however you see fit.</p>
<p>What I plan to do now is this:
There will be 2 servers, 1 at New York, 1 at Singapore. These 2 severs will have 2 different ip addresses. Those 2 will be running K8S Pods. Preferably, they should have exactly the same configs, website containers, database containers, etc. Then for each website DNS record, I will modify A and AAAA records so that they contain 2 ip addresses for the 2 servers.</p>
<p>My question is:</p>
<ol>
<li>Will DNS always route to Singapore if user is in China, and always route to New York if user is in England?</li>
<li>How to actually get certificates for 2 nodes? My understanding is that when certbot issues a certificate, it associates the domain name with the node ip address. That means 2 nodes can't have the same certificate for the same domain name. Is this correct? If you can get certificates for 2 nodes then how to do that?</li>
<li>How to keep files in sync between servers? Say I edit the file tree in Singapore server, I want that file to also be modified in New York several seconds later. For databases, I can have a master database at either Singapore or New York, then have slave databases at both locations that updates whenever the master updates, and the slaves can serve as a low latency database for each server.</li>
<li>How to actually route requests from servers to containers inside. I initially plan to use NodePort, to direct the request to <code>front</code> Pods, then that can distribute requests to other Pods, but I was heartbroken when NodePort can't attach to ports below 30000. The only other option that I am aware of is to have an external load balancing service that directs traffic to the 2 servers. But that costs like $15/site/month, and because I have &gt;30 sites, doing so will bankrupt me. I can also have 4 servers in total, 2 for the K8S cluster, and 2 serves as a load balancer that will forward to NodePort. Will this plan works? How will automatic renewing of certificates even work here?</li>
</ol>
<p>Please note that may be my questions are the wrong questions to ask (like, may be I shouldn't use A and AAAA records for directing traffic), and there's a different way to do this entirely, so feel free to ask the right questions.</p>

<p>read your question hats off to write down the whole stuff but half of the stuff is useless.</p>
<p>Answers of your question :</p>
<ol>
<li><p>Can we add the same or multiple entries in DNS? example.com with A record multiple times possible?</p>
</li>
<li><p>You might require to set up a regional K8s cluster with regional ingress support. you can use <strong>certmanager</strong> with <strong>letsencrypt</strong> which will manage your cert at LB level and terminate it at the front.</p>
<p>If you are looking forward to use two VMs put one LB in front of both and set SSL over there.</p>
</li>
<li><p>if you are using K8s with stateless PODs editing direct file inside container is not a option. better you manage the Github update inside and container get deployed on to both cluster at a same time for that you can setup CI/CD. You are right in case of database server setup with master slave concept you can use read replicas.</p>
</li>
<li><p>To route the traffic from server to internal application of K8s you can an internal LB or exposing services with <code>node ports</code>(<strong>above 30000 but change target port in SVC</strong>) and route the port if you want to redirect requests on a specific port using the target port.</p>
</li>
</ol>
<p>still, i am not getting &quot;I can also have 4 servers in total, 2 for the K8S cluster, and 2 serves as a load balancer that will forward to NodePort. Will this plan works? How will automatic renewing of certificates even work here?&quot; which server will be in front and which one in the backend.</p>
