From 2dcf93fd25d75958663b46ada3843b7958f66e16 Mon Sep 17 00:00:00 2001 From: Apple <932817900@qq.com> Date: Mon, 27 Dec 2021 11:46:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/ces-conf.yaml | 4 ++-- doc/zh_cn.md | 4 ++-- pkg/as3/utils.go | 35 ++++++++++++++++++++++++++++------- pkg/as3/utils_test.go | 3 ++- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/config/ces-conf.yaml b/config/ces-conf.yaml index 71db360..4c70795 100755 --- a/config/ces-conf.yaml +++ b/config/ces-conf.yaml @@ -73,10 +73,10 @@ tenant: serverAddresses: - "10.16.10.23" logPool: - loggingEnabled: false + loggingEnabled: true enableRemoteLog: false serverAddresses: - - "1.2.3.4" + - "1.2.3.4:514" template: '{ "k8s_afm_hsl_log_profile": { "network": { diff --git a/doc/zh_cn.md b/doc/zh_cn.md index 59c904a..5b91532 100755 --- a/doc/zh_cn.md +++ b/doc/zh_cn.md @@ -151,7 +151,7 @@ logPool: loggingEnabled: true enableRemoteLog: false serverAddresses: - - "1.2.3.4" + - "1.2.3.4:514" template: '{ "k8s_afm_hsl_log_profile": { "network": { @@ -247,7 +247,7 @@ tenant: logPool: ##日志 loggingEnabled: 是否配置log profile enableRemoteLog: 是否开启远程日志 - serverAddresses: pool中的ip列表 + serverAddresses: pool中的serverAddresses列表, 默认端口为514 template: 日志配置模板。可参考上面实例 ``` diff --git a/pkg/as3/utils.go b/pkg/as3/utils.go index fcf3661..c928526 100755 --- a/pkg/as3/utils.go +++ b/pkg/as3/utils.go @@ -5,6 +5,7 @@ import ( "fmt" "net" "reflect" + "strconv" "strings" "github.com/kubeovn/ces-controller/pkg/apis/kubeovn.io/v1alpha1" @@ -336,15 +337,35 @@ func (ac *as3Post) newLogPoolDecl(sharedApp as3Application) { sharedApp[k] = v } } + //servicePort default is 514 + numbers := []Member{} + if len(log.ServerAddresses) != 0{ + for _, v :=range log.ServerAddresses{ + ips := strings.Split(v, ":") + ip := ips[0] + port := 514 + if len(ips)> 1{ + vs, err := strconv.Atoi(ips[1]) + if err == nil{ + port = vs + } + } + numbers = append(numbers, Member{ + ServerAddresses: []string{ip}, + ServicePort: port, + Enable: true, + }) + } + }else { + numbers = append(numbers, Member{ + ServerAddresses: []string{"0.0.0.0"}, + ServicePort: 514, + Enable: true, + }) + } sharedApp[GetCluster()+"_log_pool"] = &Pool{ Class: ClassPoll, - Members: []Member{ - Member{ - ServerAddresses: log.ServerAddresses, - ServicePort: 0, - Enable: true, - }, - }, + Members: numbers, Monitors: []Monitor{ Monitor{Bigip: "/Common/gateway_icmp"}, }, diff --git a/pkg/as3/utils_test.go b/pkg/as3/utils_test.go index 1c3f48a..ab18c9e 100755 --- a/pkg/as3/utils_test.go +++ b/pkg/as3/utils_test.go @@ -2743,7 +2743,8 @@ func TestRomteLog(t *testing.T) { IsSupportRouteDomain: false, LogPool: LogPool{ EnableRemoteLog: false, - ServerAddresses: []string{"1.1.1.1"}, + LoggingEnabled: true, + ServerAddresses: []string{"1.1.1.1:8888"}, Template: ` { "k8s_afm_hsl_log_profile": { From 60420b2496ca141aa4034885217c6a96ce58e9e0 Mon Sep 17 00:00:00 2001 From: Apple <932817900@qq.com> Date: Tue, 28 Dec 2021 11:48:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=81=A5=E5=BA=B7=E6=A3=80=E6=9F=A5=E7=B1=BB=E5=9E=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/ces-conf.yaml | 1 + dist/install.sh | 18 +++++++++++------- doc/zh_cn.md | 1 + pkg/as3/types.go | 1 + pkg/as3/utils.go | 2 +- pkg/as3/utils_test.go | 13 +++++++------ 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/config/ces-conf.yaml b/config/ces-conf.yaml index 4c70795..ca92587 100755 --- a/config/ces-conf.yaml +++ b/config/ces-conf.yaml @@ -75,6 +75,7 @@ tenant: logPool: loggingEnabled: true enableRemoteLog: false + healthMonitor: tcp serverAddresses: - "1.2.3.4:514" template: '{ diff --git a/dist/install.sh b/dist/install.sh index 1b6f941..a92ba14 100755 --- a/dist/install.sh +++ b/dist/install.sh @@ -347,13 +347,14 @@ data: logPool: loggingEnabled: true enableRemoteLog: false + healthMonitor: gateway_icmp serverAddresses: - - "1.2.3.4" + - "1.2.3.4:514" template: '{ "k8s_afm_hsl_log_profile": { "network": { "publisher": { - "use": "/Common/Shared/k8s_firewall_hsl_log_publisher" + "use": "/{{tenant}}/Shared/k8s_firewall_hsl_log_publisher" }, "storageFormat": { "fields": [ @@ -387,20 +388,20 @@ data: "k8s_firewall_hsl_log_publisher": { "destinations": [ { - "use": "/Common/Shared/k8s_remote-hsl-dest" + "use": "/{{tenant}}/Shared/k8s_remote-hsl-dest" }, { - "use": "/Common/Shared/k8s_remote-hsl-dest-format" + "use": "/{{tenant}}/Shared/k8s_remote-hsl-dest-format" }, { - "bigip": "/Common/local-db" + "bigip": "/{{tenant}}/local-db" } ], "class": "Log_Publisher" }, "k8s_remote-hsl-dest": { "pool": { - "use": "/Common/Shared/k8s_log_pool" + "use": "/{{tenant}}/Shared/k8s_log_pool" }, "class": "Log_Destination", "type": "remote-high-speed-log" @@ -408,7 +409,7 @@ data: "k8s_remote-hsl-dest-format": { "format": "rfc5424", "remoteHighSpeedLog": { - "use": "/Common/Shared/k8s_remote-hsl-dest" + "use": "/{{tenant}}/Shared/k8s_remote-hsl-dest" }, "class": "Log_Destination", "type": "remote-syslog" @@ -419,6 +420,9 @@ data: - name: "Common" namespaces: "" virtualService: + virtualAddress: "0.0.0.0" + icmpEcho: "disable" + arpEnabled: false template: '' gwPool: serverAddresses: diff --git a/doc/zh_cn.md b/doc/zh_cn.md index 5b91532..aa71c89 100755 --- a/doc/zh_cn.md +++ b/doc/zh_cn.md @@ -247,6 +247,7 @@ tenant: logPool: ##日志 loggingEnabled: 是否配置log profile enableRemoteLog: 是否开启远程日志 + healthMonitor: 健康检查的方法 (tcp, udp, gateway_icmp) serverAddresses: pool中的serverAddresses列表, 默认端口为514 template: 日志配置模板。可参考上面实例 diff --git a/pkg/as3/types.go b/pkg/as3/types.go index 4360a92..037b341 100755 --- a/pkg/as3/types.go +++ b/pkg/as3/types.go @@ -139,6 +139,7 @@ type ( LoggingEnabled bool `mapstructure:"loggingEnabled"` //Whether to open remote log EnableRemoteLog bool `mapstructure:"enableRemoteLog"` + HealthMonitor string `mapstructure:"healthMonitor"` Template string `mapstructure:"template"` ServerAddresses []string `mapstructure:"serverAddresses"` } diff --git a/pkg/as3/utils.go b/pkg/as3/utils.go index c928526..2c5c239 100755 --- a/pkg/as3/utils.go +++ b/pkg/as3/utils.go @@ -367,7 +367,7 @@ func (ac *as3Post) newLogPoolDecl(sharedApp as3Application) { Class: ClassPoll, Members: numbers, Monitors: []Monitor{ - Monitor{Bigip: "/Common/gateway_icmp"}, + Monitor{Bigip: fmt.Sprintf("/%s/%s", DefaultPartition, log.HealthMonitor)}, }, } } diff --git a/pkg/as3/utils_test.go b/pkg/as3/utils_test.go index ab18c9e..0026166 100755 --- a/pkg/as3/utils_test.go +++ b/pkg/as3/utils_test.go @@ -2744,13 +2744,14 @@ func TestRomteLog(t *testing.T) { LogPool: LogPool{ EnableRemoteLog: false, LoggingEnabled: true, + HealthMonitor: "udp", ServerAddresses: []string{"1.1.1.1:8888"}, Template: ` { "k8s_afm_hsl_log_profile": { "network": { "publisher": { - "use": "/Common/Shared/k8s_firewall_hsl_log_publisher" + "use": "/{{tenant}}/Shared/k8s_firewall_hsl_log_publisher" }, "storageFormat": { "fields": [ @@ -2784,20 +2785,20 @@ func TestRomteLog(t *testing.T) { "k8s_firewall_hsl_log_publisher": { "destinations": [ { - "use": "/Common/Shared/k8s_remote-hsl-dest" + "use": "/{{tenant}}/Shared/k8s_remote-hsl-dest" }, { - "use": "/Common/Shared/k8s_remote-hsl-dest-format" + "use": "/{{tenant}}/Shared/k8s_remote-hsl-dest-format" }, { - "bigip": "/Common/local-db" + "bigip": "/{{tenant}}/local-db" } ], "class": "Log_Publisher" }, "k8s_remote-hsl-dest": { "pool": { - "use": "/Common/Shared/k8s_log_pool" + "use": "/{{tenant}}/Shared/k8s_log_pool" }, "class": "Log_Destination", "type": "remote-high-speed-log" @@ -2805,7 +2806,7 @@ func TestRomteLog(t *testing.T) { "k8s_remote-hsl-dest-format": { "format": "rfc5424", "remoteHighSpeedLog": { - "use": "/Common/Shared/k8s_remote-hsl-dest" + "use": "/{{tenant}}/Shared/k8s_remote-hsl-dest" }, "class": "Log_Destination", "type": "remote-syslog"