Merge pull request #46716 from thockin/proxy-comments
Kube-proxy cleanups
This commit is contained in:
@@ -120,7 +120,7 @@ func SetDefaults_Service(obj *Service) {
|
||||
} else if (obj.Spec.Type == ServiceTypeNodePort ||
|
||||
obj.Spec.Type == ServiceTypeLoadBalancer) &&
|
||||
obj.Spec.ExternalTrafficPolicy == "" {
|
||||
obj.Spec.ExternalTrafficPolicy = ServiceExternalTrafficPolicyTypeGlobal
|
||||
obj.Spec.ExternalTrafficPolicy = ServiceExternalTrafficPolicyTypeCluster
|
||||
}
|
||||
}
|
||||
func SetDefaults_Pod(obj *Pod) {
|
||||
|
@@ -885,15 +885,15 @@ func TestSetDefaulServiceExternalTraffic(t *testing.T) {
|
||||
in = &v1.Service{Spec: v1.ServiceSpec{Type: v1.ServiceTypeNodePort}}
|
||||
obj = roundTrip(t, runtime.Object(in))
|
||||
out = obj.(*v1.Service)
|
||||
if out.Spec.ExternalTrafficPolicy != v1.ServiceExternalTrafficPolicyTypeGlobal {
|
||||
t.Errorf("Expected ExternalTrafficPolicy to be %v, got %v", v1.ServiceExternalTrafficPolicyTypeGlobal, out.Spec.ExternalTrafficPolicy)
|
||||
if out.Spec.ExternalTrafficPolicy != v1.ServiceExternalTrafficPolicyTypeCluster {
|
||||
t.Errorf("Expected ExternalTrafficPolicy to be %v, got %v", v1.ServiceExternalTrafficPolicyTypeCluster, out.Spec.ExternalTrafficPolicy)
|
||||
}
|
||||
|
||||
in = &v1.Service{Spec: v1.ServiceSpec{Type: v1.ServiceTypeLoadBalancer}}
|
||||
obj = roundTrip(t, runtime.Object(in))
|
||||
out = obj.(*v1.Service)
|
||||
if out.Spec.ExternalTrafficPolicy != v1.ServiceExternalTrafficPolicyTypeGlobal {
|
||||
t.Errorf("Expected ExternalTrafficPolicy to be %v, got %v", v1.ServiceExternalTrafficPolicyTypeGlobal, out.Spec.ExternalTrafficPolicy)
|
||||
if out.Spec.ExternalTrafficPolicy != v1.ServiceExternalTrafficPolicyTypeCluster {
|
||||
t.Errorf("Expected ExternalTrafficPolicy to be %v, got %v", v1.ServiceExternalTrafficPolicyTypeCluster, out.Spec.ExternalTrafficPolicy)
|
||||
}
|
||||
|
||||
in = &v1.Service{
|
||||
|
@@ -3734,9 +3734,12 @@ message ServiceSpec {
|
||||
// +optional
|
||||
optional string externalName = 10;
|
||||
|
||||
// externalTrafficPolicy denotes if this Service desires to route external traffic to
|
||||
// local endpoints only. This preserves Source IP and avoids a second hop for
|
||||
// LoadBalancer and Nodeport type services.
|
||||
// externalTrafficPolicy denotes if this Service desires to route external
|
||||
// traffic to node-local or cluster-wide endpoints. "Local" preserves the
|
||||
// client source IP and avoids a second hop for LoadBalancer and Nodeport
|
||||
// type services, but risks potentially imbalanced traffic spreading.
|
||||
// "Cluster" obscures the client source IP and may cause a second hop to
|
||||
// another node, but should have good overall load-spreading.
|
||||
// +optional
|
||||
optional string externalTrafficPolicy = 11;
|
||||
|
||||
|
@@ -157,7 +157,7 @@ func TestRequestsOnlyLocalTraffic(t *testing.T) {
|
||||
checkRequestsOnlyLocalTraffic(false, &v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeNodePort,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeGlobal,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeCluster,
|
||||
},
|
||||
})
|
||||
checkRequestsOnlyLocalTraffic(true, &v1.Service{
|
||||
@@ -169,7 +169,7 @@ func TestRequestsOnlyLocalTraffic(t *testing.T) {
|
||||
checkRequestsOnlyLocalTraffic(false, &v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeLoadBalancer,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeGlobal,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeCluster,
|
||||
},
|
||||
})
|
||||
checkRequestsOnlyLocalTraffic(true, &v1.Service{
|
||||
@@ -197,7 +197,7 @@ func TestNeedsHealthCheck(t *testing.T) {
|
||||
checkNeedsHealthCheck(false, &v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeNodePort,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeGlobal,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeCluster,
|
||||
},
|
||||
})
|
||||
checkNeedsHealthCheck(false, &v1.Service{
|
||||
@@ -209,7 +209,7 @@ func TestNeedsHealthCheck(t *testing.T) {
|
||||
checkNeedsHealthCheck(false, &v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeLoadBalancer,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeGlobal,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeCluster,
|
||||
},
|
||||
})
|
||||
checkNeedsHealthCheck(true, &v1.Service{
|
||||
@@ -268,13 +268,13 @@ func TestGetServiceHealthCheckNodePort(t *testing.T) {
|
||||
checkGetServiceHealthCheckNodePort(0, &v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeNodePort,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeGlobal,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeCluster,
|
||||
},
|
||||
})
|
||||
checkGetServiceHealthCheckNodePort(0, &v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeLoadBalancer,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeGlobal,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeCluster,
|
||||
},
|
||||
})
|
||||
checkGetServiceHealthCheckNodePort(34567, &v1.Service{
|
||||
@@ -306,7 +306,7 @@ func TestClearExternalTrafficPolicy(t *testing.T) {
|
||||
&v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeClusterIP,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeGlobal,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeCluster,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -346,7 +346,7 @@ func TestSetServiceHealthCheckNodePort(t *testing.T) {
|
||||
&v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeClusterIP,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeGlobal,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeCluster,
|
||||
},
|
||||
},
|
||||
30012,
|
||||
@@ -356,7 +356,7 @@ func TestSetServiceHealthCheckNodePort(t *testing.T) {
|
||||
&v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeClusterIP,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeGlobal,
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeCluster,
|
||||
},
|
||||
},
|
||||
0,
|
||||
|
@@ -2842,10 +2842,10 @@ const (
|
||||
type ServiceExternalTrafficPolicyType string
|
||||
|
||||
const (
|
||||
// ServiceExternalTrafficPolicyTypeLocal specifies local endpoints behavior.
|
||||
// ServiceExternalTrafficPolicyTypeLocal specifies node-local endpoints behavior.
|
||||
ServiceExternalTrafficPolicyTypeLocal ServiceExternalTrafficPolicyType = "Local"
|
||||
// ServiceExternalTrafficPolicyTypeGlobal specifies global (legacy) behavior.
|
||||
ServiceExternalTrafficPolicyTypeGlobal ServiceExternalTrafficPolicyType = "Global"
|
||||
// ServiceExternalTrafficPolicyTypeCluster specifies node-global (legacy) behavior.
|
||||
ServiceExternalTrafficPolicyTypeCluster ServiceExternalTrafficPolicyType = "Cluster"
|
||||
)
|
||||
|
||||
// ServiceStatus represents the current status of a service.
|
||||
@@ -2961,9 +2961,12 @@ type ServiceSpec struct {
|
||||
// +optional
|
||||
ExternalName string `json:"externalName,omitempty" protobuf:"bytes,10,opt,name=externalName"`
|
||||
|
||||
// externalTrafficPolicy denotes if this Service desires to route external traffic to
|
||||
// local endpoints only. This preserves Source IP and avoids a second hop for
|
||||
// LoadBalancer and Nodeport type services.
|
||||
// externalTrafficPolicy denotes if this Service desires to route external
|
||||
// traffic to node-local or cluster-wide endpoints. "Local" preserves the
|
||||
// client source IP and avoids a second hop for LoadBalancer and Nodeport
|
||||
// type services, but risks potentially imbalanced traffic spreading.
|
||||
// "Cluster" obscures the client source IP and may cause a second hop to
|
||||
// another node, but should have good overall load-spreading.
|
||||
// +optional
|
||||
ExternalTrafficPolicy ServiceExternalTrafficPolicyType `json:"externalTrafficPolicy,omitempty" protobuf:"bytes,11,opt,name=externalTrafficPolicy"`
|
||||
|
||||
|
@@ -1858,7 +1858,7 @@ var map_ServiceSpec = map[string]string{
|
||||
"loadBalancerIP": "Only applies to Service Type: LoadBalancer LoadBalancer will get created with the IP specified in this field. This feature depends on whether the underlying cloud-provider supports specifying the loadBalancerIP when a load balancer is created. This field will be ignored if the cloud-provider does not support the feature.",
|
||||
"loadBalancerSourceRanges": "If specified and supported by the platform, this will restrict traffic through the cloud-provider load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support the feature.\" More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/",
|
||||
"externalName": "externalName is the external reference that kubedns or equivalent will return as a CNAME record for this service. No proxying will be involved. Must be a valid DNS name and requires Type to be ExternalName.",
|
||||
"externalTrafficPolicy": "externalTrafficPolicy denotes if this Service desires to route external traffic to local endpoints only. This preserves Source IP and avoids a second hop for LoadBalancer and Nodeport type services.",
|
||||
"externalTrafficPolicy": "externalTrafficPolicy denotes if this Service desires to route external traffic to node-local or cluster-wide endpoints. \"Local\" preserves the client source IP and avoids a second hop for LoadBalancer and Nodeport type services, but risks potentially imbalanced traffic spreading. \"Cluster\" obscures the client source IP and may cause a second hop to another node, but should have good overall load-spreading.",
|
||||
"healthCheckNodePort": "healthCheckNodePort specifies the healthcheck nodePort for the service. If not specified, HealthCheckNodePort is created by the service api backend with the allocated nodePort. Will use user-specified nodePort value if specified by the client. Only effects when Type is set to LoadBalancer and ExternalTrafficPolicy is set to Local.",
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user