in pkg/controller/ingress/reconcile/builder/albconfig_manager/model_build_server_group.go [103:177]
func buildServerGroupHealthCheckConfig(ing *networking.Ingress) alb.HealthCheckConfig {
healthCheckEnabled := util.DefaultServerGroupHealthCheckEnabled
if v, ok := ing.Annotations[annotations.HealthCheckEnabled]; ok && v == "true" {
healthCheckEnabled = true
}
healthcheckPath := util.DefaultServerGroupHealthCheckPath
if v, ok := ing.Annotations[annotations.HealthCheckPath]; ok {
healthcheckPath = v
}
healthcheckMethod := util.DefaultServerGroupHealthCheckMethod
if v, ok := ing.Annotations[annotations.HealthCheckMethod]; ok {
healthcheckMethod = v
}
healthcheckProtocol := util.DefaultServerGroupHealthCheckProtocol
if v, ok := ing.Annotations[annotations.HealthCheckProtocol]; ok {
healthcheckProtocol = v
}
healthcheckCode := util.DefaultServerGroupHealthCheckHTTPCodes
if v, ok := ing.Annotations[annotations.HealthCheckHTTPCode]; ok {
healthcheckCode = v
}
healthcheckTimeout := util.DefaultServerGroupHealthCheckTimeout
if v, ok := ing.Annotations[annotations.HealthCheckTimeout]; ok {
if val, err := strconv.Atoi(v); err != nil {
klog.Error(err.Error())
} else {
healthcheckTimeout = val
}
}
healthCheckInterval := util.DefaultServerGroupHealthCheckInterval
if v, ok := ing.Annotations[annotations.HealthCheckInterval]; ok {
if val, err := strconv.Atoi(v); err != nil {
klog.Error(err.Error())
} else {
healthCheckInterval = val
}
}
healthyThreshold := util.DefaultServerGroupHealthyThreshold
if v, ok := ing.Annotations[annotations.HealthThreshold]; ok {
if val, err := strconv.Atoi(v); err != nil {
klog.Error(err.Error())
} else {
healthyThreshold = val
}
}
unhealthyThreshold := util.DefaultServerGroupUnhealthyThreshold
if v, ok := ing.Annotations[annotations.UnHealthThreshold]; ok {
if val, err := strconv.Atoi(v); err != nil {
klog.Error(err.Error())
} else {
unhealthyThreshold = val
}
}
return alb.HealthCheckConfig{
HealthCheckConnectPort: util.DefaultServerGroupHealthCheckConnectPort,
HealthCheckEnabled: healthCheckEnabled,
HealthCheckHost: util.DefaultServerGroupHealthCheckHost,
HealthCheckHttpVersion: util.DefaultServerGroupHealthCheckHttpVersion,
HealthCheckInterval: healthCheckInterval,
HealthCheckMethod: healthcheckMethod,
HealthCheckPath: healthcheckPath,
HealthCheckProtocol: healthcheckProtocol,
HealthCheckTimeout: healthcheckTimeout,
HealthyThreshold: healthyThreshold,
UnhealthyThreshold: unhealthyThreshold,
HealthCheckTcpFastCloseEnabled: util.DefaultServerGroupHealthCheckTcpFastCloseEnabled,
HealthCheckHttpCodes: []string{
healthcheckCode,
},
HealthCheckCodes: []string{
util.DefaultServerGroupHealthCheckCodes,
},
}
}