mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #84802 from feiskyer/fix-84800
Ensure health probes are created for local traffic policy UDP services on Azure
This commit is contained in:
commit
e450a3d6f3
@ -1096,8 +1096,9 @@ func (az *Cloud) reconcileLoadBalancerRule(
|
|||||||
expectedRule.LoadBalancingRulePropertiesFormat.IdleTimeoutInMinutes = lbIdleTimeout
|
expectedRule.LoadBalancingRulePropertiesFormat.IdleTimeoutInMinutes = lbIdleTimeout
|
||||||
}
|
}
|
||||||
|
|
||||||
// we didn't construct the probe objects for UDP or SCTP because they're not used/needed/allowed
|
// we didn't construct the probe objects for UDP or SCTP because they're not allowed on Azure.
|
||||||
if protocol != v1.ProtocolUDP && protocol != v1.ProtocolSCTP {
|
// However, when externalTrafficPolicy is Local, Kubernetes HTTP health check would be used for probing.
|
||||||
|
if servicehelpers.NeedsHealthCheck(service) || (protocol != v1.ProtocolUDP && protocol != v1.ProtocolSCTP) {
|
||||||
expectedRule.Probe = &network.SubResource{
|
expectedRule.Probe = &network.SubResource{
|
||||||
ID: to.StringPtr(az.getLoadBalancerProbeID(lbName, lbRuleName)),
|
ID: to.StringPtr(az.getLoadBalancerProbeID(lbName, lbRuleName)),
|
||||||
}
|
}
|
||||||
|
@ -1330,6 +1330,60 @@ func TestReconcileLoadBalancer(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service6 := getTestService("test1", v1.ProtocolUDP, nil, 80)
|
||||||
|
lb6 := getTestLoadBalancer(to.StringPtr("testCluster"), to.StringPtr("testCluster"), to.StringPtr("atest1"), service6, "basic")
|
||||||
|
lb6.FrontendIPConfigurations = &[]network.FrontendIPConfiguration{}
|
||||||
|
lb6.Probes = &[]network.Probe{}
|
||||||
|
expectedLB6 := getTestLoadBalancer(to.StringPtr("testCluster"), to.StringPtr("testCluster"), to.StringPtr("atest1"), service6, "basic")
|
||||||
|
expectedLB6.Probes = &[]network.Probe{}
|
||||||
|
(*expectedLB6.LoadBalancerPropertiesFormat.LoadBalancingRules)[0].Probe = nil
|
||||||
|
(*expectedLB6.LoadBalancerPropertiesFormat.LoadBalancingRules)[0].EnableTCPReset = nil
|
||||||
|
(*expectedLB6.LoadBalancerPropertiesFormat.LoadBalancingRules)[0].DisableOutboundSnat = to.BoolPtr(false)
|
||||||
|
expectedLB6.FrontendIPConfigurations = &[]network.FrontendIPConfiguration{
|
||||||
|
{
|
||||||
|
Name: to.StringPtr("atest1"),
|
||||||
|
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
|
||||||
|
PublicIPAddress: &network.PublicIPAddress{ID: to.StringPtr("/subscriptions/subscription/" +
|
||||||
|
"resourceGroups/rg/providers/Microsoft.Network/publicIPAddresses/pipName")},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
service7 := getTestService("test1", v1.ProtocolUDP, nil, 80)
|
||||||
|
service7.Spec.HealthCheckNodePort = 10081
|
||||||
|
service7.Spec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyTypeLocal
|
||||||
|
lb7 := getTestLoadBalancer(to.StringPtr("testCluster"), to.StringPtr("testCluster"), to.StringPtr("atest1"), service7, "basic")
|
||||||
|
lb7.FrontendIPConfigurations = &[]network.FrontendIPConfiguration{}
|
||||||
|
lb7.Probes = &[]network.Probe{}
|
||||||
|
expectedLB7 := getTestLoadBalancer(to.StringPtr("testCluster"), to.StringPtr("testCluster"), to.StringPtr("atest1"), service7, "basic")
|
||||||
|
(*expectedLB7.LoadBalancerPropertiesFormat.LoadBalancingRules)[0].Probe = &network.SubResource{
|
||||||
|
ID: to.StringPtr("/subscriptions/subscription/resourceGroups/rg/providers/Microsoft.Network/loadBalancers/testCluster/probes/atest1-UDP-80"),
|
||||||
|
}
|
||||||
|
(*expectedLB7.LoadBalancerPropertiesFormat.LoadBalancingRules)[0].EnableTCPReset = nil
|
||||||
|
(*expectedLB7.LoadBalancerPropertiesFormat.LoadBalancingRules)[0].DisableOutboundSnat = to.BoolPtr(false)
|
||||||
|
expectedLB7.FrontendIPConfigurations = &[]network.FrontendIPConfiguration{
|
||||||
|
{
|
||||||
|
Name: to.StringPtr("atest1"),
|
||||||
|
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
|
||||||
|
PublicIPAddress: &network.PublicIPAddress{ID: to.StringPtr("/subscriptions/subscription/" +
|
||||||
|
"resourceGroups/rg/providers/Microsoft.Network/publicIPAddresses/pipName")},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
expectedLB7.Probes = &[]network.Probe{
|
||||||
|
{
|
||||||
|
Name: to.StringPtr("atest1-" + string(service7.Spec.Ports[0].Protocol) +
|
||||||
|
"-" + strconv.Itoa(int(service7.Spec.Ports[0].Port))),
|
||||||
|
ProbePropertiesFormat: &network.ProbePropertiesFormat{
|
||||||
|
Port: to.Int32Ptr(10081),
|
||||||
|
RequestPath: to.StringPtr("/healthz"),
|
||||||
|
Protocol: network.ProbeProtocolHTTP,
|
||||||
|
IntervalInSeconds: to.Int32Ptr(5),
|
||||||
|
NumberOfProbes: to.Int32Ptr(2),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
desc string
|
desc string
|
||||||
service v1.Service
|
service v1.Service
|
||||||
@ -1389,6 +1443,24 @@ func TestReconcileLoadBalancer(t *testing.T) {
|
|||||||
expectedLB: expectedSLb5,
|
expectedLB: expectedSLb5,
|
||||||
expectedError: nil,
|
expectedError: nil,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "reconcileLoadBalancer shall reconcile UDP services",
|
||||||
|
loadBalancerSku: "basic",
|
||||||
|
service: service6,
|
||||||
|
existingLB: lb6,
|
||||||
|
wantLb: true,
|
||||||
|
expectedLB: expectedLB6,
|
||||||
|
expectedError: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "reconcileLoadBalancer shall reconcile probes for local traffic policy UDP services",
|
||||||
|
loadBalancerSku: "basic",
|
||||||
|
service: service7,
|
||||||
|
existingLB: lb7,
|
||||||
|
wantLb: true,
|
||||||
|
expectedLB: expectedLB7,
|
||||||
|
expectedError: nil,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range testCases {
|
for i, test := range testCases {
|
||||||
|
Loading…
Reference in New Issue
Block a user