apache / rocketmq-operator

Apache RocketMQ Operator
https://rocketmq.apache.org/
Apache License 2.0
310 stars 126 forks source link

the 'console' create failed. #114

Closed feiyuyitiao closed 2 years ago

feiyuyitiao commented 2 years ago

operator got error when apply console.yaml

2022-07-12T10:58:11.493Z        ERROR   controller.console-controller   Reconciler error        {"name": "console", "namespace": "mq", 
"error": "Deployment.apps \"console\" is invalid: spec.template.metadata.labels: Invalid value: map[string]string(nil): `selector` does not match template `labels`"}
caigy commented 2 years ago

@feiyuyitiao Is spec.template.metadata.labels defined in console.yaml?

feiyuyitiao commented 2 years ago

fix by change code: pkg/controller/console/console_controller.go:201

//Labels: cr.Spec.ConsoleDeployment.Spec.Template.ObjectMeta.Labels, Labels: cr.Spec.ConsoleDeployment.Spec.Selector.MatchLabels,

ccctask commented 2 years ago

same issue with me 😯

ccctask commented 2 years ago

rocketmq-operator/example/rocketmq_v1alpha1_rocketmq_cluster.yaml with example resources define

apiVersion: rocketmq.apache.org/v1alpha1
kind: Console
metadata:
  name: console
spec:
  # nameServers is the [ip:port] list of name service
  nameServers: ""
  # consoleDeployment define the console deployment
  consoleDeployment:
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: rocketmq-console
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: rocketmq-console
      template:
        metadata:
          labels:
            app: rocketmq-console
        spec:
          containers:
            - name: console
              image: apacherocketmq/rocketmq-console:2.0.0
              ports:
                - containerPort: 8080
ccctask commented 2 years ago

fix by change code: pkg/controller/console/console_controller.go:201

//Labels: cr.Spec.ConsoleDeployment.Spec.Template.ObjectMeta.Labels,
  Labels: cr.Spec.ConsoleDeployment.Spec.Selector.MatchLabels,  

:-) This solves the problem, but causes the deployment to rely on its own selector label, not the templates's label

caigy commented 2 years ago

spec.template.metadata.labels was nil, maybe you can kubectl describe the console resource to check the actual definition of this resource, also check the console crd is correct or not.