From f14709b4937c972482aeb410022beda25005de8b Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Wed, 23 Sep 2015 17:46:18 -0700 Subject: [PATCH] Restore deprecatedPublicIPs for compat The v1 API will retain deprecatedPublicIPs, but externalIPs is preferred. --- api/swagger-spec/v1.json | 9 +++++++- pkg/api/v1/conversion.go | 27 +++++++++++++++++++++++ pkg/api/v1/conversion_generated.go | 9 +------- pkg/api/v1/deep_copy_generated.go | 8 +++++++ pkg/api/v1/types.go | 17 +++++++++++--- pkg/api/v1/types_swagger_doc_generated.go | 17 +++++++------- 6 files changed, 67 insertions(+), 20 deletions(-) diff --git a/api/swagger-spec/v1.json b/api/swagger-spec/v1.json index ba5c56f47de..febe7056fb1 100644 --- a/api/swagger-spec/v1.json +++ b/api/swagger-spec/v1.json @@ -13818,7 +13818,14 @@ "items": { "type": "string" }, - "description": "ExternalIPs are used by external load balancers, or can be set by users to handle external traffic that arrives at a node. Externally visible IPs (e.g. load balancers) that should be proxied to this service." + "description": "externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service. These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system. A previous form of this functionality exists as the deprecatedPublicIPs field. When using this field, callers should also clear the deprecatedPublicIPs field." + }, + "deprecatedPublicIPs": { + "type": "array", + "items": { + "type": "string" + }, + "description": "deprecatedPublicIPs is deprecated and replaced by the externalIPs field with almost the exact same semantics. This field is retained in the v1 API for compatibility until at least 8/20/2016. It will be removed from any new API revisions. If both deprecatedPublicIPs *and* externalIPs are set, deprecatedPublicIPs is used." }, "sessionAffinity": { "type": "string", diff --git a/pkg/api/v1/conversion.go b/pkg/api/v1/conversion.go index d16bd818758..1e4bb1959f2 100644 --- a/pkg/api/v1/conversion.go +++ b/pkg/api/v1/conversion.go @@ -29,8 +29,10 @@ func addConversionFuncs() { err := api.Scheme.AddConversionFuncs( convert_api_PodSpec_To_v1_PodSpec, convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec, + convert_api_ServiceSpec_To_v1_ServiceSpec, convert_v1_PodSpec_To_api_PodSpec, convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec, + convert_v1_ServiceSpec_To_api_ServiceSpec, ) if err != nil { // If one of the conversion functions is malformed, detect it immediately. @@ -365,3 +367,28 @@ func convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversi } return nil } + +func convert_api_ServiceSpec_To_v1_ServiceSpec(in *api.ServiceSpec, out *ServiceSpec, s conversion.Scope) error { + if err := autoconvert_api_ServiceSpec_To_v1_ServiceSpec(in, out, s); err != nil { + return err + } + // Publish both externalIPs and deprecatedPublicIPs fields in v1. + for _, ip := range in.ExternalIPs { + out.DeprecatedPublicIPs = append(out.DeprecatedPublicIPs, ip) + } + return nil +} + +func convert_v1_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.ServiceSpec, s conversion.Scope) error { + if err := autoconvert_v1_ServiceSpec_To_api_ServiceSpec(in, out, s); err != nil { + return err + } + // Prefer the legacy deprecatedPublicIPs field, if provided. + if len(in.DeprecatedPublicIPs) > 0 { + out.ExternalIPs = nil + for _, ip := range in.DeprecatedPublicIPs { + out.ExternalIPs = append(out.ExternalIPs, ip) + } + } + return nil +} diff --git a/pkg/api/v1/conversion_generated.go b/pkg/api/v1/conversion_generated.go index 2338ffa0502..34549d564af 100644 --- a/pkg/api/v1/conversion_generated.go +++ b/pkg/api/v1/conversion_generated.go @@ -2819,10 +2819,6 @@ func autoconvert_api_ServiceSpec_To_v1_ServiceSpec(in *api.ServiceSpec, out *Ser return nil } -func convert_api_ServiceSpec_To_v1_ServiceSpec(in *api.ServiceSpec, out *ServiceSpec, s conversion.Scope) error { - return autoconvert_api_ServiceSpec_To_v1_ServiceSpec(in, out, s) -} - func autoconvert_api_ServiceStatus_To_v1_ServiceStatus(in *api.ServiceStatus, out *ServiceStatus, s conversion.Scope) error { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { defaulting.(func(*api.ServiceStatus))(in) @@ -5798,15 +5794,12 @@ func autoconvert_v1_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.Ser } else { out.ExternalIPs = nil } + // in.DeprecatedPublicIPs has no peer in out out.SessionAffinity = api.ServiceAffinity(in.SessionAffinity) out.LoadBalancerIP = in.LoadBalancerIP return nil } -func convert_v1_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.ServiceSpec, s conversion.Scope) error { - return autoconvert_v1_ServiceSpec_To_api_ServiceSpec(in, out, s) -} - func autoconvert_v1_ServiceStatus_To_api_ServiceStatus(in *ServiceStatus, out *api.ServiceStatus, s conversion.Scope) error { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { defaulting.(func(*ServiceStatus))(in) diff --git a/pkg/api/v1/deep_copy_generated.go b/pkg/api/v1/deep_copy_generated.go index 9a5226943ab..0d440d4d856 100644 --- a/pkg/api/v1/deep_copy_generated.go +++ b/pkg/api/v1/deep_copy_generated.go @@ -2098,6 +2098,14 @@ func deepCopy_v1_ServiceSpec(in ServiceSpec, out *ServiceSpec, c *conversion.Clo } else { out.ExternalIPs = nil } + if in.DeprecatedPublicIPs != nil { + out.DeprecatedPublicIPs = make([]string, len(in.DeprecatedPublicIPs)) + for i := range in.DeprecatedPublicIPs { + out.DeprecatedPublicIPs[i] = in.DeprecatedPublicIPs[i] + } + } else { + out.DeprecatedPublicIPs = nil + } out.SessionAffinity = in.SessionAffinity out.LoadBalancerIP = in.LoadBalancerIP return nil diff --git a/pkg/api/v1/types.go b/pkg/api/v1/types.go index d1f48abb7a1..b177ae78b16 100644 --- a/pkg/api/v1/types.go +++ b/pkg/api/v1/types.go @@ -1496,11 +1496,22 @@ type ServiceSpec struct { // More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#external-services Type ServiceType `json:"type,omitempty"` - // ExternalIPs are used by external load balancers, or can be set by - // users to handle external traffic that arrives at a node. - // Externally visible IPs (e.g. load balancers) that should be proxied to this service. + // externalIPs is a list of IP addresses for which nodes in the cluster + // will also accept traffic for this service. These IPs are not managed by + // Kubernetes. The user is responsible for ensuring that traffic arrives + // at a node with this IP. A common example is external load-balancers + // that are not part of the Kubernetes system. A previous form of this + // functionality exists as the deprecatedPublicIPs field. When using this + // field, callers should also clear the deprecatedPublicIPs field. ExternalIPs []string `json:"externalIPs,omitempty"` + // deprecatedPublicIPs is deprecated and replaced by the externalIPs field + // with almost the exact same semantics. This field is retained in the v1 + // API for compatibility until at least 8/20/2016. It will be removed from + // any new API revisions. If both deprecatedPublicIPs *and* externalIPs are + // set, deprecatedPublicIPs is used. + DeprecatedPublicIPs []string `json:"deprecatedPublicIPs,omitempty"` + // Supports "ClientIP" and "None". Used to maintain session affinity. // Enable client IP based session affinity. // Must be ClientIP or None. diff --git a/pkg/api/v1/types_swagger_doc_generated.go b/pkg/api/v1/types_swagger_doc_generated.go index c2bcfdd227a..92d4eeaf863 100644 --- a/pkg/api/v1/types_swagger_doc_generated.go +++ b/pkg/api/v1/types_swagger_doc_generated.go @@ -1290,14 +1290,15 @@ func (ServicePort) SwaggerDoc() map[string]string { } var map_ServiceSpec = map[string]string{ - "": "ServiceSpec describes the attributes that a user creates on a service.", - "ports": "The list of ports that are exposed by this service. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies", - "selector": "This service will route traffic to pods having labels matching this selector. Label keys and values that must match in order to receive traffic for this service. If empty, all pods are selected, if not specified, endpoints must be manually specified. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#overview", - "clusterIP": "ClusterIP is usually assigned by the master and is the IP address of the service. If specified, it will be allocated to the service if it is unused or else creation of the service will fail. Valid values are None, empty string (\"\"), or a valid IP address. 'None' can be specified for a headless service when proxying is not required. Cannot be updated. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies", - "type": "Type of exposed service. Must be ClusterIP, NodePort, or LoadBalancer. Defaults to ClusterIP. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#external-services", - "externalIPs": "ExternalIPs are used by external load balancers, or can be set by users to handle external traffic that arrives at a node. Externally visible IPs (e.g. load balancers) that should be proxied to this service.", - "sessionAffinity": "Supports \"ClientIP\" and \"None\". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies", - "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.", + "": "ServiceSpec describes the attributes that a user creates on a service.", + "ports": "The list of ports that are exposed by this service. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies", + "selector": "This service will route traffic to pods having labels matching this selector. Label keys and values that must match in order to receive traffic for this service. If empty, all pods are selected, if not specified, endpoints must be manually specified. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#overview", + "clusterIP": "ClusterIP is usually assigned by the master and is the IP address of the service. If specified, it will be allocated to the service if it is unused or else creation of the service will fail. Valid values are None, empty string (\"\"), or a valid IP address. 'None' can be specified for a headless service when proxying is not required. Cannot be updated. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies", + "type": "Type of exposed service. Must be ClusterIP, NodePort, or LoadBalancer. Defaults to ClusterIP. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#external-services", + "externalIPs": "externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service. These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system. A previous form of this functionality exists as the deprecatedPublicIPs field. When using this field, callers should also clear the deprecatedPublicIPs field.", + "deprecatedPublicIPs": "deprecatedPublicIPs is deprecated and replaced by the externalIPs field with almost the exact same semantics. This field is retained in the v1 API for compatibility until at least 8/20/2016. It will be removed from any new API revisions. If both deprecatedPublicIPs *and* externalIPs are set, deprecatedPublicIPs is used.", + "sessionAffinity": "Supports \"ClientIP\" and \"None\". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None. More info: http://releases.k8s.io/HEAD/docs/user-guide/services.md#virtual-ips-and-service-proxies", + "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.", } func (ServiceSpec) SwaggerDoc() map[string]string {