mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
kube-proxy: internal renames
This commit is contained in:
parent
699aeb735f
commit
99330d407a
@ -115,11 +115,11 @@ const sysctlBridgeCallIPTables = "net/bridge/bridge-nf-call-iptables"
|
|||||||
type serviceInfo struct {
|
type serviceInfo struct {
|
||||||
*proxy.BaseServiceInfo
|
*proxy.BaseServiceInfo
|
||||||
// The following fields are computed and stored for performance reasons.
|
// The following fields are computed and stored for performance reasons.
|
||||||
serviceNameString string
|
nameString string
|
||||||
servicePortChainName utiliptables.Chain
|
policyClusterChainName utiliptables.Chain
|
||||||
serviceLocalChainName utiliptables.Chain
|
policyLocalChainName utiliptables.Chain
|
||||||
serviceFirewallChainName utiliptables.Chain
|
firewallChainName utiliptables.Chain
|
||||||
serviceLBChainName utiliptables.Chain
|
xlbChainName utiliptables.Chain
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns a new proxy.ServicePort which abstracts a serviceInfo
|
// returns a new proxy.ServicePort which abstracts a serviceInfo
|
||||||
@ -130,11 +130,11 @@ func newServiceInfo(port *v1.ServicePort, service *v1.Service, baseInfo *proxy.B
|
|||||||
svcName := types.NamespacedName{Namespace: service.Namespace, Name: service.Name}
|
svcName := types.NamespacedName{Namespace: service.Namespace, Name: service.Name}
|
||||||
svcPortName := proxy.ServicePortName{NamespacedName: svcName, Port: port.Name}
|
svcPortName := proxy.ServicePortName{NamespacedName: svcName, Port: port.Name}
|
||||||
protocol := strings.ToLower(string(info.Protocol()))
|
protocol := strings.ToLower(string(info.Protocol()))
|
||||||
info.serviceNameString = svcPortName.String()
|
info.nameString = svcPortName.String()
|
||||||
info.servicePortChainName = servicePortChainName(info.serviceNameString, protocol)
|
info.policyClusterChainName = servicePortPolicyClusterChain(info.nameString, protocol)
|
||||||
info.serviceLocalChainName = serviceLocalChainName(info.serviceNameString, protocol)
|
info.policyLocalChainName = servicePortPolicyLocalChainName(info.nameString, protocol)
|
||||||
info.serviceFirewallChainName = serviceFirewallChainName(info.serviceNameString, protocol)
|
info.firewallChainName = serviceFirewallChainName(info.nameString, protocol)
|
||||||
info.serviceLBChainName = serviceLBChainName(info.serviceNameString, protocol)
|
info.xlbChainName = serviceLBChainName(info.nameString, protocol)
|
||||||
|
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
@ -684,25 +684,25 @@ func portProtoHash(servicePortName string, protocol string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
servicePortChainNamePrefix = "KUBE-SVC-"
|
servicePortPolicyClusterChainNamePrefix = "KUBE-SVC-"
|
||||||
serviceLocalChainNamePrefix = "KUBE-SVL-"
|
servicePortPolicyLocalChainNamePrefix = "KUBE-SVL-"
|
||||||
serviceFirewallChainNamePrefix = "KUBE-FW-"
|
serviceFirewallChainNamePrefix = "KUBE-FW-"
|
||||||
serviceLBChainNamePrefix = "KUBE-XLB-"
|
serviceLBChainNamePrefix = "KUBE-XLB-"
|
||||||
servicePortEndpointChainNamePrefix = "KUBE-SEP-"
|
servicePortEndpointChainNamePrefix = "KUBE-SEP-"
|
||||||
)
|
)
|
||||||
|
|
||||||
// servicePortChainName returns the name of the KUBE-SVC-XXXX chain for a service, which is the
|
// servicePortPolicyClusterChain returns the name of the KUBE-SVC-XXXX chain for a service, which is the
|
||||||
// main iptables chain for that service, used for dispatching to endpoints when using `Cluster`
|
// main iptables chain for that service, used for dispatching to endpoints when using `Cluster`
|
||||||
// traffic policy.
|
// traffic policy.
|
||||||
func servicePortChainName(servicePortName string, protocol string) utiliptables.Chain {
|
func servicePortPolicyClusterChain(servicePortName string, protocol string) utiliptables.Chain {
|
||||||
return utiliptables.Chain(servicePortChainNamePrefix + portProtoHash(servicePortName, protocol))
|
return utiliptables.Chain(servicePortPolicyClusterChainNamePrefix + portProtoHash(servicePortName, protocol))
|
||||||
}
|
}
|
||||||
|
|
||||||
// serviceLocalChainName returns the name of the KUBE-SVL-XXXX chain for a service, which
|
// servicePortPolicyLocalChainName returns the name of the KUBE-SVL-XXXX chain for a service, which
|
||||||
// handles dispatching to local endpoints when using `Local` traffic policy. This chain only
|
// handles dispatching to local endpoints when using `Local` traffic policy. This chain only
|
||||||
// exists if the service has `Local` internal or external traffic policy.
|
// exists if the service has `Local` internal or external traffic policy.
|
||||||
func serviceLocalChainName(servicePortName string, protocol string) utiliptables.Chain {
|
func servicePortPolicyLocalChainName(servicePortName string, protocol string) utiliptables.Chain {
|
||||||
return utiliptables.Chain(serviceLocalChainNamePrefix + portProtoHash(servicePortName, protocol))
|
return utiliptables.Chain(servicePortPolicyLocalChainNamePrefix + portProtoHash(servicePortName, protocol))
|
||||||
}
|
}
|
||||||
|
|
||||||
// serviceFirewallChainName returns the name of the KUBE-FW-XXXX chain for a service, which
|
// serviceFirewallChainName returns the name of the KUBE-FW-XXXX chain for a service, which
|
||||||
@ -729,8 +729,8 @@ func servicePortEndpointChainName(servicePortName string, protocol string, endpo
|
|||||||
|
|
||||||
func isServiceChainName(chainString string) bool {
|
func isServiceChainName(chainString string) bool {
|
||||||
prefixes := []string{
|
prefixes := []string{
|
||||||
servicePortChainNamePrefix,
|
servicePortPolicyClusterChainNamePrefix,
|
||||||
serviceLocalChainNamePrefix,
|
servicePortPolicyLocalChainNamePrefix,
|
||||||
servicePortEndpointChainNamePrefix,
|
servicePortEndpointChainNamePrefix,
|
||||||
serviceFirewallChainNamePrefix,
|
serviceFirewallChainNamePrefix,
|
||||||
serviceLBChainNamePrefix,
|
serviceLBChainNamePrefix,
|
||||||
@ -998,7 +998,7 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
}
|
}
|
||||||
isIPv6 := netutils.IsIPv6(svcInfo.ClusterIP())
|
isIPv6 := netutils.IsIPv6(svcInfo.ClusterIP())
|
||||||
protocol := strings.ToLower(string(svcInfo.Protocol()))
|
protocol := strings.ToLower(string(svcInfo.Protocol()))
|
||||||
svcNameString := svcInfo.serviceNameString
|
svcNameString := svcInfo.nameString
|
||||||
|
|
||||||
allEndpoints := proxier.endpointsMap[svcName]
|
allEndpoints := proxier.endpointsMap[svcName]
|
||||||
|
|
||||||
@ -1042,9 +1042,9 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
proxier.natRules.Write(args)
|
proxier.natRules.Write(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
policyClusterChain := svcInfo.servicePortChainName
|
policyClusterChain := svcInfo.policyClusterChainName
|
||||||
policyLocalChain := svcInfo.serviceLocalChainName
|
policyLocalChain := svcInfo.policyLocalChainName
|
||||||
svcXlbChain := svcInfo.serviceLBChainName
|
svcXlbChain := svcInfo.xlbChainName
|
||||||
|
|
||||||
internalTrafficChain := policyClusterChain
|
internalTrafficChain := policyClusterChain
|
||||||
externalTrafficChain := policyClusterChain
|
externalTrafficChain := policyClusterChain
|
||||||
@ -1208,7 +1208,7 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Capture load-balancer ingress.
|
// Capture load-balancer ingress.
|
||||||
fwChain := svcInfo.serviceFirewallChainName
|
fwChain := svcInfo.firewallChainName
|
||||||
for _, ingress := range svcInfo.LoadBalancerIPStrings() {
|
for _, ingress := range svcInfo.LoadBalancerIPStrings() {
|
||||||
if hasEndpoints {
|
if hasEndpoints {
|
||||||
// create service firewall chain
|
// create service firewall chain
|
||||||
|
Loading…
Reference in New Issue
Block a user