From bd83365d451bb952bb3fd24a927e00df743dc840 Mon Sep 17 00:00:00 2001 From: zhongwencool Date: Mon, 26 Jun 2023 11:23:01 +0800 Subject: [PATCH 1/2] fix: update cluster.conf's k8s default api_server value --- apps/emqx_conf/src/emqx_conf_cli.erl | 29 ++++++++++++++++++++----- apps/emqx_conf/src/emqx_conf_schema.erl | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/apps/emqx_conf/src/emqx_conf_cli.erl b/apps/emqx_conf/src/emqx_conf_cli.erl index 7e5a5b891..44dda04f7 100644 --- a/apps/emqx_conf/src/emqx_conf_cli.erl +++ b/apps/emqx_conf/src/emqx_conf_cli.erl @@ -46,7 +46,7 @@ conf(["show_keys" | _]) -> conf(["show"]) -> print_hocon(get_config()); conf(["show", Key]) -> - print_hocon(get_config(Key)); + print_hocon(get_config(list_to_binary(Key))); conf(["load", "--replace", Path]) -> load_config(Path, replace); conf(["load", "--merge", Path]) -> @@ -163,19 +163,26 @@ print_hocon({error, Error}) -> emqx_ctl:warning("~ts~n", [Error]). get_config() -> - AllConf = emqx_config:fill_defaults(emqx:get_raw_config([])), + AllConf = fill_defaults(emqx:get_raw_config([])), drop_hidden_roots(AllConf). drop_hidden_roots(Conf) -> lists:foldl(fun(K, Acc) -> maps:remove(K, Acc) end, Conf, hidden_roots()). hidden_roots() -> - [<<"trace">>, <<"stats">>, <<"broker">>, <<"persistent_session_store">>, <<"plugins">>]. + [ + <<"trace">>, + <<"stats">>, + <<"broker">>, + <<"persistent_session_store">>, + <<"plugins">>, + <<"zones">> + ]. get_config(Key) -> case emqx:get_raw_config([Key], undefined) of undefined -> {error, "key_not_found"}; - Value -> emqx_config:fill_defaults(#{Key => Value}) + Value -> fill_defaults(#{Key => Value}) end. -define(OPTIONS, #{rawconf_with_defaults => true, override_to => cluster}). @@ -311,7 +318,7 @@ load_etc_config_file() -> filter_readonly_config(Raw) -> SchemaMod = emqx_conf:schema_module(), - RawDefault = emqx_config:fill_defaults(Raw), + RawDefault = fill_defaults(Raw), case emqx_conf:check_config(SchemaMod, RawDefault) of {ok, _CheckedConf} -> ReadOnlyKeys = [atom_to_binary(K) || K <- ?READONLY_KEYS], @@ -358,3 +365,15 @@ do_merge_conf(OldConf = #{}, NewConf = #{}) -> emqx_utils_maps:deep_merge(OldConf, NewConf); do_merge_conf(_OldConf, NewConf) -> NewConf. + +fill_defaults(Conf) -> + Conf1 = emqx_config:fill_defaults(Conf), + filter_cluster_conf(Conf1). + +-define(ALL_STRATEGY, [<<"manual">>, <<"static">>, <<"dns">>, <<"etcd">>, <<"k8s">>, <<"mcast">>]). + +filter_cluster_conf(#{<<"cluster">> := #{<<"discovery_strategy">> := Strategy} = Cluster} = Conf) -> + Cluster1 = maps:without(lists:delete(Strategy, ?ALL_STRATEGY), Cluster), + Conf#{<<"cluster">> => Cluster1}; +filter_cluster_conf(Conf) -> + Conf. diff --git a/apps/emqx_conf/src/emqx_conf_schema.erl b/apps/emqx_conf/src/emqx_conf_schema.erl index 2ab2ff7ac..d5d92920d 100644 --- a/apps/emqx_conf/src/emqx_conf_schema.erl +++ b/apps/emqx_conf/src/emqx_conf_schema.erl @@ -375,7 +375,7 @@ fields(cluster_k8s) -> sc( string(), #{ - default => <<"http://10.110.111.204:8080">>, + default => <<"https://kubernetes.default.svc:443">>, desc => ?DESC(cluster_k8s_apiserver), 'readOnly' => true } From 9719735c9cfaa7235264c46112d33202a4593567 Mon Sep 17 00:00:00 2001 From: zhongwencool Date: Fri, 30 Jun 2023 09:55:23 +0800 Subject: [PATCH 2/2] chore: udpate 11138 changelog --- changes/ce/feat-11138.en.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changes/ce/feat-11138.en.md diff --git a/changes/ce/feat-11138.en.md b/changes/ce/feat-11138.en.md new file mode 100644 index 000000000..4e0af7b6a --- /dev/null +++ b/changes/ce/feat-11138.en.md @@ -0,0 +1,4 @@ +- Change k8s `api_server` default value from `http://127.0.0.1:9091` to `https://kubernetes.default.svc:443` +- `emqx_ctl conf show cluster` no longer displays irrelevant configuration items, such as when `discovery_strategy=static`, +it will not display configuration information related to `etcd/k8s/dns`. +- Remove `zones`(deprecated config key) from `emqx_ctl conf show_keys`