<p>on kubernetes, one can blindly create a resource (such as deployment, service, pods, etc.). the resouce will be created only if there are enough system resources on the kubernetes nodes\cluster.</p>

<ol>
<li>how does one check that there are enough node resources before creating kubernetes resources (check whether a scale-out and\or scale-up are required)?</li>
<li>what is the best practice to check and asses that the kubernetes cluster can sustain a newly created resource before the resource is created (without doing any manual calculations)?</li>
</ol>

<p>What you are looking for in (1) is possible with a <a href="https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/" rel="nofollow noreferrer">custom admission controller</a> - but I personally think that is too complex and not a great idea from the user experience point of view. </p>

<p>What would be ideal is that once a resource is created - and if the scheduler sees that there are not enough resources - then the cluster is autoscaled. This is possible with <a href="https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler" rel="nofollow noreferrer">Kubernetes Autoscaler</a> or <a href="https://github.com/atlassian/escalator" rel="nofollow noreferrer">Escalator</a>. Both of them allow scaling cluster based on certain conditions - but are suited for different use cases.</p>

<p>You can find detailed information on how does the autoscaler adds nodes when it sees that a pod could be not be scheduled <a href="https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#how-does-scale-up-work" rel="nofollow noreferrer">here</a></p>
