<p>I have a cluster where I have deployed multiple applications and I want to horizontally scale one of the deployment.
Following is my Yaml for the deployment, how can I achieve it ?
Note : I have tried changing the replicas to more than 1 and applied the new config and restarted the deployment but want to know if I need to add any policies, specs, etc to achieve the right horizontal scaling.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: preview
  namespace: default
  resourceVersion: {}
  uid: {}
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: preview
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: preview
    spec:
      containers:
      - image: gcr.io/{project name}/{image name}
        imagePullPolicy: Always
        name: preview
        resources:
          requests:
            cpu: 10m
            memory: 450Mi
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /app/data
          name: data
        - mountPath: /app/conf
          name: config
          readOnly: true
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: preview
      - name: config
        secret:
          defaultMode: 420
          secretName: preview-secrets
</code></pre>

Jainam Shah
<p>You can use the HPA (Horizontal Pod Autoscaler). Here is what the typical yaml configuration looks like.</p>
<pre><code>apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: hpa_name
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: deployment_name_to_autoscale
  minReplicas: 1
  maxReplicas: 3
  targetCPUUtilizationPercentage: 80
</code></pre>
<p>You can monitor the scaling using <em>kubectl get hpa</em></p>
