k8s 部署的emqx5, 每次更新会重新启动一个新的sts,那dashboard配置的数据就会丢失

版本:emqx-operator-2.2.23
配置文件:
apiVersion: apps.emqx.io/v2beta1
kind: EMQX
metadata:
name: emqx
namespace: emqx-operator-system
spec:
image: emqx:5
imagePullPolicy: IfNotPresent
coreTemplate:
spec:
replicas: 1
volumeClaimTemplates:
storageClassName: “default”
resources:
requests:
storage: 10G
accessModes:
- ReadWriteOnce
resources:
requests:
cpu: 250m
memory: 512Mi
replicantTemplate:
spec:
replicas: 1
resources:
requests:
cpu: 250m
memory: 1Gi

现象:
更新这个文件会生成新的core服务的statefulset例如:
statefulset.apps/emqx-core-78ccf6fc6
然后新的sts会从sc里面申请新的pv

那存储dashboard的数据就会丢失

这个如何解决?我猜测这个是因为蓝绿部署功能导致的,这个功能不考虑core的数据持久化?

EMQX 设计如此,节点启动时 etc/emqx.conf 配置的优先级高于 Dashboard 的配置,如果你想持久化保存配置,可以在 EMQX 的 yaml 中的 .spec.config.data 中编写和更新你的配置

感谢,请问如何在.spec.config.data配置authentication?
这个有文档吗?我找到了dashboard中关于authentication的配置,但是我不知道如何加入到.spec.config.data例如:


这看着是未生效的


