Merge pull request #49850 from m1093782566/service-session-timeout

Automatic merge from submit-queue (batch tested with PRs 49850, 47782, 50595, 50730, 51341)

Paramaterize `stickyMaxAgeMinutes` for service in API

**What this PR does / why we need it**:

Currently I find `stickyMaxAgeMinutes` for a session affinity type service is hard code to 180min. There is a TODO comment, see

https://github.com/kubernetes/kubernetes/blob/master/pkg/proxy/iptables/proxier.go#L205

I think the seesion sticky max time varies from service to service and users may not aware of it since it's hard coded in all proxier.go - iptables, userspace and winuserspace.

Once we parameterize it in API, users can set/get the values for their different services.

Perhaps, we can introduce a new field `api.ClientIPAffinityConfig` in `api.ServiceSpec`.

There is an initial discussion about it in sig-network group. See,

https://groups.google.com/forum/#!topic/kubernetes-sig-network/i-LkeHrjs80

**Which issue this PR fixes**: 

fixes #49831

**Special notes for your reviewer**:

**Release note**:

```release-note
Paramaterize session affinity timeout seconds in service API for Client IP based session affinity.
```
pull/6/head
Kubernetes Submit Queue 2017-08-25 20:43:30 -07:00 committed by GitHub
commit b65f3cc8dd
29 changed files with 2675 additions and 1191 deletions

View File

@ -58320,6 +58320,16 @@
}
}
},
"io.k8s.api.core.v1.ClientIPConfig": {
"description": "ClientIPConfig represents the configurations of Client IP based session affinity.",
"properties": {
"timeoutSeconds": {
"description": "timeoutSeconds specifies the seconds of ClientIP type session sticky time. The value must be \u003e0 \u0026\u0026 \u003c=86400(for 1 day) if ServiceAffinity == \"ClientIP\". Default value is 10800(for 3 hours).",
"type": "integer",
"format": "int32"
}
}
},
"io.k8s.api.core.v1.ComponentCondition": {
"description": "Information about the condition of a component.",
"required": [
@ -62066,6 +62076,10 @@
"description": "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: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies",
"type": "string"
},
"sessionAffinityConfig": {
"description": "sessionAffinityConfig contains the configurations of session affinity.",
"$ref": "#/definitions/io.k8s.api.core.v1.SessionAffinityConfig"
},
"type": {
"description": "type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. \"ExternalName\" maps to the specified externalName. \"ClusterIP\" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object. If clusterIP is \"None\", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a stable IP. \"NodePort\" builds on ClusterIP and allocates a port on every node which routes to the clusterIP. \"LoadBalancer\" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the clusterIP. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types",
"type": "string"
@ -62081,6 +62095,15 @@
}
}
},
"io.k8s.api.core.v1.SessionAffinityConfig": {
"description": "SessionAffinityConfig represents the configurations of session affinity.",
"properties": {
"clientIP": {
"description": "clientIP contains the configurations of Client IP based session affinity.",
"$ref": "#/definitions/io.k8s.api.core.v1.ClientIPConfig"
}
}
},
"io.k8s.api.core.v1.StorageOSPersistentVolumeSource": {
"description": "Represents a StorageOS persistent volume resource.",
"properties": {

View File

@ -21907,6 +21907,10 @@
"publishNotReadyAddresses": {
"type": "boolean",
"description": "publishNotReadyAddresses, when set to true, indicates that DNS implementations must publish the notReadyAddresses of subsets for the Endpoints associated with the Service. The default value is false. The primary use case for setting this field is to use a StatefulSet's Headless Service to propagate SRV records for its Pods without respect to their readiness for purpose of peer discovery. This field will replace the service.alpha.kubernetes.io/tolerate-unready-endpoints when that annotation is deprecated and all clients have been converted to use this field."
},
"sessionAffinityConfig": {
"$ref": "v1.SessionAffinityConfig",
"description": "sessionAffinityConfig contains the configurations of session affinity."
}
}
},
@ -21941,6 +21945,27 @@
}
}
},
"v1.SessionAffinityConfig": {
"id": "v1.SessionAffinityConfig",
"description": "SessionAffinityConfig represents the configurations of session affinity.",
"properties": {
"clientIP": {
"$ref": "v1.ClientIPConfig",
"description": "clientIP contains the configurations of Client IP based session affinity."
}
}
},
"v1.ClientIPConfig": {
"id": "v1.ClientIPConfig",
"description": "ClientIPConfig represents the configurations of Client IP based session affinity.",
"properties": {
"timeoutSeconds": {
"type": "integer",
"format": "int32",
"description": "timeoutSeconds specifies the seconds of ClientIP type session sticky time. The value must be \u003e0 \u0026\u0026 \u003c=86400(for 1 day) if ServiceAffinity == \"ClientIP\". Default value is 10800(for 3 hours)."
}
}
},
"v1.ServiceStatus": {
"id": "v1.ServiceStatus",
"description": "ServiceStatus represents the current status of a service.",

View File

@ -6144,6 +6144,40 @@ Examples:<br>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_v1_sessionaffinityconfig">v1.SessionAffinityConfig</h3>
<div class="paragraph">
<p>SessionAffinityConfig represents the configurations of session affinity.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup>
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Schema</th>
<th class="tableblock halign-left valign-top">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">clientIP</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">clientIP contains the configurations of Client IP based session affinity.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_clientipconfig">v1.ClientIPConfig</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_v1_podcondition">v1.PodCondition</h3>
@ -7995,6 +8029,40 @@ Examples:<br>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_v1_clientipconfig">v1.ClientIPConfig</h3>
<div class="paragraph">
<p>ClientIPConfig represents the configurations of Client IP based session affinity.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup>
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Schema</th>
<th class="tableblock halign-left valign-top">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">timeoutSeconds</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">timeoutSeconds specifies the seconds of ClientIP type session sticky time. The value must be &gt;0 &amp;&amp; &#8656;86400(for 1 day) if ServiceAffinity == "ClientIP". Default value is 10800(for 3 hours).</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_v1_apiresource">v1.APIResource</h3>
@ -10224,6 +10292,13 @@ Examples:<br>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">sessionAffinityConfig</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">sessionAffinityConfig contains the configurations of session affinity.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_sessionaffinityconfig">v1.SessionAffinityConfig</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>

View File

@ -15,6 +15,11 @@
"name": "meteor"
},
"sessionAffinity": "ClientIP",
"sessionAffinityConfig": {
"clientIP": {
"timeoutSeconds": 90
}
},
"type": "LoadBalancer"
}
}

View File

