Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minikube error - " unknown field "app" in io.k8s"

I receive the following error after running

kubectl apply -f node.deployment.yml  

With the following YAML config:

  1 apiVersion: apps/v1
  2 kind: Deployment
  3 metadata:
  4   name: node-deployment
  5   labels:
  6     app: node-app
  7 spec:
  8   replicas: 2
  9   selector:
 10     app: node-app
 11   template:
 12     metadata:
 13       labels:
 14         app: node-app
 15     spec:
 16       containers:
 17       - name: node-app
 18         image: ubuntu/node
 19         ports:
 20         - containerPort: 8080

Error:

error: error validating "node.deployment.yml": error validating 
data: ValidationError(Deployment.spec.selector): unknown field "app"
 in io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector; 
if you choose to ignore these errors, turn validation off with --validate=fals

I'm using minikube as for a local cluster.

like image 494
Chen Avatar asked Apr 10 '18 13:04

Chen


1 Answers

Found the error, forgot to add matchLabels property:

 9   selector:
 10     matchLabels:
 11       app: node-app
like image 71
Chen Avatar answered Oct 18 '22 02:10

Chen