<p>I saw that there is an object named <code>PodTemplate</code> which have little <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/#pod-templates" rel="nofollow noreferrer">documentation</a>.  </p>

<p>It is mentioned:</p>

<blockquote>
  <p>Pod templates are pod specifications which are included in other
  objects, such as <strong>Replication Controllers</strong>, <strong>Jobs</strong>, and <strong>DaemonSets</strong>.</p>
</blockquote>

<p>But I am not sure how to mention it on <code>Replication Controllers</code>, <code>Jobs</code> or <code>DaemonSets</code>.  </p>

<p>I created a <code>PodTemplate</code> like this:  </p>

<pre><code>kubectl apply -f - &lt;&lt;EOF
apiVersion: v1
kind: PodTemplate
metadata:
  name: pod-test
  namespace: default
template:
  metadata:
    name: pod-template
  spec:
    containers:
    - name: container
      image: alpine
      command: ["/bin/sh"]
      args: ["-c", "sleep 100"]
EOF
</code></pre>

<p>I want to use it in a <code>DaemonSet</code>, how can I do it ?  </p>

<p>Here is an example for <code>DaemonSet</code> YAML:  </p>

<pre><code>kubectl apply -f - &lt;&lt;EOF
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: pod-by-daemonset
  namespace: default
spec:
  selector:
    matchLabels:
      name: selector
  template:
    metadata:
      labels:
        name: selector
    spec:
      containers: # I don't want to specify it, I want to use the template.
      - name: container
        image: alpine 

EOF
</code></pre>

<p>Interestingly the <a href="https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/" rel="nofollow noreferrer">page for DaemonSet</a> gives an example of creating a DaemonSet and says that </p>

<blockquote>
  <p>the .spec.template is a pod template. It has exactly the same schema
  as a Pod, except it is nested and does not have an apiVersion or kind.</p>
</blockquote>

<p>So the intention is to inline the Pod schema in the DaemonSet.</p>

<p>However, there does <a href="http://docker.codescode.com/about-podtamplate/" rel="nofollow noreferrer">seem to have been a plan</a> to be able to reference a PodTemplate by the form:</p>

<pre><code>TemplateRef:
Name: &lt;templatename&gt;
</code></pre>

<p>What <a href="https://github.com/kubernetes/kubernetes/issues/8109" rel="nofollow noreferrer">seems to have happened from the trail on github</a> is that this way of referencing a predefined PodTemplate was added but not finished and then removed. You can give it a try but it looks to me like only the inline spec is supported.</p>