@ -9844,6 +9844,16 @@
}
}
},
"io.k8s.api.core.v1.ClientIPConfig": {
"description": "ClientIPConfig represents the configurations of Client IP based session affinity.",
"properties": {
"timeoutSeconds": {
"description": "timeoutSeconds specifies the seconds of ClientIP type session sticky time. The value must be \u003e0 \u0026\u0026 \u003c=86400(for 1 day) if ServiceAffinity == \"ClientIP\". Default value is 10800(for 3 hours).",
"type": "integer",
"format": "int32"
}
}
},
"io.k8s.api.core.v1.ConfigMap": {
"description": "ConfigMap holds configuration data for pods to consume.",
"properties": {
@ -11874,6 +11884,10 @@
"description": "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: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies",
"type": "string"
},
"sessionAffinityConfig": {
"description": "sessionAffinityConfig contains the configurations of session affinity.",
"$ref": "#/definitions/io.k8s.api.core.v1.SessionAffinityConfig"
},
"type": {
"description": "type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. \"ExternalName\" maps to the specified externalName. \"ClusterIP\" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object. If clusterIP is \"None\", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a stable IP. \"NodePort\" builds on ClusterIP and allocates a port on every node which routes to the clusterIP. \"LoadBalancer\" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the clusterIP. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types",
"type": "string"
@ -11889,6 +11903,15 @@
}
}
},
"io.k8s.api.core.v1.SessionAffinityConfig": {
"description": "SessionAffinityConfig represents the configurations of session affinity.",
"properties": {
"clientIP": {
"description": "clientIP contains the configurations of Client IP based session affinity.",
"$ref": "#/definitions/io.k8s.api.core.v1.ClientIPConfig"
}
}
},
"io.k8s.api.core.v1.StorageOSVolumeSource": {
"description": "Represents a StorageOS persistent volume resource.",
"properties": {

View File

@ -5128,6 +5128,10 @@
"publishNotReadyAddresses": {
"type": "boolean",
"description": "publishNotReadyAddresses, when set to true, indicates that DNS implementations must publish the notReadyAddresses of subsets for the Endpoints associated with the Service. The default value is false. The primary use case for setting this field is to use a StatefulSet's Headless Service to propagate SRV records for its Pods without respect to their readiness for purpose of peer discovery. This field will replace the service.alpha.kubernetes.io/tolerate-unready-endpoints when that annotation is deprecated and all clients have been converted to use this field."
},
"sessionAffinityConfig": {
"$ref": "v1.SessionAffinityConfig",
"description": "sessionAffinityConfig contains the configurations of session affinity."
}
}
},
@ -5162,6 +5166,27 @@
}
}
},
"v1.SessionAffinityConfig": {
"id": "v1.SessionAffinityConfig",
"description": "SessionAffinityConfig represents the configurations of session affinity.",
"properties": {
"clientIP": {
"$ref": "v1.ClientIPConfig",
"description": "clientIP contains the configurations of Client IP based session affinity."
}
}
},
"v1.ClientIPConfig": {
"id": "v1.ClientIPConfig",
"description": "ClientIPConfig represents the configurations of Client IP based session affinity.",
"properties": {
"timeoutSeconds": {
"type": "integer",
"format": "int32",
"description": "timeoutSeconds specifies the seconds of ClientIP type session sticky time. The value must be \u003e0 \u0026\u0026 \u003c=86400(for 1 day) if ServiceAffinity == \"ClientIP\". Default value is 10800(for 3 hours)."
}
}
},
"v1.ServiceStatus": {
"id": "v1.ServiceStatus",
"description": "ServiceStatus represents the current status of a service.",

View File

@ -2049,6 +2049,40 @@ When an object is created, the system will populate this list with the current s
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_v1_clientipconfig">v1.ClientIPConfig</h3>
<div class="paragraph">
<p>ClientIPConfig represents the configurations of Client IP based session affinity.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup>
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Schema</th>
<th class="tableblock halign-left valign-top">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">timeoutSeconds</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">timeoutSeconds specifies the seconds of ClientIP type session sticky time. The value must be &gt;0 &amp;&amp; &#8656;86400(for 1 day) if ServiceAffinity == "ClientIP". Default value is 10800(for 3 hours).</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_v1_apiresource">v1.APIResource</h3>
@ -2233,6 +2267,13 @@ When an object is created, the system will populate this list with the current s
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">sessionAffinityConfig</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">sessionAffinityConfig contains the configurations of session affinity.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_sessionaffinityconfig">v1.SessionAffinityConfig</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
@ -2333,6 +2374,40 @@ Examples:<br>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_v1_sessionaffinityconfig">v1.SessionAffinityConfig</h3>
<div class="paragraph">
<p>SessionAffinityConfig represents the configurations of session affinity.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup>
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Schema</th>
<th class="tableblock halign-left valign-top">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">clientIP</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">clientIP contains the configurations of Client IP based session affinity.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_clientipconfig">v1.ClientIPConfig</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_any">any</h3>

View File

@ -2660,6 +2660,31 @@ const (
ServiceAffinityNone ServiceAffinity = "None"
)
const (
// DefaultClientIPServiceAffinitySeconds is the default timeout seconds
// of Client IP based session affinity - 3 hours.
DefaultClientIPServiceAffinitySeconds int32 = 10800
// MaxClientIPServiceAffinitySeconds is the max timeout seconds
// of Client IP based session affinity - 1 day.
MaxClientIPServiceAffinitySeconds int32 = 86400
)
// SessionAffinityConfig represents the configurations of session affinity.
type SessionAffinityConfig struct {
// clientIP contains the configurations of Client IP based session affinity.
// +optional
ClientIP *ClientIPConfig
}
// ClientIPConfig represents the configurations of Client IP based session affinity.
type ClientIPConfig struct {
// timeoutSeconds specifies the seconds of ClientIP type session sticky time.
// The value must be >0 && <=86400(for 1 day) if ServiceAffinity == "ClientIP".
// Default value is 10800(for 3 hours).
// +optional
TimeoutSeconds *int32
}
// Service Type string describes ingress methods for a service
type ServiceType string
@ -2787,6 +2812,10 @@ type ServiceSpec struct {
// +optional
SessionAffinity ServiceAffinity
// sessionAffinityConfig contains the configurations of session affinity.
// +optional
SessionAffinityConfig *SessionAffinityConfig
// Optional: 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."

View File

@ -62,6 +62,8 @@ func RegisterConversions(scheme *runtime.Scheme) error {
Convert_api_CephFSVolumeSource_To_v1_CephFSVolumeSource,
Convert_v1_CinderVolumeSource_To_api_CinderVolumeSource,
Convert_api_CinderVolumeSource_To_v1_CinderVolumeSource,
Convert_v1_ClientIPConfig_To_api_ClientIPConfig,
Convert_api_ClientIPConfig_To_v1_ClientIPConfig,
Convert_v1_ComponentCondition_To_api_ComponentCondition,
Convert_api_ComponentCondition_To_v1_ComponentCondition,
Convert_v1_ComponentStatus_To_api_ComponentStatus,
@ -364,6 +366,8 @@ func RegisterConversions(scheme *runtime.Scheme) error {
Convert_api_ServiceSpec_To_v1_ServiceSpec,
Convert_v1_ServiceStatus_To_api_ServiceStatus,
Convert_api_ServiceStatus_To_v1_ServiceStatus,
Convert_v1_SessionAffinityConfig_To_api_SessionAffinityConfig,
Convert_api_SessionAffinityConfig_To_v1_SessionAffinityConfig,
Convert_v1_StorageOSPersistentVolumeSource_To_api_StorageOSPersistentVolumeSource,
Convert_api_StorageOSPersistentVolumeSource_To_v1_StorageOSPersistentVolumeSource,
Convert_v1_StorageOSVolumeSource_To_api_StorageOSVolumeSource,
@ -703,6 +707,26 @@ func Convert_api_CinderVolumeSource_To_v1_CinderVolumeSource(in *api.CinderVolum
return autoConvert_api_CinderVolumeSource_To_v1_CinderVolumeSource(in, out, s)
}
func autoConvert_v1_ClientIPConfig_To_api_ClientIPConfig(in *v1.ClientIPConfig, out *api.ClientIPConfig, s conversion.Scope) error {
out.TimeoutSeconds = (*int32)(unsafe.Pointer(in.TimeoutSeconds))
return nil
}
// Convert_v1_ClientIPConfig_To_api_ClientIPConfig is an autogenerated conversion function.
func Convert_v1_ClientIPConfig_To_api_ClientIPConfig(in *v1.ClientIPConfig, out *api.ClientIPConfig, s conversion.Scope) error {
return autoConvert_v1_ClientIPConfig_To_api_ClientIPConfig(in, out, s)
}
func autoConvert_api_ClientIPConfig_To_v1_ClientIPConfig(in *api.ClientIPConfig, out *v1.ClientIPConfig, s conversion.Scope) error {
out.TimeoutSeconds = (*int32)(unsafe.Pointer(in.TimeoutSeconds))
return nil
}
// Convert_api_ClientIPConfig_To_v1_ClientIPConfig is an autogenerated conversion function.
func Convert_api_ClientIPConfig_To_v1_ClientIPConfig(in *api.ClientIPConfig, out *v1.ClientIPConfig, s conversion.Scope) error {
return autoConvert_api_ClientIPConfig_To_v1_ClientIPConfig(in, out, s)
}
func autoConvert_v1_ComponentCondition_To_api_ComponentCondition(in *v1.ComponentCondition, out *api.ComponentCondition, s conversion.Scope) error {
out.Type = api.ComponentConditionType(in.Type)
out.Status = api.ConditionStatus(in.Status)
@ -4930,6 +4954,7 @@ func autoConvert_v1_ServiceSpec_To_api_ServiceSpec(in *v1.ServiceSpec, out *api.
out.ExternalTrafficPolicy = api.ServiceExternalTrafficPolicyType(in.ExternalTrafficPolicy)
out.HealthCheckNodePort = in.HealthCheckNodePort
out.PublishNotReadyAddresses = in.PublishNotReadyAddresses
out.SessionAffinityConfig = (*api.SessionAffinityConfig)(unsafe.Pointer(in.SessionAffinityConfig))
return nil
}
@ -4947,6 +4972,7 @@ func autoConvert_api_ServiceSpec_To_v1_ServiceSpec(in *api.ServiceSpec, out *v1.
out.ExternalIPs = *(*[]string)(unsafe.Pointer(&in.ExternalIPs))
out.LoadBalancerIP = in.LoadBalancerIP
out.SessionAffinity = v1.ServiceAffinity(in.SessionAffinity)
out.SessionAffinityConfig = (*v1.SessionAffinityConfig)(unsafe.Pointer(in.SessionAffinityConfig))
out.LoadBalancerSourceRanges = *(*[]string)(unsafe.Pointer(&in.LoadBalancerSourceRanges))
out.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyType(in.ExternalTrafficPolicy)
out.HealthCheckNodePort = in.HealthCheckNodePort
@ -4983,6 +5009,26 @@ func Convert_api_ServiceStatus_To_v1_ServiceStatus(in *api.ServiceStatus, out *v
return autoConvert_api_ServiceStatus_To_v1_ServiceStatus(in, out, s)
}
func autoConvert_v1_SessionAffinityConfig_To_api_SessionAffinityConfig(in *v1.SessionAffinityConfig, out *api.SessionAffinityConfig, s conversion.Scope) error {
out.ClientIP = (*api.ClientIPConfig)(unsafe.Pointer(in.ClientIP))
return nil
}
// Convert_v1_SessionAffinityConfig_To_api_SessionAffinityConfig is an autogenerated conversion function.
func Convert_v1_SessionAffinityConfig_To_api_SessionAffinityConfig(in *v1.SessionAffinityConfig, out *api.SessionAffinityConfig, s conversion.Scope) error {
return autoConvert_v1_SessionAffinityConfig_To_api_SessionAffinityConfig(in, out, s)
}
func autoConvert_api_SessionAffinityConfig_To_v1_SessionAffinityConfig(in *api.SessionAffinityConfig, out *v1.SessionAffinityConfig, s conversion.Scope) error {
out.ClientIP = (*v1.ClientIPConfig)(unsafe.Pointer(in.ClientIP))
return nil
}
// Convert_api_SessionAffinityConfig_To_v1_SessionAffinityConfig is an autogenerated conversion function.
func Convert_api_SessionAffinityConfig_To_v1_SessionAffinityConfig(in *api.SessionAffinityConfig, out *v1.SessionAffinityConfig, s conversion.Scope) error {
return autoConvert_api_SessionAffinityConfig_To_v1_SessionAffinityConfig(in, out, s)
}
func autoConvert_v1_StorageOSPersistentVolumeSource_To_api_StorageOSPersistentVolumeSource(in *v1.StorageOSPersistentVolumeSource, out *api.StorageOSPersistentVolumeSource, s conversion.Scope) error {
out.VolumeName = in.VolumeName
out.VolumeNamespace = in.VolumeNamespace

View File

@ -19,6 +19,7 @@ package validation
import (
"encoding/json"
"fmt"
"math"
"net"
"path"
"path/filepath"
@ -28,8 +29,6 @@ import (
"github.com/golang/glog"
"math"
"k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
@ -1873,6 +1872,33 @@ func validateProbe(probe *api.Probe, fldPath *field.Path) field.ErrorList {
return allErrs
}
func validateClientIPAffinityConfig(config *api.SessionAffinityConfig, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if config == nil {
allErrs = append(allErrs, field.Required(fldPath, fmt.Sprintf("when session affinity type is %s", api.ServiceAffinityClientIP)))
return allErrs
}
if config.ClientIP == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("clientIP"), fmt.Sprintf("when session affinity type is %s", api.ServiceAffinityClientIP)))
return allErrs
}
if config.ClientIP.TimeoutSeconds == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("clientIP").Child("timeoutSeconds"), fmt.Sprintf("when session affinity type is %s", api.ServiceAffinityClientIP)))
return allErrs
}
allErrs = append(allErrs, validateAffinityTimeout(config.ClientIP.TimeoutSeconds, fldPath.Child("clientIP").Child("timeoutSeconds"))...)
return allErrs
}
func validateAffinityTimeout(timeout *int32, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if *timeout <= 0 || *timeout > api.MaxClientIPServiceAffinitySeconds {
allErrs = append(allErrs, field.Invalid(fldPath, timeout, fmt.Sprintf("must be greater than 0 and less than %d", api.MaxClientIPServiceAffinitySeconds)))
}
return allErrs
}
// AccumulateUniqueHostPorts extracts each HostPort of each Container,
// accumulating the results and returning an error if any ports conflict.
func AccumulateUniqueHostPorts(containers []api.Container, accumulator *sets.String, fldPath *field.Path) field.ErrorList {
@ -2914,6 +2940,14 @@ func ValidateService(service *api.Service) field.ErrorList {
allErrs = append(allErrs, field.NotSupported(specPath.Child("sessionAffinity"), service.Spec.SessionAffinity, supportedSessionAffinityType.List()))
}
if service.Spec.SessionAffinity == api.ServiceAffinityClientIP {
allErrs = append(allErrs, validateClientIPAffinityConfig(service.Spec.SessionAffinityConfig, specPath.Child("sessionAffinityConfig"))...)
} else if service.Spec.SessionAffinity == api.ServiceAffinityNone {
if service.Spec.SessionAffinityConfig != nil {
allErrs = append(allErrs, field.Forbidden(specPath.Child("sessionAffinityConfig"), fmt.Sprintf("must not be set when session affinity is %s", string(api.ServiceAffinityNone))))
}
}
if helper.IsServiceIPSet(service) {
if ip := net.ParseIP(service.Spec.ClusterIP); ip == nil {
allErrs = append(allErrs, field.Invalid(specPath.Child("clusterIP"), service.Spec.ClusterIP, "must be empty, 'None', or a valid IP address"))

View File

@ -6792,6 +6792,32 @@ func TestValidateService(t *testing.T) {
numErrs: 0,
},
// ESIPP section ends.
{
name: "invalid timeoutSeconds field",
tweakSvc: func(s *api.Service) {
s.Spec.Type = api.ServiceTypeClusterIP
s.Spec.SessionAffinity = api.ServiceAffinityClientIP
s.Spec.SessionAffinityConfig = &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: newInt32(-1),
},
}
},
numErrs: 1,
},
{
name: "sessionAffinityConfig can't be set when session affinity is None",
tweakSvc: func(s *api.Service) {
s.Spec.Type = api.ServiceTypeLoadBalancer
s.Spec.SessionAffinity = api.ServiceAffinityNone
s.Spec.SessionAffinityConfig = &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: newInt32(90),
},
}
},
numErrs: 1,
},
}
for _, tc := range testCases {
@ -8193,6 +8219,11 @@ func TestValidateServiceUpdate(t *testing.T) {
name: "change affinity",
tweakSvc: func(oldSvc, newSvc *api.Service) {
newSvc.Spec.SessionAffinity = "ClientIP"
newSvc.Spec.SessionAffinityConfig = &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: newInt32(90),
},
}
},
numErrs: 0,
},
@ -10314,3 +10345,62 @@ func TestValidateFlexVolumeSource(t *testing.T) {
}
}
}
func TestValidateOrSetClientIPAffinityConfig(t *testing.T) {
successCases := map[string]*api.SessionAffinityConfig{
"non-empty config, valid timeout: 1": {
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: newInt32(1),
},
},
"non-empty config, valid timeout: api.MaxClientIPServiceAffinitySeconds-1": {
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: newInt32(int(api.MaxClientIPServiceAffinitySeconds - 1)),
},
},
"non-empty config, valid timeout: api.MaxClientIPServiceAffinitySeconds": {
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: newInt32(int(api.MaxClientIPServiceAffinitySeconds)),
},
},
}
for name, test := range successCases {
if errs := validateClientIPAffinityConfig(test, field.NewPath("field")); len(errs) != 0 {
t.Errorf("case: %s, expected success: %v", name, errs)
}
}
errorCases := map[string]*api.SessionAffinityConfig{
"empty session affinity config": nil,
"empty client IP config": {
ClientIP: nil,
},
"empty timeoutSeconds": {
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: nil,
},
},
"non-empty config, invalid timeout: api.MaxClientIPServiceAffinitySeconds+1": {
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: newInt32(int(api.MaxClientIPServiceAffinitySeconds + 1)),
},
},
"non-empty config, invalid timeout: -1": {
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: newInt32(-1),
},
},
"non-empty config, invalid timeout: 0": {
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: newInt32(0),
},
},
}
for name, test := range errorCases {
if errs := validateClientIPAffinityConfig(test, field.NewPath("field")); len(errs) == 0 {
t.Errorf("case: %v, expected failures: %v", name, errs)
}
}
}

