<p>I would like to deploy an application cluster by managing my deployment via k8s Deployment object. The documentation has me extremely confused. My basic layout has the following components that scale independently:</p>

<ol>
<li>API server</li>
<li>UI server</li>
<li>Redis cache</li>
<li>Timer/Scheduled task server</li>
</ol>

<p>Technically, all 4 above belong in separate pods that are scaled independently. </p>

<p>My questions are:</p>

<ol>
<li>Do I need to create <code>pod.yml</code> files and then somehow reference them in <code>deployment.yml</code> file or can a deployment file also embed pod definitions?</li>
<li>K8s documentation seems to imply that the <code>spec</code> portion of <code>Deployment</code> is equivalent to defining <em>one</em> pod. Is that correct? What if I want to declaratively describe multi-pod deployments? Do I do need multiple deployment.yml files?</li>
</ol>

<p>Pagids answer has most of the basics. You should create 4 <code>Deployments</code> for your scenario. Each deployment will create a <code>ReplicaSet</code> that schedules and supervises the collection of <code>PODs</code> for the <code>Deployment</code>.</p>

<p>Each <code>Deployment</code> will most likely also require a <code>Service</code> in front of it for access. I usually create a single yaml file that has a <code>Deployment</code> and the corresponding <code>Service</code> in it. Here is an example for an <code>nginx.yaml</code> that I use:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
  name: nginx
  labels:
    app: nginx
spec:
  type: NodePort
  ports:
  - port: 80
    name: nginx
    targetPort: 80
    nodePort: 32756
  selector:
    app: nginx
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginxdeployment
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginxcontainer
        image: nginx:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 80
</code></pre>

<p>Here some additional information for clarification:</p>

<ul>
<li>A <code>POD</code> is not a scalable unit. A <code>Deployment</code> that schedules PODs is.</li>
<li>A <code>Deployment</code> is meant to represent a single group of PODs fulfilling a single purpose together.</li>
<li>You can have many <code>Deployments</code> work together in the virtual network of the cluster.</li>
<li>For accessing a <code>Deployment</code> that may consist of many <code>PODs</code> running on different nodes you have to create a Service.</li>
<li>Deployments are meant to contain stateless services. If you need to store a state you need to create <code>StatefulSet</code> instead (e.g. for a database service).</li>
</ul>
