<p>I am trying to create a deployment declaratively, using <code>kubectl apply</code>. The below configuration is created just fine when I do</p>

<pre><code>kubectl create -f postgres-deployment.yaml
</code></pre>

<p>but if I go</p>

<pre><code>kubectl apply -f postgres-deployment.yaml
</code></pre>

<p>I am presented with the lovely error message:</p>

<blockquote>
  <p>error: unable to decode "postgres-deployment.yaml": no kind
  "Deployment" is registered for version "apps/v1beta1"</p>
</blockquote>

<p>I have tried searching for an explanation to what this means but I cannot figure it out. </p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: postgres-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:10.1
        ports:
        - containerPort: 5432
</code></pre>

<p>Old Kubernetes versions supported the Deployment object on the <code>extensions/v1beta1</code> API group. <a href="https://v1-9.docs.kubernetes.io/docs/api-reference/v1.9/#deployment-v1beta1-extensions" rel="nofollow noreferrer">That is no longer the case</a>.</p>

<p>For Kubernetes versions before 1.9.0 you should use the API group <code>apps/v1beta2</code>.</p>

<p><a href="https://v1-9.docs.kubernetes.io/docs/api-reference/v1.9/#deployment-v1-apps" rel="nofollow noreferrer">In Kubernetes 1.9</a> and above you should use the API group <code>apps/v1</code>.</p>
