Skip to content

Commit

Permalink
🌱 add icmp protocol for udp health check
Browse files Browse the repository at this point in the history
  • Loading branch information
anngdinh committed Apr 17, 2024
1 parent 92d56ec commit f305386
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 2 additions & 0 deletions pkg/utils/vngcloud/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/vngcloud/vlb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
}
}

Expand All @@ -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"))
}
}
}

Expand Down

0 comments on commit f305386

Please sign in to comment.