View File

@ -86,6 +86,10 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
in.(*CinderVolumeSource).DeepCopyInto(out.(*CinderVolumeSource))
return nil
}, InType: reflect.TypeOf(&CinderVolumeSource{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*ClientIPConfig).DeepCopyInto(out.(*ClientIPConfig))
return nil
}, InType: reflect.TypeOf(&ClientIPConfig{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*ComponentCondition).DeepCopyInto(out.(*ComponentCondition))
return nil
@ -690,6 +694,10 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
in.(*ServiceStatus).DeepCopyInto(out.(*ServiceStatus))
return nil
}, InType: reflect.TypeOf(&ServiceStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*SessionAffinityConfig).DeepCopyInto(out.(*SessionAffinityConfig))
return nil
}, InType: reflect.TypeOf(&SessionAffinityConfig{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*StorageOSPersistentVolumeSource).DeepCopyInto(out.(*StorageOSPersistentVolumeSource))
return nil
@ -1062,6 +1070,31 @@ func (in *CinderVolumeSource) DeepCopy() *CinderVolumeSource {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClientIPConfig) DeepCopyInto(out *ClientIPConfig) {
*out = *in
if in.TimeoutSeconds != nil {
in, out := &in.TimeoutSeconds, &out.TimeoutSeconds
if *in == nil {
*out = nil
} else {
*out = new(int32)
**out = **in
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClientIPConfig.
func (in *ClientIPConfig) DeepCopy() *ClientIPConfig {
if in == nil {
return nil
}
out := new(ClientIPConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ComponentCondition) DeepCopyInto(out *ComponentCondition) {
*out = *in
@ -5670,6 +5703,15 @@ func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) {
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.SessionAffinityConfig != nil {
in, out := &in.SessionAffinityConfig, &out.SessionAffinityConfig
if *in == nil {
*out = nil
} else {
*out = new(SessionAffinityConfig)
(*in).DeepCopyInto(*out)
}
}
if in.LoadBalancerSourceRanges != nil {
in, out := &in.LoadBalancerSourceRanges, &out.LoadBalancerSourceRanges
*out = make([]string, len(*in))
@ -5705,6 +5747,31 @@ func (in *ServiceStatus) DeepCopy() *ServiceStatus {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SessionAffinityConfig) DeepCopyInto(out *SessionAffinityConfig) {
*out = *in
if in.ClientIP != nil {
in, out := &in.ClientIP, &out.ClientIP
if *in == nil {
*out = nil
} else {
*out = new(ClientIPConfig)
(*in).DeepCopyInto(*out)
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SessionAffinityConfig.
func (in *SessionAffinityConfig) DeepCopy() *SessionAffinityConfig {
if in == nil {
return nil
}
out := new(SessionAffinityConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *StorageOSPersistentVolumeSource) DeepCopyInto(out *StorageOSPersistentVolumeSource) {
*out = *in

View File

@ -250,6 +250,7 @@ func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, ser
}
return nil
}
timeoutSeconds := api.DefaultClientIPServiceAffinitySeconds
svc := &api.Service{
ObjectMeta: metav1.ObjectMeta{
Name: serviceName,
@ -263,6 +264,11 @@ func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, ser
ClusterIP: serviceIP.String(),
SessionAffinity: api.ServiceAffinityClientIP,
Type: serviceType,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
},
}

View File

@ -546,6 +546,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
om := func(name string) metav1.ObjectMeta {
return metav1.ObjectMeta{Namespace: ns, Name: name}
}
timeoutSeconds := api.DefaultClientIPServiceAffinitySeconds
create_tests := []struct {
testName string
@ -570,7 +571,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
},
@ -625,7 +631,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
expectUpdate: &api.Service{
@ -637,7 +648,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
},
@ -658,7 +674,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
expectUpdate: &api.Service{
@ -671,7 +692,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
},
@ -691,7 +717,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
expectUpdate: &api.Service{
@ -703,7 +734,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
},
@ -723,7 +759,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
expectUpdate: &api.Service{
@ -735,7 +776,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
},
@ -755,7 +801,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
expectUpdate: &api.Service{
@ -767,7 +818,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
},
@ -787,7 +843,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
expectUpdate: &api.Service{
@ -799,7 +860,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
},
@ -819,7 +885,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeNodePort,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeNodePort,
},
},
expectUpdate: &api.Service{
@ -831,7 +902,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
},
@ -851,7 +927,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
expectUpdate: nil,
@ -910,7 +991,12 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
Selector: nil,
ClusterIP: "1.2.3.4",
SessionAffinity: api.ServiceAffinityClientIP,
Type: api.ServiceTypeClusterIP,
SessionAffinityConfig: &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
},
Type: api.ServiceTypeClusterIP,
},
},
expectUpdate: nil,

View File

@ -143,7 +143,7 @@ type serviceInfo struct {
nodePort int
loadBalancerStatus api.LoadBalancerStatus
sessionAffinityType api.ServiceAffinity
stickyMaxAgeMinutes int
stickyMaxAgeSeconds int
externalIPs []string
loadBalancerSourceRanges []string
onlyNodeLocalEndpoints bool
@ -194,6 +194,10 @@ func newServiceInfo(svcPortName proxy.ServicePortName, port *api.ServicePort, se
apiservice.RequestsOnlyLocalTraffic(service) {
onlyNodeLocalEndpoints = true
}
var stickyMaxAgeSeconds int
if service.Spec.SessionAffinity == api.ServiceAffinityClientIP {
stickyMaxAgeSeconds = int(*service.Spec.SessionAffinityConfig.ClientIP.TimeoutSeconds)
}
info := &serviceInfo{
clusterIP: net.ParseIP(service.Spec.ClusterIP),
port: int(port.Port),
@ -202,11 +206,12 @@ func newServiceInfo(svcPortName proxy.ServicePortName, port *api.ServicePort, se
// Deep-copy in case the service instance changes
loadBalancerStatus: *helper.LoadBalancerStatusDeepCopy(&service.Status.LoadBalancer),
sessionAffinityType: service.Spec.SessionAffinity,
stickyMaxAgeMinutes: 180, // TODO: paramaterize this in the API.
stickyMaxAgeSeconds: stickyMaxAgeSeconds,
externalIPs: make([]string, len(service.Spec.ExternalIPs)),
loadBalancerSourceRanges: make([]string, len(service.Spec.LoadBalancerSourceRanges)),
onlyNodeLocalEndpoints: onlyNodeLocalEndpoints,
}
copy(info.loadBalancerSourceRanges, service.Spec.LoadBalancerSourceRanges)
copy(info.externalIPs, service.Spec.ExternalIPs)
@ -1419,7 +1424,7 @@ func (proxier *Proxier) syncProxyRules() {
"-A", string(svcChain),
"-m", "comment", "--comment", svcNameString,
"-m", "recent", "--name", string(endpointChain),
"--rcheck", "--seconds", strconv.Itoa(svcInfo.stickyMaxAgeMinutes*60), "--reap",
"--rcheck", "--seconds", strconv.Itoa(svcInfo.stickyMaxAgeSeconds), "--reap",
"-j", string(endpointChain))
}
}

View File

@ -179,8 +179,8 @@ func TestGetChainLinesMultipleTables(t *testing.T) {
func newFakeServiceInfo(service proxy.ServicePortName, ip net.IP, port int, protocol api.Protocol, onlyNodeLocalEndpoints bool) *serviceInfo {
return &serviceInfo{
sessionAffinityType: api.ServiceAffinityNone, // default
stickyMaxAgeMinutes: 180, // TODO: paramaterize this in the API.
sessionAffinityType: api.ServiceAffinityNone, // default
stickyMaxAgeSeconds: int(api.DefaultClientIPServiceAffinitySeconds), // default
clusterIP: ip,
port: port,
protocol: protocol,

View File

@ -28,7 +28,7 @@ type LoadBalancer interface {
// NextEndpoint returns the endpoint to handle a request for the given
// service-port and source address.
NextEndpoint(service proxy.ServicePortName, srcAddr net.Addr, sessionAffinityReset bool) (string, error)
NewService(service proxy.ServicePortName, sessionAffinityType api.ServiceAffinity, stickyMaxAgeMinutes int) error
NewService(service proxy.ServicePortName, sessionAffinityType api.ServiceAffinity, stickyMaxAgeSeconds int) error
DeleteService(service proxy.ServicePortName)
CleanupStaleStickySessions(service proxy.ServicePortName)
ServiceHasEndpoints(service proxy.ServicePortName) bool

View File

@ -61,7 +61,7 @@ type ServiceInfo struct {
nodePort int
loadBalancerStatus api.LoadBalancerStatus
sessionAffinityType api.ServiceAffinity
stickyMaxAgeMinutes int
stickyMaxAgeSeconds int
// Deprecated, but required for back-compat (including e2e)
externalIPs []string
}
@ -378,15 +378,13 @@ func (proxier *Proxier) addServiceOnPort(service proxy.ServicePortName, protocol
return nil, err
}
si := &ServiceInfo{
Timeout: timeout,
ActiveClients: newClientCache(),
Timeout: timeout,
ActiveClients: newClientCache(),
isAliveAtomic: 1,
proxyPort: portNum,
protocol: protocol,
socket: sock,
sessionAffinityType: api.ServiceAffinityNone, // default
stickyMaxAgeMinutes: 180, // TODO: parameterize this in the API.
}
proxier.setServiceInfo(service, si)
@ -450,12 +448,17 @@ func (proxier *Proxier) mergeService(service *api.Service) sets.String {
info.loadBalancerStatus = *helper.LoadBalancerStatusDeepCopy(&service.Status.LoadBalancer)
info.nodePort = int(servicePort.NodePort)
info.sessionAffinityType = service.Spec.SessionAffinity
// Set session affinity timeout value when sessionAffinity==ClientIP
if service.Spec.SessionAffinity == api.ServiceAffinityClientIP {
info.stickyMaxAgeSeconds = int(*service.Spec.SessionAffinityConfig.ClientIP.TimeoutSeconds)
}
glog.V(4).Infof("info: %#v", info)
if err := proxier.openPortal(serviceName, info); err != nil {
glog.Errorf("Failed to open portal for %q: %v", serviceName, err)
}
proxier.loadBalancer.NewService(serviceName, info.sessionAffinityType, info.stickyMaxAgeMinutes)
proxier.loadBalancer.NewService(serviceName, info.sessionAffinityType, info.stickyMaxAgeSeconds)
}
return existingPorts

View File

@ -48,7 +48,7 @@ type affinityState struct {
type affinityPolicy struct {
affinityType api.ServiceAffinity
affinityMap map[string]*affinityState // map client IP -> affinity info
ttlMinutes int
ttlSeconds int
}
// LoadBalancerRR is a round-robin load balancer.
@ -66,11 +66,11 @@ type balancerState struct {
affinity affinityPolicy
}
func newAffinityPolicy(affinityType api.ServiceAffinity, ttlMinutes int) *affinityPolicy {
func newAffinityPolicy(affinityType api.ServiceAffinity, ttlSeconds int) *affinityPolicy {
return &affinityPolicy{
affinityType: affinityType,
affinityMap: make(map[string]*affinityState),
ttlMinutes: ttlMinutes,
ttlSeconds: ttlSeconds,
}
}
@ -81,22 +81,22 @@ func NewLoadBalancerRR() *LoadBalancerRR {
}
}
func (lb *LoadBalancerRR) NewService(svcPort proxy.ServicePortName, affinityType api.ServiceAffinity, ttlMinutes int) error {
func (lb *LoadBalancerRR) NewService(svcPort proxy.ServicePortName, affinityType api.ServiceAffinity, ttlSeconds int) error {
glog.V(4).Infof("LoadBalancerRR NewService %q", svcPort)
lb.lock.Lock()
defer lb.lock.Unlock()
lb.newServiceInternal(svcPort, affinityType, ttlMinutes)
lb.newServiceInternal(svcPort, affinityType, ttlSeconds)
return nil
}
// This assumes that lb.lock is already held.
func (lb *LoadBalancerRR) newServiceInternal(svcPort proxy.ServicePortName, affinityType api.ServiceAffinity, ttlMinutes int) *balancerState {
if ttlMinutes == 0 {
ttlMinutes = 180 //default to 3 hours if not specified. Should 0 be unlimited instead????
func (lb *LoadBalancerRR) newServiceInternal(svcPort proxy.ServicePortName, affinityType api.ServiceAffinity, ttlSeconds int) *balancerState {
if ttlSeconds == 0 {
ttlSeconds = int(api.DefaultClientIPServiceAffinitySeconds) //default to 3 hours if not specified. Should 0 be unlimited instead????
}
if _, exists := lb.services[svcPort]; !exists {
lb.services[svcPort] = &balancerState{affinity: *newAffinityPolicy(affinityType, ttlMinutes)}
lb.services[svcPort] = &balancerState{affinity: *newAffinityPolicy(affinityType, ttlSeconds)}
glog.V(4).Infof("LoadBalancerRR service %q did not exist, created", svcPort)
} else if affinityType != "" {
lb.services[svcPort].affinity.affinityType = affinityType
@ -159,7 +159,7 @@ func (lb *LoadBalancerRR) NextEndpoint(svcPort proxy.ServicePortName, srcAddr ne
}
if !sessionAffinityReset {
sessionAffinity, exists := state.affinity.affinityMap[ipaddr]
if exists && int(time.Now().Sub(sessionAffinity.lastUsed).Minutes()) < state.affinity.ttlMinutes {
if exists && int(time.Now().Sub(sessionAffinity.lastUsed).Seconds()) < state.affinity.ttlSeconds {
// Affinity wins.
endpoint := sessionAffinity.endpoint
sessionAffinity.lastUsed = time.Now()
@ -378,7 +378,7 @@ func (lb *LoadBalancerRR) CleanupStaleStickySessions(svcPort proxy.ServicePortNa
return
}
for ip, affinity := range state.affinity.affinityMap {
if int(time.Now().Sub(affinity.lastUsed).Minutes()) >= state.affinity.ttlMinutes {
if int(time.Now().Sub(affinity.lastUsed).Seconds()) >= state.affinity.ttlSeconds {
glog.V(4).Infof("Removing client %s from affinityMap for service %q", affinity.clientIP, svcPort)
delete(state.affinity.affinityMap, ip)
}

View File

@ -357,7 +357,7 @@ func TestStickyLoadBalanceWorksWithNewServiceCalledFirst(t *testing.T) {
}
// Call NewService() before OnEndpointsUpdate()
loadBalancer.NewService(service, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpoints := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Subsets: []api.EndpointSubset{
@ -421,7 +421,7 @@ func TestStickyLoadBalanceWorksWithNewServiceCalledSecond(t *testing.T) {
},
}
loadBalancer.OnEndpointsAdd(endpoints)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
client1 := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0}
client2 := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 2), Port: 0}
@ -473,7 +473,7 @@ func TestStickyLoadBalanaceWorksWithMultipleEndpointsRemoveOne(t *testing.T) {
t.Errorf("Didn't fail with non-existent service")
}
loadBalancer.NewService(service, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpointsv1 := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Subsets: []api.EndpointSubset{
@ -546,7 +546,7 @@ func TestStickyLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
t.Errorf("Didn't fail with non-existent service")
}
loadBalancer.NewService(service, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpointsv1 := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Subsets: []api.EndpointSubset{
@ -605,7 +605,7 @@ func TestStickyLoadBalanceWorksWithServiceRemoval(t *testing.T) {
if err == nil || len(endpoint) != 0 {
t.Errorf("Didn't fail with non-existent service")
}
loadBalancer.NewService(fooService, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(fooService, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpoints1 := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: fooService.Name, Namespace: fooService.Namespace},
Subsets: []api.EndpointSubset{
@ -616,7 +616,7 @@ func TestStickyLoadBalanceWorksWithServiceRemoval(t *testing.T) {
},
}
barService := proxy.ServicePortName{NamespacedName: types.NamespacedName{Namespace: "testnamespace", Name: "bar"}, Port: ""}
loadBalancer.NewService(barService, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(barService, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpoints2 := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: barService.Name, Namespace: barService.Namespace},
Subsets: []api.EndpointSubset{
@ -674,7 +674,7 @@ func TestStickyLoadBalanceWorksWithEndpointFails(t *testing.T) {
}
// Call NewService() before OnEndpointsUpdate()
loadBalancer.NewService(service, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpoints := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Subsets: []api.EndpointSubset{

View File

@ -36,7 +36,6 @@ import (
)
const allAvailableInterfaces string = ""
const stickyMaxAgeMinutes int = 180 // TODO: parameterize this in the API.
type portal struct {
ip string
@ -360,7 +359,11 @@ func (proxier *Proxier) mergeService(service *api.Service) map[ServicePortPortal
},
Port: servicePort.Name,
}
proxier.loadBalancer.NewService(servicePortName, service.Spec.SessionAffinity, stickyMaxAgeMinutes)
timeoutSeconds := 0
if service.Spec.SessionAffinity == api.ServiceAffinityClientIP {
timeoutSeconds = int(*service.Spec.SessionAffinityConfig.ClientIP.TimeoutSeconds)
}
proxier.loadBalancer.NewService(servicePortName, service.Spec.SessionAffinity, timeoutSeconds)
}
}

View File

@ -48,7 +48,7 @@ type affinityState struct {
type affinityPolicy struct {
affinityType api.ServiceAffinity
affinityMap map[string]*affinityState // map client IP -> affinity info
ttlMinutes int
ttlSeconds int
}
// LoadBalancerRR is a round-robin load balancer.
@ -66,11 +66,11 @@ type balancerState struct {
affinity affinityPolicy
}
func newAffinityPolicy(affinityType api.ServiceAffinity, ttlMinutes int) *affinityPolicy {
func newAffinityPolicy(affinityType api.ServiceAffinity, ttlSeconds int) *affinityPolicy {
return &affinityPolicy{
affinityType: affinityType,
affinityMap: make(map[string]*affinityState),
ttlMinutes: ttlMinutes,
ttlSeconds: ttlSeconds,
}
}
@ -81,22 +81,22 @@ func NewLoadBalancerRR() *LoadBalancerRR {
}
}
func (lb *LoadBalancerRR) NewService(svcPort proxy.ServicePortName, affinityType api.ServiceAffinity, ttlMinutes int) error {
func (lb *LoadBalancerRR) NewService(svcPort proxy.ServicePortName, affinityType api.ServiceAffinity, ttlSeconds int) error {
glog.V(4).Infof("LoadBalancerRR NewService %q", svcPort)
lb.lock.Lock()
defer lb.lock.Unlock()
lb.newServiceInternal(svcPort, affinityType, ttlMinutes)
lb.newServiceInternal(svcPort, affinityType, ttlSeconds)
return nil
}
// This assumes that lb.lock is already held.
func (lb *LoadBalancerRR) newServiceInternal(svcPort proxy.ServicePortName, affinityType api.ServiceAffinity, ttlMinutes int) *balancerState {
if ttlMinutes == 0 {
ttlMinutes = 180 //default to 3 hours if not specified. Should 0 be unlimited instead????
func (lb *LoadBalancerRR) newServiceInternal(svcPort proxy.ServicePortName, affinityType api.ServiceAffinity, ttlSeconds int) *balancerState {
if ttlSeconds == 0 {
ttlSeconds = int(api.DefaultClientIPServiceAffinitySeconds) //default to 3 hours if not specified. Should 0 be unlimited instead????
}
if _, exists := lb.services[svcPort]; !exists {
lb.services[svcPort] = &balancerState{affinity: *newAffinityPolicy(affinityType, ttlMinutes)}
lb.services[svcPort] = &balancerState{affinity: *newAffinityPolicy(affinityType, ttlSeconds)}
glog.V(4).Infof("LoadBalancerRR service %q did not exist, created", svcPort)
} else if affinityType != "" {
lb.services[svcPort].affinity.affinityType = affinityType
@ -149,7 +149,7 @@ func (lb *LoadBalancerRR) NextEndpoint(svcPort proxy.ServicePortName, srcAddr ne
}
if !sessionAffinityReset {
sessionAffinity, exists := state.affinity.affinityMap[ipaddr]
if exists && int(time.Now().Sub(sessionAffinity.lastUsed).Minutes()) < state.affinity.ttlMinutes {
if exists && int(time.Now().Sub(sessionAffinity.lastUsed).Seconds()) < state.affinity.ttlSeconds {
// Affinity wins.
endpoint := sessionAffinity.endpoint
sessionAffinity.lastUsed = time.Now()
@ -366,7 +366,7 @@ func (lb *LoadBalancerRR) CleanupStaleStickySessions(svcPort proxy.ServicePortNa
return
}
for ip, affinity := range state.affinity.affinityMap {
if int(time.Now().Sub(affinity.lastUsed).Minutes()) >= state.affinity.ttlMinutes {
if int(time.Now().Sub(affinity.lastUsed).Seconds()) >= state.affinity.ttlSeconds {
glog.V(4).Infof("Removing client %s from affinityMap for service %q", affinity.clientIP, svcPort)
delete(state.affinity.affinityMap, ip)
}

View File

@ -357,7 +357,7 @@ func TestStickyLoadBalanceWorksWithNewServiceCalledFirst(t *testing.T) {
}
// Call NewService() before OnEndpointsUpdate()
loadBalancer.NewService(service, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpoints := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Subsets: []api.EndpointSubset{
@ -421,7 +421,7 @@ func TestStickyLoadBalanceWorksWithNewServiceCalledSecond(t *testing.T) {
},
}
loadBalancer.OnEndpointsAdd(endpoints)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
client1 := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0}
client2 := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 2), Port: 0}
@ -473,7 +473,7 @@ func TestStickyLoadBalanaceWorksWithMultipleEndpointsRemoveOne(t *testing.T) {
t.Errorf("Didn't fail with non-existent service")
}
loadBalancer.NewService(service, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpointsv1 := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Subsets: []api.EndpointSubset{
@ -546,7 +546,7 @@ func TestStickyLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
t.Errorf("Didn't fail with non-existent service")
}
loadBalancer.NewService(service, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpointsv1 := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Subsets: []api.EndpointSubset{
@ -605,7 +605,7 @@ func TestStickyLoadBalanceWorksWithServiceRemoval(t *testing.T) {
if err == nil || len(endpoint) != 0 {
t.Errorf("Didn't fail with non-existent service")
}
loadBalancer.NewService(fooService, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(fooService, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpoints1 := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: fooService.Name, Namespace: fooService.Namespace},
Subsets: []api.EndpointSubset{
@ -616,7 +616,7 @@ func TestStickyLoadBalanceWorksWithServiceRemoval(t *testing.T) {
},
}
barService := proxy.ServicePortName{NamespacedName: types.NamespacedName{Namespace: "testnamespace", Name: "bar"}, Port: ""}
loadBalancer.NewService(barService, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(barService, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpoints2 := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: barService.Name, Namespace: barService.Namespace},
Subsets: []api.EndpointSubset{
@ -674,7 +674,7 @@ func TestStickyLoadBalanceWorksWithEndpointFails(t *testing.T) {
}
// Call NewService() before OnEndpointsUpdate()
loadBalancer.NewService(service, api.ServiceAffinityClientIP, 0)
loadBalancer.NewService(service, api.ServiceAffinityClientIP, int(api.DefaultClientIPServiceAffinitySeconds))
endpoints := &api.Endpoints{
ObjectMeta: metav1.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Subsets: []api.EndpointSubset{

File diff suppressed because it is too large Load Diff

View File

@ -269,6 +269,15 @@ message CinderVolumeSource {
optional bool readOnly = 3;
}
// ClientIPConfig represents the configurations of Client IP based session affinity.
message ClientIPConfig {
// timeoutSeconds specifies the seconds of ClientIP type session sticky time.
// The value must be >0 && <=86400(for 1 day) if ServiceAffinity == "ClientIP".
// Default value is 10800(for 3 hours).
// +optional
optional int32 timeoutSeconds = 1;
}
// Information about the condition of a component.
message ComponentCondition {
// Type of condition for a component.
@ -3864,6 +3873,10 @@ message ServiceSpec {
// field.
// +optional
optional bool publishNotReadyAddresses = 13;
// sessionAffinityConfig contains the configurations of session affinity.
// +optional
optional SessionAffinityConfig sessionAffinityConfig = 14;
}
// ServiceStatus represents the current status of a service.
@ -3874,6 +3887,13 @@ message ServiceStatus {
optional LoadBalancerStatus loadBalancer = 1;
}
// SessionAffinityConfig represents the configurations of session affinity.
message SessionAffinityConfig {
// clientIP contains the configurations of Client IP based session affinity.
// +optional
optional ClientIPConfig clientIP = 1;
}
// Represents a StorageOS persistent volume resource.
message StorageOSPersistentVolumeSource {
// VolumeName is the human-readable name of the StorageOS volume. Volume

View File

@ -44373,6 +44373,382 @@ func (x *ServiceAffinity) CodecDecodeSelf(d *codec1978.Decoder) {
}
}
func (x *SessionAffinityConfig) CodecEncodeSelf(e *codec1978.Encoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperEncoder(e)
_, _, _ = h, z, r
if x == nil {
r.EncodeNil()
} else {
yym1 := z.EncBinary()
_ = yym1
if false {
} else if z.HasExtensions() && z.EncExt(x) {
} else {
yysep2 := !z.EncBinary()
yy2arr2 := z.EncBasicHandle().StructToArray
var yyq2 [1]bool
_, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false
yyq2[0] = x.ClientIP != nil
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(1)
} else {
yynn2 = 0
for _, b := range yyq2 {
if b {
yynn2++
}
}
r.EncodeMapStart(yynn2)
yynn2 = 0
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[0] {
if x.ClientIP == nil {
r.EncodeNil()
} else {
x.ClientIP.CodecEncodeSelf(e)
}
} else {
r.EncodeNil()
}
} else {
if yyq2[0] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("clientIP"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.ClientIP == nil {
r.EncodeNil()
} else {
x.ClientIP.CodecEncodeSelf(e)
}
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
} else {
z.EncSendContainerState(codecSelfer_containerMapEnd1234)
}
}
}
}
func (x *SessionAffinityConfig) CodecDecodeSelf(d *codec1978.Decoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r
yym1 := z.DecBinary()
_ = yym1
if false {
} else if z.HasExtensions() && z.DecExt(x) {
} else {
yyct2 := r.ContainerType()
if yyct2 == codecSelferValueTypeMap1234 {
yyl2 := r.ReadMapStart()
if yyl2 == 0 {
z.DecSendContainerState(codecSelfer_containerMapEnd1234)
} else {
x.codecDecodeSelfFromMap(yyl2, d)
}
} else if yyct2 == codecSelferValueTypeArray1234 {
yyl2 := r.ReadArrayStart()
if yyl2 == 0 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
} else {
x.codecDecodeSelfFromArray(yyl2, d)
}
} else {
panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234)
}
}
}
func (x *SessionAffinityConfig) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r
var yys3Slc = z.DecScratchBuffer() // default slice to decode into
_ = yys3Slc
var yyhl3 bool = l >= 0
for yyj3 := 0; ; yyj3++ {
if yyhl3 {
if yyj3 >= l {
break
}
} else {
if r.CheckBreak() {
break
}
}
z.DecSendContainerState(codecSelfer_containerMapKey1234)
yys3Slc = r.DecodeBytes(yys3Slc, true, true)
yys3 := string(yys3Slc)
z.DecSendContainerState(codecSelfer_containerMapValue1234)
switch yys3 {
case "clientIP":
if r.TryDecodeAsNil() {
if x.ClientIP != nil {
x.ClientIP = nil
}
} else {
if x.ClientIP == nil {
x.ClientIP = new(ClientIPConfig)
}
x.ClientIP.CodecDecodeSelf(d)
}
default:
z.DecStructFieldNotFound(-1, yys3)
} // end switch yys3
} // end for yyj3
z.DecSendContainerState(codecSelfer_containerMapEnd1234)
}
func (x *SessionAffinityConfig) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r
var yyj5 int
var yyb5 bool
var yyhl5 bool = l >= 0
yyj5++
if yyhl5 {
yyb5 = yyj5 > l
} else {
yyb5 = r.CheckBreak()
}
if yyb5 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
if x.ClientIP != nil {
x.ClientIP = nil
}
} else {
if x.ClientIP == nil {
x.ClientIP = new(ClientIPConfig)
}
x.ClientIP.CodecDecodeSelf(d)
}
for {
yyj5++
if yyhl5 {
yyb5 = yyj5 > l
} else {
yyb5 = r.CheckBreak()
}
if yyb5 {
break
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
z.DecStructFieldNotFound(yyj5-1, "")
}
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
}
func (x *ClientIPConfig) CodecEncodeSelf(e *codec1978.Encoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperEncoder(e)
_, _, _ = h, z, r
if x == nil {
r.EncodeNil()
} else {
yym1 := z.EncBinary()
_ = yym1
if false {
} else if z.HasExtensions() && z.EncExt(x) {
} else {
yysep2 := !z.EncBinary()
yy2arr2 := z.EncBasicHandle().StructToArray
var yyq2 [1]bool
_, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false
yyq2[0] = x.TimeoutSeconds != nil
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(1)
} else {
yynn2 = 0
for _, b := range yyq2 {
if b {
yynn2++
}
}
r.EncodeMapStart(yynn2)
yynn2 = 0
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[0] {
if x.TimeoutSeconds == nil {
r.EncodeNil()
} else {
yy4 := *x.TimeoutSeconds
yym5 := z.EncBinary()
_ = yym5
if false {
} else {
r.EncodeInt(int64(yy4))
}
}
} else {
r.EncodeNil()
}
} else {
if yyq2[0] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("timeoutSeconds"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.TimeoutSeconds == nil {
r.EncodeNil()
} else {
yy6 := *x.TimeoutSeconds
yym7 := z.EncBinary()
_ = yym7
if false {
} else {
r.EncodeInt(int64(yy6))
}
}
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
} else {
z.EncSendContainerState(codecSelfer_containerMapEnd1234)
}
}
}
}
func (x *ClientIPConfig) CodecDecodeSelf(d *codec1978.Decoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r
yym1 := z.DecBinary()
_ = yym1
if false {
} else if z.HasExtensions() && z.DecExt(x) {
} else {
yyct2 := r.ContainerType()
if yyct2 == codecSelferValueTypeMap1234 {
yyl2 := r.ReadMapStart()
if yyl2 == 0 {
z.DecSendContainerState(codecSelfer_containerMapEnd1234)
} else {
x.codecDecodeSelfFromMap(yyl2, d)
}
} else if yyct2 == codecSelferValueTypeArray1234 {
yyl2 := r.ReadArrayStart()
if yyl2 == 0 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
} else {
x.codecDecodeSelfFromArray(yyl2, d)
}
} else {
panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234)
}
}
}
func (x *ClientIPConfig) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r
var yys3Slc = z.DecScratchBuffer() // default slice to decode into
_ = yys3Slc
var yyhl3 bool = l >= 0
for yyj3 := 0; ; yyj3++ {
if yyhl3 {
if yyj3 >= l {
break
}
} else {
if r.CheckBreak() {
break
}
}
z.DecSendContainerState(codecSelfer_containerMapKey1234)
yys3Slc = r.DecodeBytes(yys3Slc, true, true)
yys3 := string(yys3Slc)
z.DecSendContainerState(codecSelfer_containerMapValue1234)
switch yys3 {
case "timeoutSeconds":
if r.TryDecodeAsNil() {
if x.TimeoutSeconds != nil {
x.TimeoutSeconds = nil
}
} else {
if x.TimeoutSeconds == nil {
x.TimeoutSeconds = new(int32)
}
yym5 := z.DecBinary()
_ = yym5
if false {
} else {
*((*int32)(x.TimeoutSeconds)) = int32(r.DecodeInt(32))
}
}
default:
z.DecStructFieldNotFound(-1, yys3)
} // end switch yys3
} // end for yyj3
z.DecSendContainerState(codecSelfer_containerMapEnd1234)
}
func (x *ClientIPConfig) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r
var yyj6 int
var yyb6 bool
var yyhl6 bool = l >= 0
yyj6++
if yyhl6 {
yyb6 = yyj6 > l
} else {
yyb6 = r.CheckBreak()
}
if yyb6 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
if x.TimeoutSeconds != nil {
x.TimeoutSeconds = nil
}
} else {
if x.TimeoutSeconds == nil {
x.TimeoutSeconds = new(int32)
}
yym8 := z.DecBinary()
_ = yym8
if false {
} else {
*((*int32)(x.TimeoutSeconds)) = int32(r.DecodeInt(32))
}
}
for {
yyj6++
if yyhl6 {
yyb6 = yyj6 > l
} else {
yyb6 = r.CheckBreak()
}
if yyb6 {
break
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
z.DecStructFieldNotFound(yyj6-1, "")
}
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
}
func (x ServiceType) CodecEncodeSelf(e *codec1978.Encoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperEncoder(e)
@ -45032,7 +45408,7 @@ func (x *ServiceSpec) CodecEncodeSelf(e *codec1978.Encoder) {
} else {
yysep2 := !z.EncBinary()
yy2arr2 := z.EncBasicHandle().StructToArray
var yyq2 [12]bool
var yyq2 [13]bool
_, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false
yyq2[0] = len(x.Ports) != 0
@ -45047,9 +45423,10 @@ func (x *ServiceSpec) CodecEncodeSelf(e *codec1978.Encoder) {
yyq2[9] = x.ExternalTrafficPolicy != ""
yyq2[10] = x.HealthCheckNodePort != 0
yyq2[11] = x.PublishNotReadyAddresses != false
yyq2[12] = x.SessionAffinityConfig != nil
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(12)
r.EncodeArrayStart(13)
} else {
yynn2 = 0
for _, b := range yyq2 {
@ -45362,6 +45739,29 @@ func (x *ServiceSpec) CodecEncodeSelf(e *codec1978.Encoder) {
}
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[12] {
if x.SessionAffinityConfig == nil {
r.EncodeNil()
} else {
x.SessionAffinityConfig.CodecEncodeSelf(e)
}
} else {
r.EncodeNil()
}
} else {
if yyq2[12] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("sessionAffinityConfig"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.SessionAffinityConfig == nil {
r.EncodeNil()
} else {
x.SessionAffinityConfig.CodecEncodeSelf(e)
}
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
} else {
@ -45552,6 +45952,17 @@ func (x *ServiceSpec) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
*((*bool)(yyv23)) = r.DecodeBool()
}
}
case "sessionAffinityConfig":
if r.TryDecodeAsNil() {
if x.SessionAffinityConfig != nil {
x.SessionAffinityConfig = nil
}
} else {
if x.SessionAffinityConfig == nil {
x.SessionAffinityConfig = new(SessionAffinityConfig)
}
x.SessionAffinityConfig.CodecDecodeSelf(d)
}
default:
z.DecStructFieldNotFound(-1, yys3)
} // end switch yys3
@ -45563,16 +45974,16 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r
var yyj25 int
var yyb25 bool
var yyhl25 bool = l >= 0
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
var yyj26 int
var yyb26 bool
var yyhl26 bool = l >= 0
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45580,21 +45991,21 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.Ports = nil
} else {
yyv26 := &x.Ports
yym27 := z.DecBinary()
_ = yym27
yyv27 := &x.Ports
yym28 := z.DecBinary()
_ = yym28
if false {
} else {
h.decSliceServicePort((*[]ServicePort)(yyv26), d)
h.decSliceServicePort((*[]ServicePort)(yyv27), d)
}
}
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45602,21 +46013,21 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.Selector = nil
} else {
yyv28 := &x.Selector
yym29 := z.DecBinary()
_ = yym29
yyv29 := &x.Selector
yym30 := z.DecBinary()
_ = yym30
if false {
} else {
z.F.DecMapStringStringX(yyv28, false, d)
z.F.DecMapStringStringX(yyv29, false, d)
}
}
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45624,21 +46035,21 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.ClusterIP = ""
} else {
yyv30 := &x.ClusterIP
yym31 := z.DecBinary()
_ = yym31
yyv31 := &x.ClusterIP
yym32 := z.DecBinary()
_ = yym32
if false {
} else {
*((*string)(yyv30)) = r.DecodeString()
*((*string)(yyv31)) = r.DecodeString()
}
}
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45646,16 +46057,16 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.Type = ""
} else {
yyv32 := &x.Type
yyv32.CodecDecodeSelf(d)
yyv33 := &x.Type
yyv33.CodecDecodeSelf(d)
}
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45663,21 +46074,21 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.ExternalIPs = nil
} else {
yyv33 := &x.ExternalIPs
yym34 := z.DecBinary()
_ = yym34
yyv34 := &x.ExternalIPs
yym35 := z.DecBinary()
_ = yym35
if false {
} else {
z.F.DecSliceStringX(yyv33, false, d)
z.F.DecSliceStringX(yyv34, false, d)
}
}
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45685,16 +46096,16 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.SessionAffinity = ""
} else {
yyv35 := &x.SessionAffinity
yyv35.CodecDecodeSelf(d)
yyv36 := &x.SessionAffinity
yyv36.CodecDecodeSelf(d)
}
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45702,21 +46113,21 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.LoadBalancerIP = ""
} else {
yyv36 := &x.LoadBalancerIP
yym37 := z.DecBinary()
_ = yym37
yyv37 := &x.LoadBalancerIP
yym38 := z.DecBinary()
_ = yym38
if false {
} else {
*((*string)(yyv36)) = r.DecodeString()
*((*string)(yyv37)) = r.DecodeString()
}
}
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45724,21 +46135,21 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.LoadBalancerSourceRanges = nil
} else {
yyv38 := &x.LoadBalancerSourceRanges
yym39 := z.DecBinary()
_ = yym39
yyv39 := &x.LoadBalancerSourceRanges
yym40 := z.DecBinary()
_ = yym40
if false {
} else {
z.F.DecSliceStringX(yyv38, false, d)
z.F.DecSliceStringX(yyv39, false, d)
}
}
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45746,21 +46157,21 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.ExternalName = ""
} else {
yyv40 := &x.ExternalName
yym41 := z.DecBinary()
_ = yym41
yyv41 := &x.ExternalName
yym42 := z.DecBinary()
_ = yym42
if false {
} else {
*((*string)(yyv40)) = r.DecodeString()
*((*string)(yyv41)) = r.DecodeString()
}
}
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45768,16 +46179,16 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.ExternalTrafficPolicy = ""
} else {
yyv42 := &x.ExternalTrafficPolicy
yyv42.CodecDecodeSelf(d)
yyv43 := &x.ExternalTrafficPolicy
yyv43.CodecDecodeSelf(d)
}
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45785,21 +46196,21 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.HealthCheckNodePort = 0
} else {
yyv43 := &x.HealthCheckNodePort
yym44 := z.DecBinary()
_ = yym44
yyv44 := &x.HealthCheckNodePort
yym45 := z.DecBinary()
_ = yym45
if false {
} else {
*((*int32)(yyv43)) = int32(r.DecodeInt(32))
*((*int32)(yyv44)) = int32(r.DecodeInt(32))
}
}
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb25 = r.CheckBreak()
yyb26 = r.CheckBreak()
}
if yyb25 {
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@ -45807,26 +46218,47 @@ func (x *ServiceSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() {
x.PublishNotReadyAddresses = false
} else {
yyv45 := &x.PublishNotReadyAddresses
yym46 := z.DecBinary()
_ = yym46
yyv46 := &x.PublishNotReadyAddresses
yym47 := z.DecBinary()
_ = yym47
if false {
} else {
*((*bool)(yyv45)) = r.DecodeBool()
*((*bool)(yyv46)) = r.DecodeBool()
}
}
for {
yyj25++
if yyhl25 {
yyb25 = yyj25 > l
} else {
yyb25 = r.CheckBreak()
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb26 = r.CheckBreak()
}
if yyb26 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
if x.SessionAffinityConfig != nil {
x.SessionAffinityConfig = nil
}
if yyb25 {
} else {
if x.SessionAffinityConfig == nil {
x.SessionAffinityConfig = new(SessionAffinityConfig)
}
x.SessionAffinityConfig.CodecDecodeSelf(d)
}
for {
yyj26++
if yyhl26 {
yyb26 = yyj26 > l
} else {
yyb26 = r.CheckBreak()
}
if yyb26 {
break
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
z.DecStructFieldNotFound(yyj25-1, "")
z.DecStructFieldNotFound(yyj26-1, "")
}
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
}
@ -74751,7 +75183,7 @@ func (x codecSelfer1234) decSliceService(v *[]Service, d *codec1978.Decoder) {
yyrg1 := len(yyv1) > 0
yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 472)
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 480)
if yyrt1 {
if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1]

View File

@ -2998,6 +2998,22 @@ const (
ServiceAffinityNone ServiceAffinity = "None"
)
// SessionAffinityConfig represents the configurations of session affinity.
type SessionAffinityConfig struct {
// clientIP contains the configurations of Client IP based session affinity.
// +optional
ClientIP *ClientIPConfig `json:"clientIP,omitempty" protobuf:"bytes,1,opt,name=clientIP"`
}
// ClientIPConfig represents the configurations of Client IP based session affinity.
type ClientIPConfig struct {
// timeoutSeconds specifies the seconds of ClientIP type session sticky time.
// The value must be >0 && <=86400(for 1 day) if ServiceAffinity == "ClientIP".
// Default value is 10800(for 3 hours).
// +optional
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty" protobuf:"varint,1,opt,name=timeoutSeconds"`
}
// Service Type string describes ingress methods for a service
type ServiceType string
@ -3172,6 +3188,9 @@ type ServiceSpec struct {
// field.
// +optional
PublishNotReadyAddresses bool `json:"publishNotReadyAddresses,omitempty" protobuf:"varint,13,opt,name=publishNotReadyAddresses"`
// sessionAffinityConfig contains the configurations of session affinity.
// +optional
SessionAffinityConfig *SessionAffinityConfig `json:"sessionAffinityConfig,omitempty" protobuf:"bytes,14,opt,name=sessionAffinityConfig"`
}
// ServicePort contains information on service's port.

View File

@ -165,6 +165,15 @@ func (CinderVolumeSource) SwaggerDoc() map[string]string {
return map_CinderVolumeSource
}
var map_ClientIPConfig = map[string]string{
"": "ClientIPConfig represents the configurations of Client IP based session affinity.",
"timeoutSeconds": "timeoutSeconds specifies the seconds of ClientIP type session sticky time. The value must be >0 && <=86400(for 1 day) if ServiceAffinity == \"ClientIP\". Default value is 10800(for 3 hours).",
}
func (ClientIPConfig) SwaggerDoc() map[string]string {
return map_ClientIPConfig
}
var map_ComponentCondition = map[string]string{
"": "Information about the condition of a component.",
"type": "Type of condition for a component. Valid value: \"Healthy\"",
@ -1903,6 +1912,7 @@ var map_ServiceSpec = map[string]string{
"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.",
"publishNotReadyAddresses": "publishNotReadyAddresses, when set to true, indicates that DNS implementations must publish the notReadyAddresses of subsets for the Endpoints associated with the Service. The default value is false. The primary use case for setting this field is to use a StatefulSet's Headless Service to propagate SRV records for its Pods without respect to their readiness for purpose of peer discovery. This field will replace the service.alpha.kubernetes.io/tolerate-unready-endpoints when that annotation is deprecated and all clients have been converted to use this field.",
"sessionAffinityConfig": "sessionAffinityConfig contains the configurations of session affinity.",
}
func (ServiceSpec) SwaggerDoc() map[string]string {
@ -1918,6 +1928,15 @@ func (ServiceStatus) SwaggerDoc() map[string]string {
return map_ServiceStatus
}
var map_SessionAffinityConfig = map[string]string{
"": "SessionAffinityConfig represents the configurations of session affinity.",
"clientIP": "clientIP contains the configurations of Client IP based session affinity.",
}
func (SessionAffinityConfig) SwaggerDoc() map[string]string {
return map_SessionAffinityConfig
}
var map_StorageOSPersistentVolumeSource = map[string]string{
"": "Represents a StorageOS persistent volume resource.",
"volumeName": "VolumeName is the human-readable name of the StorageOS volume. Volume names are only unique within a namespace.",

View File

@ -86,6 +86,10 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
in.(*CinderVolumeSource).DeepCopyInto(out.(*CinderVolumeSource))
return nil
}, InType: reflect.TypeOf(&CinderVolumeSource{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*ClientIPConfig).DeepCopyInto(out.(*ClientIPConfig))
return nil
}, InType: reflect.TypeOf(&ClientIPConfig{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*ComponentCondition).DeepCopyInto(out.(*ComponentCondition))
return nil
@ -690,6 +694,10 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
in.(*ServiceStatus).DeepCopyInto(out.(*ServiceStatus))
return nil
}, InType: reflect.TypeOf(&ServiceStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*SessionAffinityConfig).DeepCopyInto(out.(*SessionAffinityConfig))
return nil
}, InType: reflect.TypeOf(&SessionAffinityConfig{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*StorageOSPersistentVolumeSource).DeepCopyInto(out.(*StorageOSPersistentVolumeSource))
return nil
@ -1062,6 +1070,31 @@ func (in *CinderVolumeSource) DeepCopy() *CinderVolumeSource {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClientIPConfig) DeepCopyInto(out *ClientIPConfig) {
*out = *in
if in.TimeoutSeconds != nil {
in, out := &in.TimeoutSeconds, &out.TimeoutSeconds
if *in == nil {
*out = nil
} else {
*out = new(int32)
**out = **in
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClientIPConfig.
func (in *ClientIPConfig) DeepCopy() *ClientIPConfig {
if in == nil {
return nil
}
out := new(ClientIPConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ComponentCondition) DeepCopyInto(out *ComponentCondition) {
*out = *in
@ -5677,6 +5710,15 @@ func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) {
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.SessionAffinityConfig != nil {
in, out := &in.SessionAffinityConfig, &out.SessionAffinityConfig
if *in == nil {
*out = nil
} else {
*out = new(SessionAffinityConfig)
(*in).DeepCopyInto(*out)
}
}
return
}
@ -5707,6 +5749,31 @@ func (in *ServiceStatus) DeepCopy() *ServiceStatus {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SessionAffinityConfig) DeepCopyInto(out *SessionAffinityConfig) {
*out = *in
if in.ClientIP != nil {
in, out := &in.ClientIP, &out.ClientIP
if *in == nil {
*out = nil
} else {
*out = new(ClientIPConfig)
(*in).DeepCopyInto(*out)
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SessionAffinityConfig.
func (in *SessionAffinityConfig) DeepCopy() *SessionAffinityConfig {
if in == nil {
return nil
}
out := new(SessionAffinityConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *StorageOSPersistentVolumeSource) DeepCopyInto(out *StorageOSPersistentVolumeSource) {
*out = *in