diff --git a/pkg/api/service/annotations.go b/pkg/api/service/annotations.go index d6ccaeba32a..c347854367e 100644 --- a/pkg/api/service/annotations.go +++ b/pkg/api/service/annotations.go @@ -26,25 +26,19 @@ const ( // Not all cloud providers support this annotation, though AWS & GCE do. AnnotationLoadBalancerSourceRangesKey = "service.beta.kubernetes.io/load-balancer-source-ranges" - // AnnotationValueExternalTrafficLocal Value of annotation to specify local endpoints behaviour + // AnnotationValueExternalTrafficLocal Value of annotation to specify local endpoints behavior. AnnotationValueExternalTrafficLocal = "OnlyLocal" - // AnnotationValueExternalTrafficGlobal Value of annotation to specify global (legacy) behaviour + // AnnotationValueExternalTrafficGlobal Value of annotation to specify global (legacy) behavior. AnnotationValueExternalTrafficGlobal = "Global" - // TODO: The alpha annotations have been deprecated, remove them when we move this feature to GA. + // TODO: The beta annotations have been deprecated, remove them when we release k8s 1.8. - // AlphaAnnotationHealthCheckNodePort Annotation specifying the healthcheck nodePort for the service - // If not specified, annotation is created by the service api backend with the allocated nodePort - // Will use user-specified nodePort value if specified by the client - AlphaAnnotationHealthCheckNodePort = "service.alpha.kubernetes.io/healthcheck-nodeport" - - // AlphaAnnotationExternalTraffic An annotation that denotes if this Service desires to route external traffic to local - // endpoints only. This preserves Source IP and avoids a second hop. - AlphaAnnotationExternalTraffic = "service.alpha.kubernetes.io/external-traffic" - - // BetaAnnotationHealthCheckNodePort is the beta version of AlphaAnnotationHealthCheckNodePort. + // BetaAnnotationHealthCheckNodePort Annotation specifying the healthcheck nodePort for the service. + // If not specified, annotation is created by the service api backend with the allocated nodePort. + // Will use user-specified nodePort value if specified by the client. BetaAnnotationHealthCheckNodePort = "service.beta.kubernetes.io/healthcheck-nodeport" - // BetaAnnotationExternalTraffic is the beta version of AlphaAnnotationExternalTraffic. + // BetaAnnotationExternalTraffic An annotation that denotes if this Service desires to route + // external traffic to local endpoints only. This preserves Source IP and avoids a second hop. BetaAnnotationExternalTraffic = "service.beta.kubernetes.io/external-traffic" ) diff --git a/pkg/api/types.go b/pkg/api/types.go index 9d0ab25f521..2345673da3d 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -2453,6 +2453,16 @@ const ( ServiceTypeExternalName ServiceType = "ExternalName" ) +// Service External Traffic Policy Type string +type ServiceExternalTrafficPolicyType string + +const ( + // ServiceExternalTrafficPolicyTypeLocal specifies local endpoints behavior. + ServiceExternalTrafficPolicyTypeLocal ServiceExternalTrafficPolicyType = "Local" + // ServiceExternalTrafficPolicyTypeGlobal specifies global (legacy) behavior. + ServiceExternalTrafficPolicyTypeGlobal ServiceExternalTrafficPolicyType = "Global" +) + // ServiceStatus represents the current status of a service type ServiceStatus struct { // LoadBalancer contains the current status of the load-balancer, @@ -2552,6 +2562,20 @@ type ServiceSpec struct { // cloud-provider does not support the feature." // +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. + // +optional + ExternalTrafficPolicy ServiceExternalTrafficPolicyType + + // 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. + // +optional + HealthCheckNodePort int32 } type ServicePort struct { diff --git a/pkg/api/v1/service/annotations.go b/pkg/api/v1/service/annotations.go index d6ccaeba32a..c347854367e 100644 --- a/pkg/api/v1/service/annotations.go +++ b/pkg/api/v1/service/annotations.go @@ -26,25 +26,19 @@ const ( // Not all cloud providers support this annotation, though AWS & GCE do. AnnotationLoadBalancerSourceRangesKey = "service.beta.kubernetes.io/load-balancer-source-ranges" - // AnnotationValueExternalTrafficLocal Value of annotation to specify local endpoints behaviour + // AnnotationValueExternalTrafficLocal Value of annotation to specify local endpoints behavior. AnnotationValueExternalTrafficLocal = "OnlyLocal" - // AnnotationValueExternalTrafficGlobal Value of annotation to specify global (legacy) behaviour + // AnnotationValueExternalTrafficGlobal Value of annotation to specify global (legacy) behavior. AnnotationValueExternalTrafficGlobal = "Global" - // TODO: The alpha annotations have been deprecated, remove them when we move this feature to GA. + // TODO: The beta annotations have been deprecated, remove them when we release k8s 1.8. - // AlphaAnnotationHealthCheckNodePort Annotation specifying the healthcheck nodePort for the service - // If not specified, annotation is created by the service api backend with the allocated nodePort - // Will use user-specified nodePort value if specified by the client - AlphaAnnotationHealthCheckNodePort = "service.alpha.kubernetes.io/healthcheck-nodeport" - - // AlphaAnnotationExternalTraffic An annotation that denotes if this Service desires to route external traffic to local - // endpoints only. This preserves Source IP and avoids a second hop. - AlphaAnnotationExternalTraffic = "service.alpha.kubernetes.io/external-traffic" - - // BetaAnnotationHealthCheckNodePort is the beta version of AlphaAnnotationHealthCheckNodePort. + // BetaAnnotationHealthCheckNodePort Annotation specifying the healthcheck nodePort for the service. + // If not specified, annotation is created by the service api backend with the allocated nodePort. + // Will use user-specified nodePort value if specified by the client. BetaAnnotationHealthCheckNodePort = "service.beta.kubernetes.io/healthcheck-nodeport" - // BetaAnnotationExternalTraffic is the beta version of AlphaAnnotationExternalTraffic. + // BetaAnnotationExternalTraffic An annotation that denotes if this Service desires to route + // external traffic to local endpoints only. This preserves Source IP and avoids a second hop. BetaAnnotationExternalTraffic = "service.beta.kubernetes.io/external-traffic" ) diff --git a/pkg/api/v1/types.go b/pkg/api/v1/types.go index 945079129c5..db730965988 100644 --- a/pkg/api/v1/types.go +++ b/pkg/api/v1/types.go @@ -2792,6 +2792,16 @@ const ( ServiceTypeExternalName ServiceType = "ExternalName" ) +// Service External Traffic Policy Type string +type ServiceExternalTrafficPolicyType string + +const ( + // ServiceExternalTrafficPolicyTypeLocal specifies local endpoints behavior. + ServiceExternalTrafficPolicyTypeLocal ServiceExternalTrafficPolicyType = "Local" + // ServiceExternalTrafficPolicyTypeGlobal specifies global (legacy) behavior. + ServiceExternalTrafficPolicyTypeGlobal ServiceExternalTrafficPolicyType = "Global" +) + // ServiceStatus represents the current status of a service. type ServiceStatus struct { // LoadBalancer contains the current status of the load-balancer, @@ -2904,6 +2914,20 @@ type ServiceSpec struct { // Must be a valid DNS name and requires Type to be ExternalName. // +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. + // +optional + ExternalTrafficPolicy ServiceExternalTrafficPolicyType `json:"externalTrafficPolicy,omitempty" protobuf:"bytes,11,opt,name=externalTrafficPolicy"` + + // 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. + // +optional + HealthCheckNodePort int32 `json:"healthCheckNodePort,omitempty" protobuf:"bytes,12,opt,name=healthCheckNodePort"` } // ServicePort contains information on service's port. diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index 2827af44424..44ca87f1842 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -98,7 +98,7 @@ func init() { // To add a new feature, define a key for it above and add it here. The features will be // available throughout Kubernetes binaries. var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureSpec{ - ExternalTrafficLocalOnly: {Default: true, PreRelease: utilfeature.Beta}, + ExternalTrafficLocalOnly: {Default: true, PreRelease: utilfeature.GA}, AppArmor: {Default: true, PreRelease: utilfeature.Beta}, DynamicKubeletConfig: {Default: false, PreRelease: utilfeature.Alpha}, DynamicVolumeProvisioning: {Default: true, PreRelease: utilfeature.Alpha},