赶知识网

selector does not match template labels

OS/操作系统 2020-11-12发布 2115次点击
The error is self-explanatory: "selector" does not match template "labels".

Edit your YAML files and set the same key-value pairs in both selector.matchLabels and metadata.labels.

spec:
  selector:
    matchLabels: # <---- This
      app: database
  template:
    metadata:
      labels: # <---- This
        io.kompose.service: database 
  • Why selector field is important?

The selector field defines how the Deployment finds which Pods to manage. In this case, you simply select a label that is defined in the Pod template (app: nginx). However, more sophisticated selection rules are possible, as long as the Pod template itself satisfies the rule.

Update:

One possible sample can be:

spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: database
  template:
    metadata:
      labels:
         app.kubernetes.io/name: database

Update2:

no matches for kind "Deployment" in version "extensions/v1beta1"

The apiVersion for Deployment object is now apps/v1.

apiVersion: apps/v1 # <-- update here.
kind: Deployment
... ... ...

Top10

沪ICP备09053415号 © 赶知识网