Rename 'portal IP' to 'cluster IP' most everywhere
This covers obvious transforms, but not --portal_net, $PORTAL_NET and similar.
This commit is contained in:
@@ -18,6 +18,8 @@ package api
|
||||
|
||||
// AUTO-GENERATED FUNCTIONS START HERE
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
|
||||
@@ -25,7 +27,6 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
"speter.net/go/exp/math/dec/inf"
|
||||
"time"
|
||||
)
|
||||
|
||||
func deepCopy_api_AWSElasticBlockStoreVolumeSource(in AWSElasticBlockStoreVolumeSource, out *AWSElasticBlockStoreVolumeSource, c *conversion.Cloner) error {
|
||||
@@ -1928,7 +1929,7 @@ func deepCopy_api_ServiceSpec(in ServiceSpec, out *ServiceSpec, c *conversion.Cl
|
||||
} else {
|
||||
out.Selector = nil
|
||||
}
|
||||
out.PortalIP = in.PortalIP
|
||||
out.ClusterIP = in.ClusterIP
|
||||
out.Type = in.Type
|
||||
if in.DeprecatedPublicIPs != nil {
|
||||
out.DeprecatedPublicIPs = make([]string, len(in.DeprecatedPublicIPs))
|
||||
|
@@ -99,15 +99,15 @@ func NewDeleteOptions(grace int64) *DeleteOptions {
|
||||
return &DeleteOptions{GracePeriodSeconds: &grace}
|
||||
}
|
||||
|
||||
// this function aims to check if the service portal IP is set or not
|
||||
// this function aims to check if the service's ClusterIP is set or not
|
||||
// the objective is not to perform validation here
|
||||
func IsServiceIPSet(service *Service) bool {
|
||||
return service.Spec.PortalIP != PortalIPNone && service.Spec.PortalIP != ""
|
||||
return service.Spec.ClusterIP != ClusterIPNone && service.Spec.ClusterIP != ""
|
||||
}
|
||||
|
||||
// this function aims to check if the service portal IP is requested or not
|
||||
// this function aims to check if the service's cluster IP is requested or not
|
||||
func IsServiceIPRequested(service *Service) bool {
|
||||
return service.Spec.PortalIP == ""
|
||||
return service.Spec.ClusterIP == ""
|
||||
}
|
||||
|
||||
var standardFinalizers = util.NewStringSet(
|
||||
|
@@ -77,10 +77,10 @@ func TestBeforeUpdate(t *testing.T) {
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "change portal IP",
|
||||
name: "change ClusterIP",
|
||||
tweakSvc: func(oldSvc, newSvc *api.Service) {
|
||||
oldSvc.Spec.PortalIP = "1.2.3.4"
|
||||
newSvc.Spec.PortalIP = "4.3.2.1"
|
||||
oldSvc.Spec.ClusterIP = "1.2.3.4"
|
||||
newSvc.Spec.ClusterIP = "4.3.2.1"
|
||||
},
|
||||
expectErr: true,
|
||||
},
|
||||
|
@@ -1004,9 +1004,9 @@ type ReplicationControllerList struct {
|
||||
}
|
||||
|
||||
const (
|
||||
// PortalIPNone - do not assign a portal IP
|
||||
// ClusterIPNone - do not assign a cluster IP
|
||||
// no proxying required and no environment variables should be created for pods
|
||||
PortalIPNone = "None"
|
||||
ClusterIPNone = "None"
|
||||
)
|
||||
|
||||
// ServiceList holds a list of services.
|
||||
@@ -1033,7 +1033,7 @@ type ServiceType string
|
||||
|
||||
const (
|
||||
// ServiceTypeClusterIP means a service will only be accessible inside the
|
||||
// cluster, via the portal IP.
|
||||
// cluster, via the ClusterIP.
|
||||
ServiceTypeClusterIP ServiceType = "ClusterIP"
|
||||
|
||||
// ServiceTypeNodePort means a service will be exposed on one port of
|
||||
@@ -1082,12 +1082,12 @@ type ServiceSpec struct {
|
||||
// those endpoints.
|
||||
Selector map[string]string `json:"selector"`
|
||||
|
||||
// PortalIP is usually assigned by the master. If specified by the user
|
||||
// ClusterIP is usually assigned by the master. If specified by the user
|
||||
// we will try to respect it or else fail the request. This field can
|
||||
// not be changed by updates.
|
||||
// Valid values are None, empty string (""), or a valid IP address
|
||||
// None can be specified for headless services when proxying is not required
|
||||
PortalIP string `json:"portalIP,omitempty"`
|
||||
ClusterIP string `json:"clusterIP,omitempty"`
|
||||
|
||||
// Type determines how the service will be exposed. Valid options: ClusterIP, NodePort, LoadBalancer
|
||||
Type ServiceType `json:"type,omitempty"`
|
||||
|
@@ -2116,7 +2116,7 @@ func convert_api_ServiceSpec_To_v1_ServiceSpec(in *api.ServiceSpec, out *Service
|
||||
} else {
|
||||
out.Selector = nil
|
||||
}
|
||||
out.PortalIP = in.PortalIP
|
||||
out.ClusterIP = in.ClusterIP
|
||||
out.Type = ServiceType(in.Type)
|
||||
if in.DeprecatedPublicIPs != nil {
|
||||
out.DeprecatedPublicIPs = make([]string, len(in.DeprecatedPublicIPs))
|
||||
@@ -4391,7 +4391,7 @@ func convert_v1_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.Service
|
||||
} else {
|
||||
out.Selector = nil
|
||||
}
|
||||
out.PortalIP = in.PortalIP
|
||||
out.ClusterIP = in.ClusterIP
|
||||
out.Type = api.ServiceType(in.Type)
|
||||
if in.DeprecatedPublicIPs != nil {
|
||||
out.DeprecatedPublicIPs = make([]string, len(in.DeprecatedPublicIPs))
|
||||
|
@@ -18,13 +18,14 @@ package v1
|
||||
|
||||
// AUTO-GENERATED FUNCTIONS START HERE
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
"speter.net/go/exp/math/dec/inf"
|
||||
"time"
|
||||
)
|
||||
|
||||
func deepCopy_resource_Quantity(in resource.Quantity, out *resource.Quantity, c *conversion.Cloner) error {
|
||||
@@ -1864,7 +1865,7 @@ func deepCopy_v1_ServiceSpec(in ServiceSpec, out *ServiceSpec, c *conversion.Clo
|
||||
} else {
|
||||
out.Selector = nil
|
||||
}
|
||||
out.PortalIP = in.PortalIP
|
||||
out.ClusterIP = in.ClusterIP
|
||||
out.Type = in.Type
|
||||
if in.DeprecatedPublicIPs != nil {
|
||||
out.DeprecatedPublicIPs = make([]string, len(in.DeprecatedPublicIPs))
|
||||
|
@@ -1015,7 +1015,7 @@ type ServiceType string
|
||||
|
||||
const (
|
||||
// ServiceTypeClusterIP means a service will only be accessible inside the
|
||||
// cluster, via the portal IP.
|
||||
// cluster, via the cluster IP.
|
||||
ServiceTypeClusterIP ServiceType = "ClusterIP"
|
||||
|
||||
// ServiceTypeNodePort means a service will be exposed on one port of
|
||||
@@ -1062,12 +1062,12 @@ type ServiceSpec struct {
|
||||
// This service will route traffic to pods having labels matching this selector. If null, no endpoints will be automatically created. If empty, all pods will be selected.
|
||||
Selector map[string]string `json:"selector,omitempty" description:"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"`
|
||||
|
||||
// PortalIP is usually assigned by the master. If specified by the user
|
||||
// ClusterIP is usually assigned by the master. If specified by the user
|
||||
// we will try to respect it or else fail the request. This field can
|
||||
// not be changed by updates.
|
||||
// Valid values are None, empty string (""), or a valid IP address
|
||||
// None can be specified for headless services when proxying is not required
|
||||
PortalIP string `json:"portalIP,omitempty description: IP address of the service; usually assigned by the system; if specified, it will be allocated to the service if unused, and creation of the service will fail otherwise; cannot be updated; 'None' can be specified for a headless service when proxying is not required"`
|
||||
ClusterIP string `json:"clusterIP,omitempty description: IP address of the service; usually assigned by the system; if specified, it will be allocated to the service if unused, and creation of the service will fail otherwise; cannot be updated; 'None' can be specified for a headless service when proxying is not required"`
|
||||
|
||||
// Type determines how the service will be exposed. Valid options: ClusterIP, NodePort, LoadBalancer
|
||||
Type ServiceType `json:"type,omitempty" description:"type of this service; must be ClusterIP, NodePort, or LoadBalancer; defaults to ClusterIP"`
|
||||
@@ -1120,9 +1120,9 @@ type Service struct {
|
||||
}
|
||||
|
||||
const (
|
||||
// PortalIPNone - do not assign a portal IP
|
||||
// ClusterIPNone - do not assign a cluster IP
|
||||
// no proxying required and no environment variables should be created for pods
|
||||
PortalIPNone = "None"
|
||||
ClusterIPNone = "None"
|
||||
)
|
||||
|
||||
// ServiceList holds a list of services.
|
||||
|
@@ -782,7 +782,7 @@ func addConversionFuncs() {
|
||||
return err
|
||||
}
|
||||
out.PublicIPs = in.Spec.DeprecatedPublicIPs
|
||||
out.PortalIP = in.Spec.PortalIP
|
||||
out.PortalIP = in.Spec.ClusterIP
|
||||
if err := s.Convert(&in.Spec.SessionAffinity, &out.SessionAffinity, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -834,7 +834,7 @@ func addConversionFuncs() {
|
||||
return err
|
||||
}
|
||||
out.Spec.DeprecatedPublicIPs = in.PublicIPs
|
||||
out.Spec.PortalIP = in.PortalIP
|
||||
out.Spec.ClusterIP = in.PortalIP
|
||||
if err := s.Convert(&in.SessionAffinity, &out.Spec.SessionAffinity, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -704,7 +704,7 @@ func addConversionFuncs() {
|
||||
return err
|
||||
}
|
||||
out.PublicIPs = in.Spec.DeprecatedPublicIPs
|
||||
out.PortalIP = in.Spec.PortalIP
|
||||
out.PortalIP = in.Spec.ClusterIP
|
||||
if err := s.Convert(&in.Spec.SessionAffinity, &out.SessionAffinity, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -756,7 +756,7 @@ func addConversionFuncs() {
|
||||
return err
|
||||
}
|
||||
out.Spec.DeprecatedPublicIPs = in.PublicIPs
|
||||
out.Spec.PortalIP = in.PortalIP
|
||||
out.Spec.ClusterIP = in.PortalIP
|
||||
if err := s.Convert(&in.SessionAffinity, &out.Spec.SessionAffinity, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -356,7 +356,7 @@ func convert_v1beta3_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.Se
|
||||
} else {
|
||||
out.Selector = nil
|
||||
}
|
||||
out.PortalIP = in.PortalIP
|
||||
out.ClusterIP = in.PortalIP
|
||||
|
||||
typeIn := in.Type
|
||||
if typeIn == "" {
|
||||
@@ -404,7 +404,7 @@ func convert_api_ServiceSpec_To_v1beta3_ServiceSpec(in *api.ServiceSpec, out *Se
|
||||
} else {
|
||||
out.Selector = nil
|
||||
}
|
||||
out.PortalIP = in.PortalIP
|
||||
out.PortalIP = in.ClusterIP
|
||||
|
||||
if err := s.Convert(&in.Type, &out.Type, 0); err != nil {
|
||||
return err
|
||||
|
@@ -1063,8 +1063,8 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
|
||||
}
|
||||
|
||||
if api.IsServiceIPSet(service) {
|
||||
if ip := net.ParseIP(service.Spec.PortalIP); ip == nil {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.portalIP", service.Spec.PortalIP, "portalIP should be empty, 'None', or a valid IP address"))
|
||||
if ip := net.ParseIP(service.Spec.ClusterIP); ip == nil {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.clusterIP", service.Spec.ClusterIP, "clusterIP should be empty, 'None', or a valid IP address"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1157,10 +1157,8 @@ func ValidateServiceUpdate(oldService, service *api.Service) errs.ValidationErro
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldService.ObjectMeta, &service.ObjectMeta).Prefix("metadata")...)
|
||||
|
||||
// TODO: PortalIP should be a Status field, since the system can set a value != to the user's value
|
||||
// once PortalIP is set, it cannot be unset.
|
||||
if api.IsServiceIPSet(oldService) && service.Spec.PortalIP != oldService.Spec.PortalIP {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.portalIP", service.Spec.PortalIP, "field is immutable"))
|
||||
if api.IsServiceIPSet(oldService) && service.Spec.ClusterIP != oldService.Spec.ClusterIP {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.clusterIP", service.Spec.ClusterIP, "field is immutable"))
|
||||
}
|
||||
|
||||
allErrs = append(allErrs, ValidateService(service)...)
|
||||
|
@@ -1581,9 +1581,9 @@ func TestValidateService(t *testing.T) {
|
||||
numErrs: 1,
|
||||
},
|
||||
{
|
||||
name: "invalid portal ip",
|
||||
name: "invalid cluster ip",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.PortalIP = "invalid"
|
||||
s.Spec.ClusterIP = "invalid"
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
@@ -1676,16 +1676,16 @@ func TestValidateService(t *testing.T) {
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "valid portal ip - none ",
|
||||
name: "valid cluster ip - none ",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.PortalIP = "None"
|
||||
s.Spec.ClusterIP = "None"
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "valid portal ip - empty",
|
||||
name: "valid cluster ip - empty",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.PortalIP = ""
|
||||
s.Spec.ClusterIP = ""
|
||||
s.Spec.Ports[0].TargetPort = util.NewIntOrStringFromString("http")
|
||||
},
|
||||
numErrs: 0,
|
||||
@@ -2556,18 +2556,18 @@ func TestValidateServiceUpdate(t *testing.T) {
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "change portal IP",
|
||||
name: "change cluster IP",
|
||||
tweakSvc: func(oldSvc, newSvc *api.Service) {
|
||||
oldSvc.Spec.PortalIP = "1.2.3.4"
|
||||
newSvc.Spec.PortalIP = "8.6.7.5"
|
||||
oldSvc.Spec.ClusterIP = "1.2.3.4"
|
||||
newSvc.Spec.ClusterIP = "8.6.7.5"
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
{
|
||||
name: "remove portal IP",
|
||||
name: "remove cluster IP",
|
||||
tweakSvc: func(oldSvc, newSvc *api.Service) {
|
||||
oldSvc.Spec.PortalIP = "1.2.3.4"
|
||||
newSvc.Spec.PortalIP = ""
|
||||
oldSvc.Spec.ClusterIP = "1.2.3.4"
|
||||
newSvc.Spec.ClusterIP = ""
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
|
Reference in New Issue
Block a user