mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #97096 from nilo19/cleanup/deprecate-mix-protocol-annotation
Delete deprecated mixed procotol annotation
This commit is contained in:
commit
42d19f9641
@ -95,10 +95,6 @@ const (
|
|||||||
// to specify the idle timeout for connections on the load balancer in minutes.
|
// to specify the idle timeout for connections on the load balancer in minutes.
|
||||||
ServiceAnnotationLoadBalancerIdleTimeout = "service.beta.kubernetes.io/azure-load-balancer-tcp-idle-timeout"
|
ServiceAnnotationLoadBalancerIdleTimeout = "service.beta.kubernetes.io/azure-load-balancer-tcp-idle-timeout"
|
||||||
|
|
||||||
// ServiceAnnotationLoadBalancerMixedProtocols is the annotation used on the service
|
|
||||||
// to create both TCP and UDP protocols when creating load balancer rules.
|
|
||||||
ServiceAnnotationLoadBalancerMixedProtocols = "service.beta.kubernetes.io/azure-load-balancer-mixed-protocols"
|
|
||||||
|
|
||||||
// ServiceAnnotationLoadBalancerEnableHighAvailabilityPorts is the annotation used on the service
|
// ServiceAnnotationLoadBalancerEnableHighAvailabilityPorts is the annotation used on the service
|
||||||
// to enable the high availability ports on the standard internal load balancer.
|
// to enable the high availability ports on the standard internal load balancer.
|
||||||
ServiceAnnotationLoadBalancerEnableHighAvailabilityPorts = "service.beta.kubernetes.io/azure-load-balancer-enable-high-availability-ports"
|
ServiceAnnotationLoadBalancerEnableHighAvailabilityPorts = "service.beta.kubernetes.io/azure-load-balancer-enable-high-availability-ports"
|
||||||
@ -1627,116 +1623,104 @@ func (az *Cloud) reconcileLoadBalancerRule(
|
|||||||
var expectedProbes []network.Probe
|
var expectedProbes []network.Probe
|
||||||
var expectedRules []network.LoadBalancingRule
|
var expectedRules []network.LoadBalancingRule
|
||||||
for _, port := range ports {
|
for _, port := range ports {
|
||||||
protocols := []v1.Protocol{port.Protocol}
|
lbRuleName := az.getLoadBalancerRuleName(service, port.Protocol, port.Port)
|
||||||
if v, ok := service.Annotations[ServiceAnnotationLoadBalancerMixedProtocols]; ok && v == "true" {
|
klog.V(2).Infof("reconcileLoadBalancerRule lb name (%s) rule name (%s)", lbName, lbRuleName)
|
||||||
klog.V(2).Infof("reconcileLoadBalancerRule lb name (%s) flag(%s) is set", lbName, ServiceAnnotationLoadBalancerMixedProtocols)
|
|
||||||
if port.Protocol == v1.ProtocolTCP {
|
transportProto, _, probeProto, err := getProtocolsFromKubernetesProtocol(port.Protocol)
|
||||||
protocols = append(protocols, v1.ProtocolUDP)
|
if err != nil {
|
||||||
} else if port.Protocol == v1.ProtocolUDP {
|
return expectedProbes, expectedRules, err
|
||||||
protocols = append(protocols, v1.ProtocolTCP)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, protocol := range protocols {
|
probeProtocol, requestPath := parseHealthProbeProtocolAndPath(service)
|
||||||
lbRuleName := az.getLoadBalancerRuleName(service, protocol, port.Port)
|
if servicehelpers.NeedsHealthCheck(service) {
|
||||||
klog.V(2).Infof("reconcileLoadBalancerRule lb name (%s) rule name (%s)", lbName, lbRuleName)
|
podPresencePath, podPresencePort := servicehelpers.GetServiceHealthCheckPathPort(service)
|
||||||
|
if probeProtocol == "" {
|
||||||
transportProto, _, probeProto, err := getProtocolsFromKubernetesProtocol(protocol)
|
probeProtocol = string(network.ProbeProtocolHTTP)
|
||||||
if err != nil {
|
}
|
||||||
return expectedProbes, expectedRules, err
|
if requestPath == "" {
|
||||||
|
requestPath = podPresencePath
|
||||||
}
|
}
|
||||||
|
|
||||||
probeProtocol, requestPath := parseHealthProbeProtocolAndPath(service)
|
expectedProbes = append(expectedProbes, network.Probe{
|
||||||
if servicehelpers.NeedsHealthCheck(service) {
|
|
||||||
podPresencePath, podPresencePort := servicehelpers.GetServiceHealthCheckPathPort(service)
|
|
||||||
if probeProtocol == "" {
|
|
||||||
probeProtocol = string(network.ProbeProtocolHTTP)
|
|
||||||
}
|
|
||||||
if requestPath == "" {
|
|
||||||
requestPath = podPresencePath
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedProbes = append(expectedProbes, network.Probe{
|
|
||||||
Name: &lbRuleName,
|
|
||||||
ProbePropertiesFormat: &network.ProbePropertiesFormat{
|
|
||||||
RequestPath: to.StringPtr(requestPath),
|
|
||||||
Protocol: network.ProbeProtocol(probeProtocol),
|
|
||||||
Port: to.Int32Ptr(podPresencePort),
|
|
||||||
IntervalInSeconds: to.Int32Ptr(5),
|
|
||||||
NumberOfProbes: to.Int32Ptr(2),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} else if protocol != v1.ProtocolUDP && protocol != v1.ProtocolSCTP {
|
|
||||||
// we only add the expected probe if we're doing TCP
|
|
||||||
if probeProtocol == "" {
|
|
||||||
probeProtocol = string(*probeProto)
|
|
||||||
}
|
|
||||||
var actualPath *string
|
|
||||||
if !strings.EqualFold(probeProtocol, string(network.ProbeProtocolTCP)) {
|
|
||||||
if requestPath != "" {
|
|
||||||
actualPath = to.StringPtr(requestPath)
|
|
||||||
} else {
|
|
||||||
actualPath = to.StringPtr("/healthz")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
expectedProbes = append(expectedProbes, network.Probe{
|
|
||||||
Name: &lbRuleName,
|
|
||||||
ProbePropertiesFormat: &network.ProbePropertiesFormat{
|
|
||||||
Protocol: network.ProbeProtocol(probeProtocol),
|
|
||||||
RequestPath: actualPath,
|
|
||||||
Port: to.Int32Ptr(port.NodePort),
|
|
||||||
IntervalInSeconds: to.Int32Ptr(5),
|
|
||||||
NumberOfProbes: to.Int32Ptr(2),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
loadDistribution := network.LoadDistributionDefault
|
|
||||||
if service.Spec.SessionAffinity == v1.ServiceAffinityClientIP {
|
|
||||||
loadDistribution = network.LoadDistributionSourceIP
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedRule := network.LoadBalancingRule{
|
|
||||||
Name: &lbRuleName,
|
Name: &lbRuleName,
|
||||||
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
|
ProbePropertiesFormat: &network.ProbePropertiesFormat{
|
||||||
Protocol: *transportProto,
|
RequestPath: to.StringPtr(requestPath),
|
||||||
FrontendIPConfiguration: &network.SubResource{
|
Protocol: network.ProbeProtocol(probeProtocol),
|
||||||
ID: to.StringPtr(lbFrontendIPConfigID),
|
Port: to.Int32Ptr(podPresencePort),
|
||||||
},
|
IntervalInSeconds: to.Int32Ptr(5),
|
||||||
BackendAddressPool: &network.SubResource{
|
NumberOfProbes: to.Int32Ptr(2),
|
||||||
ID: to.StringPtr(lbBackendPoolID),
|
|
||||||
},
|
|
||||||
LoadDistribution: loadDistribution,
|
|
||||||
FrontendPort: to.Int32Ptr(port.Port),
|
|
||||||
BackendPort: to.Int32Ptr(port.Port),
|
|
||||||
DisableOutboundSnat: to.BoolPtr(az.disableLoadBalancerOutboundSNAT()),
|
|
||||||
EnableTCPReset: enableTCPReset,
|
|
||||||
EnableFloatingIP: to.BoolPtr(true),
|
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
} else if port.Protocol != v1.ProtocolUDP && port.Protocol != v1.ProtocolSCTP {
|
||||||
|
// we only add the expected probe if we're doing TCP
|
||||||
|
if probeProtocol == "" {
|
||||||
|
probeProtocol = string(*probeProto)
|
||||||
}
|
}
|
||||||
|
var actualPath *string
|
||||||
if protocol == v1.ProtocolTCP {
|
if !strings.EqualFold(probeProtocol, string(network.ProbeProtocolTCP)) {
|
||||||
expectedRule.LoadBalancingRulePropertiesFormat.IdleTimeoutInMinutes = lbIdleTimeout
|
if requestPath != "" {
|
||||||
}
|
actualPath = to.StringPtr(requestPath)
|
||||||
|
} else {
|
||||||
if requiresInternalLoadBalancer(service) &&
|
actualPath = to.StringPtr("/healthz")
|
||||||
strings.EqualFold(az.LoadBalancerSku, loadBalancerSkuStandard) &&
|
|
||||||
strings.EqualFold(service.Annotations[ServiceAnnotationLoadBalancerEnableHighAvailabilityPorts], "true") {
|
|
||||||
expectedRule.FrontendPort = to.Int32Ptr(0)
|
|
||||||
expectedRule.BackendPort = to.Int32Ptr(0)
|
|
||||||
expectedRule.Protocol = network.TransportProtocolAll
|
|
||||||
}
|
|
||||||
|
|
||||||
// we didn't construct the probe objects for UDP or SCTP because they're not allowed on Azure.
|
|
||||||
// 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{
|
|
||||||
ID: to.StringPtr(az.getLoadBalancerProbeID(lbName, az.getLoadBalancerResourceGroup(), lbRuleName)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
expectedProbes = append(expectedProbes, network.Probe{
|
||||||
expectedRules = append(expectedRules, expectedRule)
|
Name: &lbRuleName,
|
||||||
|
ProbePropertiesFormat: &network.ProbePropertiesFormat{
|
||||||
|
Protocol: network.ProbeProtocol(probeProtocol),
|
||||||
|
RequestPath: actualPath,
|
||||||
|
Port: to.Int32Ptr(port.NodePort),
|
||||||
|
IntervalInSeconds: to.Int32Ptr(5),
|
||||||
|
NumberOfProbes: to.Int32Ptr(2),
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadDistribution := network.LoadDistributionDefault
|
||||||
|
if service.Spec.SessionAffinity == v1.ServiceAffinityClientIP {
|
||||||
|
loadDistribution = network.LoadDistributionSourceIP
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedRule := network.LoadBalancingRule{
|
||||||
|
Name: &lbRuleName,
|
||||||
|
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
|
||||||
|
Protocol: *transportProto,
|
||||||
|
FrontendIPConfiguration: &network.SubResource{
|
||||||
|
ID: to.StringPtr(lbFrontendIPConfigID),
|
||||||
|
},
|
||||||
|
BackendAddressPool: &network.SubResource{
|
||||||
|
ID: to.StringPtr(lbBackendPoolID),
|
||||||
|
},
|
||||||
|
LoadDistribution: loadDistribution,
|
||||||
|
FrontendPort: to.Int32Ptr(port.Port),
|
||||||
|
BackendPort: to.Int32Ptr(port.Port),
|
||||||
|
DisableOutboundSnat: to.BoolPtr(az.disableLoadBalancerOutboundSNAT()),
|
||||||
|
EnableTCPReset: enableTCPReset,
|
||||||
|
EnableFloatingIP: to.BoolPtr(true),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if port.Protocol == v1.ProtocolTCP {
|
||||||
|
expectedRule.LoadBalancingRulePropertiesFormat.IdleTimeoutInMinutes = lbIdleTimeout
|
||||||
|
}
|
||||||
|
|
||||||
|
if requiresInternalLoadBalancer(service) &&
|
||||||
|
strings.EqualFold(az.LoadBalancerSku, loadBalancerSkuStandard) &&
|
||||||
|
strings.EqualFold(service.Annotations[ServiceAnnotationLoadBalancerEnableHighAvailabilityPorts], "true") {
|
||||||
|
expectedRule.FrontendPort = to.Int32Ptr(0)
|
||||||
|
expectedRule.BackendPort = to.Int32Ptr(0)
|
||||||
|
expectedRule.Protocol = network.TransportProtocolAll
|
||||||
|
}
|
||||||
|
|
||||||
|
// we didn't construct the probe objects for UDP or SCTP because they're not allowed on Azure.
|
||||||
|
// However, when externalTrafficPolicy is Local, Kubernetes HTTP health check would be used for probing.
|
||||||
|
if servicehelpers.NeedsHealthCheck(service) || (port.Protocol != v1.ProtocolUDP && port.Protocol != v1.ProtocolSCTP) {
|
||||||
|
expectedRule.Probe = &network.SubResource{
|
||||||
|
ID: to.StringPtr(az.getLoadBalancerProbeID(lbName, az.getLoadBalancerResourceGroup(), lbRuleName)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedRules = append(expectedRules, expectedRule)
|
||||||
}
|
}
|
||||||
|
|
||||||
return expectedProbes, expectedRules, nil
|
return expectedProbes, expectedRules, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user