From bf9b15475ad67b9fa9d5c8c4f4c966bef1b45601 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Wed, 31 May 2017 11:35:24 -0700 Subject: [PATCH] 'Global' -> 'Cluster' for traffic policy Kubernetes-commit: fc34a9d6ba4679298abc2d371b86eb32354f0c7b --- pkg/api/types.go | 15 +++++++++------ pkg/api/v1/defaults.go | 2 +- pkg/api/v1/generated.proto | 9 ++++++--- pkg/api/v1/types.go | 15 +++++++++------ pkg/api/v1/types_swagger_doc_generated.go | 2 +- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/pkg/api/types.go b/pkg/api/types.go index 6f42fb145..df22d01b5 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -2504,10 +2504,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 cluster-wide (legacy) behavior. + ServiceExternalTrafficPolicyTypeCluster ServiceExternalTrafficPolicyType = "Cluster" ) // ServiceStatus represents the current status of a service @@ -2610,9 +2610,12 @@ type ServiceSpec struct { // +optional LoadBalancerSourceRanges []string - // 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 diff --git a/pkg/api/v1/defaults.go b/pkg/api/v1/defaults.go index 19c6f6f56..a791ba7b5 100644 --- a/pkg/api/v1/defaults.go +++ b/pkg/api/v1/defaults.go @@ -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) { diff --git a/pkg/api/v1/generated.proto b/pkg/api/v1/generated.proto index a84f642d1..7f1b196f6 100644 --- a/pkg/api/v1/generated.proto +++ b/pkg/api/v1/generated.proto @@ -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; diff --git a/pkg/api/v1/types.go b/pkg/api/v1/types.go index 44c87a791..06aae75b2 100644 --- a/pkg/api/v1/types.go +++ b/pkg/api/v1/types.go @@ -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"` diff --git a/pkg/api/v1/types_swagger_doc_generated.go b/pkg/api/v1/types_swagger_doc_generated.go index 7b2a45024..b5ab0eb65 100644 --- a/pkg/api/v1/types_swagger_doc_generated.go +++ b/pkg/api/v1/types_swagger_doc_generated.go @@ -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.", }