新的配置,apply后报错
{“level”:“error”,“ts”:“2024-06-20T09:33:27Z”,“msg”:“Reconciler error”,“controller”:“emqx”,“controllerGroup”:“apps.emqx.io”,“controllerKind”:“EMQX”,“EMQX”:{“name”:“emqx”,“namespace”:“emqx-operator-system”},“namespace”:“emqx-operator-system”,“name”:“emqx”,“reconcileID”:“0d290861-7472-4d6f-89ae-6eaba0176cc9”,“error”:“failed to put emqx config: failed to put API http://10.10.12.10:18083/api/v5/configs?mode=merge, status : 400 Bad Request, body: {"errors":"{parse_error,#{line => 1,reason => \"syntax error before: 0.1\"}}"}”,“errorVerbose”:“failed to put API http://10.10.12.10:18083/api/v5/configs?mode=merge, status : 400 Bad Request, body: {"errors":"{parse_error,#{line => 1,reason => \"syntax error before: 0.1\"}}"}\ngithub.com/emqx/emqx-operator/controllers/apps/v2beta1.putEMQXConfigsByAPI\n\t/workspace/controllers/apps/v2beta1/sync_emqx_config.go:131\ngithub.com/emqx/emqx-operator/controllers/apps/v2beta1.(*syncConfig).reconcile\n\t/workspace/controllers/apps/v2beta1/sync_emqx_config.go:85\ngithub.com/emqx/emqx-operator/controllers/apps/v2beta1.(*EMQXReconciler).Reconcile\n\t/workspace/controllers/apps/v2beta1/emqx_controller.go:137\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:119\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:316\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:227\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650\nfailed to put emqx config\ngithub.com/emqx/emqx-operator/controllers/apps/v2beta1.(*syncConfig).reconcile\n\t/workspace/controllers/apps/v2beta1/sync_emqx_config.go:86\ngithub.com/emqx/emqx-operator/controllers/apps/v2beta1.(*EMQXReconciler).Reconcile\n\t/workspace/controllers/apps/v2beta1/emqx_controller.go:137\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:119\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:316\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:227\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650”,“stacktrace”:“sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:329\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:227”}

.spec.config.data 支持 EMQX 的 HOCON 格式,所以你直接把 EMQX 的配置复制进来就可以了,关于 EMQX 的配置,你可以参考 EMQX 的文档

400 的报错的话,你可以看一下 EMQX Pod 的 log,我认为应该是配置格式不合法导致的

感谢,我在试试,刚才把authentication.1 加上引号确实解决了上个错误,不过现在包错缺少missing_mechanism_field字段但是我写的配置文件中有mechanism字段
{“level”:“error”,“ts”:“2024-06-20T09:42:25Z”,“msg”:“Reconciler error”,“controller”:“emqx”,“controllerGroup”:“apps.emqx.io”,“controllerKind”:“EMQX”,“EMQX”:{“name”:“emqx”,“namespace”:“emqx-operator-system”},“namespace”:“emqx-operator-system”,“name”:“emqx”,“reconcileID”:“d3881bf1-96df-40e3-8d5c-363793b91757”,“error”:“failed to put emqx config: failed to put API http://10.10.12.10:18083/api/v5/configs?mode=merge, status : 500 Internal Server Error, body: {"code":"INTERNAL_ERROR","message":"throw, {emqx_conf_schema,[#{reason => \"missing_mechanism_field\",path => \"authentication.1\",kind => validation_error}]}, [{hocon_tconf,assert,2,[{file,\"hocon_tconf.erl\"},{line,1230}]},{hocon_tconf,map,4,[{file,\"hocon_tconf.erl\"},{line,303}]},{hocon_tconf,do_check,4,[{file,\"hocon_tconf.erl\"},{line,267}]},{emqx_config,‘-fill_defaults/2-fun-0-’,5,[{file,\"emqx_config.erl\"},{line,490}]},{maps,fold_1,4,[{file,\"maps.erl\"},{line,416}]},{emqx_conf_cli,check_config,2,[{file,\"emqx_conf_cli.erl\"},{line,406}]},{emqx_conf_cli,load_config_from_raw,2,[{file,\"emqx_conf_cli.erl\"},{line,246}]},{emqx_mgmt_api_configs,configs,3,[{file,\"emqx_mgmt_api_configs.erl\"},{line,369}]},{minirest_handler,apply_callback,3,[{file,\"minirest_handler.erl\"},{line,152}]},{minirest_handler,handle,2,[{file,\"minirest_handler.erl\"},{line,56}]},{minirest_handler,init,2,[{file,\"minirest_handler.erl\"},{line,27}]},{cowboy_handler,execute,2,[{file,\"cowboy_handler.erl\"},{line,41}]},{cowboy_stream_h,execute,3,[{file,\"cowboy_stream_h.erl\"},{line,318}]},{cowboy_stream_h,request_process,3,[{file,\"cowboy_stream_h.erl\"},{line,302}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,241}]}]"}”,“errorVerbose”:“failed to put API http://10.10.12.10:18083/api/v5/configs?mode=merge, status : 500 Internal Server Error, body: {"code":"INTERNAL_ERROR","message":"throw, {emqx_conf_schema,[#{reason => \"missing_mechanism_field\",path => \"authentication.1\",kind => validation_error}]}, [{hocon_tconf,assert,2,[{file,\"hocon_tconf.erl\"},{line,1230}]},{hocon_tconf,map,4,[{file,\"hocon_tconf.erl\"},{line,303}]},{hocon_tconf,do_check,4,[{file,\"hocon_tconf.erl\"},{line,267}]},{emqx_config,‘-fill_defaults/2-fun-0-’,5,[{file,\"emqx_config.erl\"},{line,490}]},{maps,fold_1,4,[{file,\"maps.erl\"},{line,416}]},{emqx_conf_cli,check_config,2,[{file,\"emqx_conf_cli.erl\"},{line,406}]},{emqx_conf_cli,load_config_from_raw,2,[{file,\"emqx_conf_cli.erl\"},{line,246}]},{emqx_mgmt_api_configs,configs,3,[{file,\"emqx_mgmt_api_configs.erl\"},{line,369}]},{minirest_handler,apply_callback,3,[{file,\"minirest_handler.erl\"},{line,152}]},{minirest_handler,handle,2,[{file,\"minirest_handler.erl\"},{line,56}]},{minirest_handler,init,2,[{file,\"minirest_handler.erl\"},{line,27}]},{cowboy_handler,execute,2,[{file,\"cowboy_handler.erl\"},{line,41}]},{cowboy_stream_h,execute,3,[{file,\"cowboy_stream_h.erl\"},{line,318}]},{cowboy_stream_h,request_process,3,[{file,\"cowboy_stream_h.erl\"},{line,302}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,241}]}]"}\ngithub.com/emqx/emqx-operator/controllers/apps/v2beta1.putEMQXConfigsByAPI\n\t/workspace/controllers/apps/v2beta1/sync_emqx_config.go:131\ngithub.com/emqx/emqx-operator/controllers/apps/v2beta1.(*syncConfig).reconcile\n\t/workspace/controllers/apps/v2beta1/sync_emqx_config.go:85\ngithub.com/emqx/emqx-operator/controllers/apps/v2beta1.(*EMQXReconciler).Reconcile\n\t/workspace/controllers/apps/v2beta1/emqx_controller.go:137\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:119\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:316\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:227\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650\nfailed to put emqx config\ngithub.com/emqx/emqx-operator/controllers/apps/v2beta1.(*syncConfig).reconcile\n\t/workspace/controllers/apps/v2beta1/sync_emqx_config.go:86\ngithub.com/emqx/emqx-operator/controllers/apps/v2beta1.(*EMQXReconciler).Reconcile\n\t/workspace/controllers/apps/v2beta1/emqx_controller.go:137\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:119\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:316\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:227\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650”,“stacktrace”:“sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:329\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:227”}

已经解决,关闭此单
进入方法进入pod把dashboard生成的HOCON文件粘贴进来,我一开始就是这么处理的,报错是由于其他配置引起的,所以搞错了方向