// 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// +optional
SessionAffinity ServiceAffinity `json:"sessionAffinity,omitempty" protobuf:"bytes,7,opt,name=sessionAffinity,casttype=ServiceAffinity"`
代碼段 ClientIP 基於客戶端地址來實現 None不做回話保持
// Session Affinity Type stringtype ServiceAffinity stringconst(// ServiceAffinityClientIP is the Client IP based.
ServiceAffinityClientIP ServiceAffinity ="ClientIP"// ServiceAffinityNone - no session affinity.
ServiceAffinityNone ServiceAffinity ="None")
# 可選項 配置了基於ClientIP 會話保持
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"`}
##配置回話保持時間 範圍(0秒 ~ 1天),默認是保持3個小時
// 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"`}