<p>My development setup uses a microservices deployment in a Docker environment on an Amazon EC2 instance.  Now, we are trying to implement Kubernetes in that EC2 instance to autoscale and load-balance the microservices deployed in Docker.</p>
<p>I saw one method of installing kubectl and minikube and setting up Kubernetes with a node and pods (I think this method is only to test locally).  Another source has a giant process of having two to three EC2 instances, having one as master and other as slave with same setup.</p>
<p>Can I have Kubernetes setup on a master node alone and implement autoscaling and load balancing on that one node? Can keep everything in a single EC2 instance where my microservices are?</p>

<blockquote>
<p>Can I have Kubernetes setup on a master node alone and implement autoscaling and load balancing on that one node?</p>
</blockquote>
<p>Yes, absolutely.</p>
<blockquote>
<p>Can keep everything in a single EC2 instance where my microservices are?</p>
</blockquote>
<p>Yes you can. However, it is not a &quot;best practice&quot; if we are speaking about production.</p>
<blockquote>
<p>My development setup uses a microservices deployment in a Docker environment on an Amazon EC2 instance. Now, we are trying to implement Kubernetes in that EC2 instance to autoscale and load-balance the microservices deployed in Docker.</p>
</blockquote>
<p>I see the following issues with this approach.</p>
<ol>
<li>you are going to put more load on the node as Kubernetes (k8s) itself provides some overhead</li>
<li>as @DavidMaze told, k8s is designed for a massive load in a multi-node environment. And you are trying to use it just to have autoscaling for pods.</li>
</ol>
<blockquote>
<p>I have 30 microservices running on docker.</p>
</blockquote>
<p>It looks like that is <em>at least</em> 30 containers, thus most probably it'll translate to around 30 pods. Please keep in mind, that in addition to the pods requested by user, k8s runs a dozen of pods in a <code>kube-system</code> namespace (dns, kube-proxy, default-backend, etc, etc).</p>
<p>Additionally, you have mentioned autoscaling, so there could be quite a lit of pods on that single node.</p>
<p><strong>Limits.</strong></p>
<p>K8s <a href="https://kubernetes.io/docs/setup/best-practices/cluster-large/" rel="nofollow noreferrer">recommends a maximum number of 110 pods per node</a>.</p>
<p>Up to this number, Kubernetes has been tested to work reliably on common node types.</p>
<p><em>Most managed k8s services even impose hard limits on the number of pods per node:</em></p>
<ul>
<li>On Amazon Elastic Kubernetes Service (EKS), the maximum number of pods per node <a href="https://github.com/awslabs/amazon-eks-ami/blob/master/files/eni-max-pods.txt" rel="nofollow noreferrer">depends on the node type</a> and ranges from 4 to 737.</li>
<li>On Google Kubernetes Engine (GKE), the <a href="https://cloud.google.com/kubernetes-engine/quotas" rel="nofollow noreferrer">limit</a> is 100 pods per node, regardless of the type of node.</li>
<li>On Azure Kubernetes Service (AKS), the <a href="https://learn.microsoft.com/bs-latn-ba/azure/aks/configure-azure-cni#maximum-pods-per-node" rel="nofollow noreferrer">default limit</a> is 30 pods per node but it can be increased up to 250.</li>
</ul>
<p><strong>Availability.</strong></p>
<p>If you have only a few nodes, then the impact of a failing node is bigger than if you have many nodes. For example, if you have only two nodes, and one of them fails, then about half of your pods disappear. And in case you have only one node (with the cluster configuration database on it)... :)</p>
<p>So you aren't getting the benefit of rescheduling the workloads of failed nodes to other nodes.</p>
<p>If you have high-availability requirements, you might require a certain minimum number of nodes in your cluster.</p>
<p>To sum it up:</p>
<ol>
<li>Overhead of maintaining such a setup (and bigger EC2 instance) can be bigger than the price of the managed solution (EKS);</li>
<li>The setup looks quite fragile and you are not getting the main benefit of reliability. That could lead to devastating consequences.</li>
</ol>
<blockquote>
<p>Another source has a giant process of having two to three EC2 instances, having one as master and other as slave with the same setup.</p>
</blockquote>
<p>There are a few ways to install k8s. I think you might want to check <a href="https://github.com/kubernetes/kops" rel="nofollow noreferrer"><code>kops</code></a> tool. Additionally, there is a very comprehensive reading called <a href="https://github.com/kelseyhightower/kubernetes-the-hard-way" rel="nofollow noreferrer">kubernetes-the-hard-way</a> by Kelsey Hightower.</p>
<p>Last but not least, there is <a href="https://learnk8s.io/kubernetes-node-size" rel="nofollow noreferrer">a good article</a> on topic.
Additionally, there are some <a href="https://stackoverflow.com/questions/47673162/running-kubernetes-on-a-single-machine-bare-metal">similar discussions</a> on StackOverflow.</p>
<p>I hope that info sheds some light on a problem and answers your questions :)</p>
