error: no matches forkind “Deployment”in version “apps/v1beta1”

This is a short blog post about changes in the new Kubernetes deployment definition.
In my older blog posts related to Kubernetes you will find older deployment definitions, these definitions will cause errors during the Kubernetes deployment. Here are the two major problems you maybe will notice:

1. If you get the following error

error: unable to recognize "deployment.yaml": 
no matches forkind "Deployment"in version "apps/v1beta1"
Please change the entry apps/v1beta1 to apps/v1 in the deployment.yaml file, the newer `deployment definition` for Kubernetes v1.16.8 (v1.18).

Note: Additional useful blog post here.


2. If you get this error

error: error validating "deployment.yaml": 
error validating data: ValidationError(Deployment.spec): 
missing required field "selector"in io.k8s.api.apps.v1.DeploymentSpec; 
#if you choose to ignore these errors, 
turn validation off with --validate=false
You need to insert in the deployment specification the statement selector:matchLabels:name:authors, as you see in the table below.
The table contains an example of the major changes in the deployment specification, the left hand side contains the new Kubernetes deployment definition and right hand side includes the older definition. The `selector` is now required.

kind: Deployment
apiVersion: apps/v1
metadata:
   name: authors
   labels:
     app: authors
spec:
   selector:
     matchLabels:
       app: authors
       version: v1
  replicas: 1
  template:
    metadata:
     labels:
        app: authors
        version: v1
     spec:
       containers:
       - name: authors
         image: authors:1
         ports:
          - containerPort: 3000
 ...
kind: Deployment
apiVersion: apps/v1beta1
metadata:
  name: authors
  labels:
    app: authors
spec: 
  ...
  ...
  ...
  ...
  replicas: 1
  template:
  metadata:
    labels:
      app: authors
        version: v1
    spec:
      containers:
      - name: authors
        image: authors:1
        ports:
        - containerPort: 3000
...

I hope this was useful for you and let’s see what’s next?

Greetings,

Thomas

PS:  You can try out Cloud Foundry Apps or Kubernetes on IBM Cloud. By the way, you can use the IBM Cloud for free, if you simply create an IBM Lite account. Here you only need an e-mail address.

#Kubernetes, #Deployment, #yaml

 

One thought on “error: no matches forkind “Deployment”in version “apps/v1beta1”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.