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"
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