<p>How to configure Kubernetes deployment to run only one replica of pod always ? We can configure replicas as 1 in the deployment file but this will not prevent someone from scaling up pods using kubectl. </p>

<p>You can't directly restrict a Deployment resource to not allow more than one replica.</p>

<p>But you could create a custom <a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#validatingadmissionwebhook" rel="nofollow noreferrer">ValidatingAdmissionWebhook</a> admission controller that rejects requests that try to modify the <code>replicas</code> field of this Deployment.</p>

<p>Or you could create a Custom Resource Definition (CRD) that has a similar behaviour as a Deployment, but has the number of replicas fixed to 1.</p>

<p>In general, if you just want to prevent certain users from scaling a replica, you could restrict the RBAC permissions for these users to prevent them from updating Deployment objects.</p>
