Selector does not match template labels

Hi all
I’m running a k8s-cluster with one CN and two Workers:
Client Version: version.Info{Major:“1”, Minor:“26”, GitVersion:“v1.26.2”, GitCommit:“fc04e732bb3e7198d2fa44efa5457c7c6f8c0f5b”, GitTreeState:“clean”, BuildDate:“2023-02-22T13:39:03Z”, GoVersion:“go1.19.6”, Compiler:“gc”, Platform:“linux/amd64”}

For pure test purposes I created this YAML file that should create a Load-Balancer and two Nginx “Frontends”.

apiVersion: v1
kind: List
items:
  - apiVersion: v1
    kind: Service
    metadata:
      name: frontend
      namespace: test
    spec:
      type: LoadBalancer
      loadBalancerIP: 192.168.10.15
      ports:
        - port: 80
      selector:
        name: frontend-pod
  - apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: frontend-deployment
      namespace: test
      labels:
        app: frontend-pod
    spec:
      replicas: 2
      revisionHistoryLimit: 3
      selector: 
        matchLabels:
          app: frontend-pod
      template:
        metadata:
          labels:
            name: frontend-pod
        spec:
          containers:
            - name: nginx
              image: nginx
              ports:
                - containerPort: 80

But it fails:
ubectl create -f lb-service.yaml
service/frontend created
The Deployment “frontend-deployment” is invalid: spec.template.metadata.labels: Invalid value: map[string]string{“name”:“frontend-pod”}: selector does not match template labels

I simply can’t find any mistake here ? Kubeval didn’t find anything along with other (pure) yaml checkers.
Any ideas ?

The deployment spec template label needs to be updated to -
app: frontend-pod
From your deployment file value is name: frontend-pod
The template label needs to be same to the spec selector.

Well, thanks for your answer … although it was “a little bit” vague … as you’ve to add the “app:” line rather than to rename anything.
Now this works:

apiVersion: v1
kind: List
items:
  - apiVersion: v1
    kind: Service
    metadata:
      name: frontend
      namespace: test
    spec:
      type: LoadBalancer
      loadBalancerIP: 192.168.10.15
      ports:
        - port: 80
      selector:
        name: frontend-pod
  - apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: frontend-pod
      namespace: test
      labels:
        app: frontend-pod
    spec:
      replicas: 2
      revisionHistoryLimit: 3
      selector:
        matchLabels:
          app: frontend-pod
      template:
        metadata:
          labels:
            name: frontend-pod
            app: frontend-pod
        spec:
          containers:
            - name: nginx
              image: nginx
              ports:
                - containerPort: 80

And it still does not work correctly, as the LoadBalancer doesn’t get an ext-IP address - although explicitly stated in the yaml file.