Merge pull request #38278 from hodovska/external-name-no-ports

Automatic merge from submit-queue

API v1: do not require ports for all types of services

Ports values had to be specified for all types of services but object with service type "ExternalName" does't define ports. That's why we had to remove required condition.
Presence of ports in service types where ports are actually required is verified here: 
https://github.com/kubernetes/kubernetes/blob/master/pkg/api/validation/validation.go#L2439

For more information about ExternalName services see:
http://kubernetes.io/docs/user-guide/services/#services-without-selectors

Fixes https://github.com/kubernetes/kubernetes/issues/34394
This commit is contained in:
Kubernetes Submit Queue
2016-12-08 23:43:14 -08:00
committed by GitHub
7 changed files with 28 additions and 31 deletions

View File

@@ -33967,6 +33967,7 @@ func (x *ServiceSpec) CodecEncodeSelf(e *codec1978.Encoder) {
var yyq2588 [10]bool
_, _, _ = yysep2588, yyq2588, yy2arr2588
const yyr2588 bool = false
yyq2588[0] = len(x.Ports) != 0
yyq2588[1] = len(x.Selector) != 0
yyq2588[2] = x.ClusterIP != ""
yyq2588[3] = x.Type != ""
@@ -33980,7 +33981,7 @@ func (x *ServiceSpec) CodecEncodeSelf(e *codec1978.Encoder) {
if yyr2588 || yy2arr2588 {
r.EncodeArrayStart(10)
} else {
yynn2588 = 1
yynn2588 = 0
for _, b := range yyq2588 {
if b {
yynn2588++
@@ -33991,28 +33992,34 @@ func (x *ServiceSpec) CodecEncodeSelf(e *codec1978.Encoder) {
}
if yyr2588 || yy2arr2588 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if x.Ports == nil {
r.EncodeNil()
} else {
yym2590 := z.EncBinary()
_ = yym2590
if false {
if yyq2588[0] {
if x.Ports == nil {
r.EncodeNil()
} else {
h.encSliceServicePort(([]ServicePort)(x.Ports), e)
yym2590 := z.EncBinary()
_ = yym2590
if false {
} else {
h.encSliceServicePort(([]ServicePort)(x.Ports), e)
}
}
} else {
r.EncodeNil()
}
} else {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("ports"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Ports == nil {
r.EncodeNil()
} else {
yym2591 := z.EncBinary()
_ = yym2591
if false {
if yyq2588[0] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("ports"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Ports == nil {
r.EncodeNil()
} else {
h.encSliceServicePort(([]ServicePort)(x.Ports), e)
yym2591 := z.EncBinary()
_ = yym2591
if false {
} else {
h.encSliceServicePort(([]ServicePort)(x.Ports), e)
}
}
}
}

View File

@@ -2491,7 +2491,7 @@ type LoadBalancerIngress struct {
type ServiceSpec struct {
// The list of ports that are exposed by this service.
// More info: http://kubernetes.io/docs/user-guide/services#virtual-ips-and-service-proxies
Ports []ServicePort `json:"ports" patchStrategy:"merge" patchMergeKey:"port" protobuf:"bytes,1,rep,name=ports"`
Ports []ServicePort `json:"ports,omitempty" patchStrategy:"merge" patchMergeKey:"port" protobuf:"bytes,1,rep,name=ports"`
// Route service traffic to pods with label keys and values matching this
// selector. If empty or not present, the service is assumed to have an