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.
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
Where can i found the file deployment.yaml in kubernetes ?
LikeLike
OK you right,I should say it a little more precisely 😉
Your deployment specification you defined, for example in a local file *.yaml.
Here is “How a deployment specification is defined for Kubernetes you can find here: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
You can find the deployments in Kubernetes for example with CLI command
kubectl get deployment
(Some other commands https://kubernetes.io/docs/reference/kubectl/cheatsheet/ )I hope the answer is OK for you?
Greetings,
Thomas
LikeLike