diff --git a/go.mod b/go.mod index a6aed41..4a7bf20 100755 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 - github.com/vngcloud/vngcloud-go-sdk v0.0.1-0.20240409061655-d0b5f527f6ea + github.com/vngcloud/vngcloud-go-sdk v0.0.1-0.20240415044012-c3352d3b520e gopkg.in/gcfg.v1 v1.2.3 k8s.io/api v0.29.0 k8s.io/apimachinery v0.29.0 diff --git a/go.sum b/go.sum index c973955..d9ad705 100755 --- a/go.sum +++ b/go.sum @@ -236,6 +236,8 @@ github.com/vngcloud/vngcloud-go-sdk v0.0.1-0.20240409031653-469d2896b5c7 h1:IDj7 github.com/vngcloud/vngcloud-go-sdk v0.0.1-0.20240409031653-469d2896b5c7/go.mod h1:ooZo+kYuaDbn1HzS8KUEORKGj68yEtDx1XLJU06Xw4k= github.com/vngcloud/vngcloud-go-sdk v0.0.1-0.20240409061655-d0b5f527f6ea h1:ggNJdzaE2YnYSfpqbgfRPxadWDIDVDtAUcdwL9XriQ0= github.com/vngcloud/vngcloud-go-sdk v0.0.1-0.20240409061655-d0b5f527f6ea/go.mod h1:ooZo+kYuaDbn1HzS8KUEORKGj68yEtDx1XLJU06Xw4k= +github.com/vngcloud/vngcloud-go-sdk v0.0.1-0.20240415044012-c3352d3b520e h1:3Ex9Ka4CfrxBf1TdURxaod+ZazUAxJy8n6oYYvjQr0I= +github.com/vngcloud/vngcloud-go-sdk v0.0.1-0.20240415044012-c3352d3b520e/go.mod h1:ooZo+kYuaDbn1HzS8KUEORKGj68yEtDx1XLJU06Xw4k= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/pkg/utils/vngcloud/utils.go b/pkg/utils/vngcloud/utils.go index 05919f6..32683ce 100644 --- a/pkg/utils/vngcloud/utils.go +++ b/pkg/utils/vngcloud/utils.go @@ -107,6 +107,8 @@ func HealthcheckProtocoToSecGroupProtocol(p string) secgroup_rule.CreateOptsProt return secgroup_rule.CreateOptsProtocolOptTCP case "udp": return secgroup_rule.CreateOptsProtocolOptUDP + case "icmp": + return secgroup_rule.CreateOptsProtocolOptICMP default: return secgroup_rule.CreateOptsProtocolOptTCP } diff --git a/pkg/vngcloud/vlb.go b/pkg/vngcloud/vlb.go index fbecf2e..afca49a 100644 --- a/pkg/vngcloud/vlb.go +++ b/pkg/vngcloud/vlb.go @@ -472,6 +472,10 @@ func (c *vLB) inspectService(pService *lCoreV1.Service) (*Expander, error) { if serviceConf.IsAutoCreateSecurityGroup { ingressInspect.AddSecgroupRule(monitorPort, vngcloudutil.HealthcheckProtocoToSecGroupProtocol(string(port.Protocol))) + if strings.EqualFold(string(port.Protocol), "UDP") { + ingressInspect.AddSecgroupRule(monitorPort, + vngcloudutil.HealthcheckProtocoToSecGroupProtocol("ICMP")) + } } } @@ -494,6 +498,10 @@ func (c *vLB) inspectService(pService *lCoreV1.Service) (*Expander, error) { if serviceConf.IsAutoCreateSecurityGroup { ingressInspect.AddSecgroupRule(int(port.NodePort), vngcloudutil.HealthcheckProtocoToSecGroupProtocol(string(port.Protocol))) + if strings.EqualFold(string(port.Protocol), "UDP") { + ingressInspect.AddSecgroupRule(monitorPort, + vngcloudutil.HealthcheckProtocoToSecGroupProtocol("ICMP")) + } } }