k8s error spec.selector: Required value, spec.template.metadata.labels:

This is a quite common error that i bump into while trying to use istioctl kube-inject cli to parse my deployment with envoy sidecar.

Error from server (Invalid): error when creating ".\\app-ready.yaml": Deployment.apps "service-one" is invalid: [spec.selector: Required value, spec.template.metadata.labels: Invalid value: map[string]string{"app":"service-one", "security.istio.io/tlsMode":"istio", "service.istio.io/canonical-name":"service-one", "service.istio.io/canonical-revision":"latest"}: `selector` does not match template `labels`]

Found out that my Deployment -> Spec -> selector is null

To resolve this i simply had to add it back in as shown below:-

---
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  name: service-two
spec:
  replicas: 1
  selector:
    matchLabels:
      app: service-two # <--- Add this here to fix it
  strategy: {}
 

For the record my original yaml does have this value. It just that istioctl has a weird way of parsing my yaml. 


Comments

Popular posts from this blog

gemini cli getting file not defined error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

vllm : Failed to infer device type