<p>I've created a simple K8s deployment with the <code>kubectl create</code> command</p>
<pre><code>kubectl create -f k8-deployment.yaml
</code></pre>
<p>My <code>k8-deployment.yaml</code> file looks like this</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: mage-di
  name: mage-di
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mage-di
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: mage-di
    spec:
      containers:
      - image: astorm/mage-di
        name: mage-di
        imagePullPolicy: Never
        resources: {}
status: {}
</code></pre>
<p>This results in a single pod being started.</p>
<p>I want to tell my k8 cluster that more pods are needed to handle an expected traffic spike.</p>
<p>How should I do this? If I look at <code>kubectl help</code> I see there's an <code>edit</code> command that allows me to edit a deployment object's configuration, but this requires an interactive editor.  Also, I'm new to K8s and I'm unsure if editing a deployment in place and updating its replica count is enough to trigger the <em>proper</em> creation of new pods.  If I look at other <code>kubectl</code> commands I see there's also a <code>rollout</code>, <code>apply</code> and <code>patch</code> command that might do what I want.</p>
<p>Is there a canonically accepted way to do what I want, or is K8s the sort of tech where I just need to experiment and hope for the best?</p>

Alana Storm
<p>You can do this in two ways. Either <em>imperative</em> - a quick command Or <em>declarative</em> - good for a production environment where you store your Deployment-manifest in Git.</p>
<p><strong>Imperative way</strong>: (this will then diverge from what you have in your yaml-file)</p>
<pre><code>kubectl scale deployment mage-di --replicas=2
</code></pre>
<p><strong>Declarative way</strong>, edit this line in your Yaml file:</p>
<pre><code>replicas: 2
</code></pre>
<p>then apply it to the cluster with:</p>
<pre><code>kubectl apply -f k8-deployment.yaml
</code></pre>
<p>See also:</p>
<ul>
<li><a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/" rel="noreferrer">Declarative config management</a></li>
<li><a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/imperative-command/" rel="noreferrer">Imperative config management with commands</a></li>
</ul>
