Support externalTrafficPolicy on the client Service #6
@@ -33,6 +33,13 @@ type ClusterServiceSpec struct {
|
|||||||
// +optional
|
// +optional
|
||||||
LoadBalancerIP string `json:"loadBalancerIP,omitempty"`
|
LoadBalancerIP string `json:"loadBalancerIP,omitempty"`
|
||||||
|
|
||||||
|
// ExternalTrafficPolicy for a LoadBalancer/NodePort Service. Local preserves
|
||||||
|
// client source IPs (required for source-IP ACLs on the DNS servers) but
|
||||||
|
// only routes to nodes running a pod. Defaults to Cluster.
|
||||||
|
// +kubebuilder:validation:Enum=Cluster;Local
|
||||||
|
// +optional
|
||||||
|
ExternalTrafficPolicy corev1.ServiceExternalTrafficPolicy `json:"externalTrafficPolicy,omitempty"`
|
||||||
|
|
||||||
// Annotations added to the client-facing Service (e.g. PureLB/MetalLB hints).
|
// Annotations added to the client-facing Service (e.g. PureLB/MetalLB hints).
|
||||||
// +optional
|
// +optional
|
||||||
Annotations map[string]string `json:"annotations,omitempty"`
|
Annotations map[string]string `json:"annotations,omitempty"`
|
||||||
|
|||||||
@@ -1094,6 +1094,15 @@ spec:
|
|||||||
description: Annotations added to the client-facing Service (e.g.
|
description: Annotations added to the client-facing Service (e.g.
|
||||||
PureLB/MetalLB hints).
|
PureLB/MetalLB hints).
|
||||||
type: object
|
type: object
|
||||||
|
externalTrafficPolicy:
|
||||||
|
description: |-
|
||||||
|
ExternalTrafficPolicy for a LoadBalancer/NodePort Service. Local preserves
|
||||||
|
client source IPs (required for source-IP ACLs on the DNS servers) but
|
||||||
|
only routes to nodes running a pod. Defaults to Cluster.
|
||||||
|
enum:
|
||||||
|
- Cluster
|
||||||
|
- Local
|
||||||
|
type: string
|
||||||
loadBalancerIP:
|
loadBalancerIP:
|
||||||
description: LoadBalancerIP requests a specific address when Type
|
description: LoadBalancerIP requests a specific address when Type
|
||||||
is LoadBalancer.
|
is LoadBalancer.
|
||||||
|
|||||||
@@ -1399,6 +1399,15 @@ spec:
|
|||||||
description: Annotations added to the client-facing Service (e.g.
|
description: Annotations added to the client-facing Service (e.g.
|
||||||
PureLB/MetalLB hints).
|
PureLB/MetalLB hints).
|
||||||
type: object
|
type: object
|
||||||
|
externalTrafficPolicy:
|
||||||
|
description: |-
|
||||||
|
ExternalTrafficPolicy for a LoadBalancer/NodePort Service. Local preserves
|
||||||
|
client source IPs (required for source-IP ACLs on the DNS servers) but
|
||||||
|
only routes to nodes running a pod. Defaults to Cluster.
|
||||||
|
enum:
|
||||||
|
- Cluster
|
||||||
|
- Local
|
||||||
|
type: string
|
||||||
loadBalancerIP:
|
loadBalancerIP:
|
||||||
description: LoadBalancerIP requests a specific address when Type
|
description: LoadBalancerIP requests a specific address when Type
|
||||||
is LoadBalancer.
|
is LoadBalancer.
|
||||||
|
|||||||
@@ -273,6 +273,10 @@ func (r *BindClusterReconciler) reconcileServices(ctx context.Context, c *bindv1
|
|||||||
LoadBalancerIP: c.Spec.Service.LoadBalancerIP,
|
LoadBalancerIP: c.Spec.Service.LoadBalancerIP,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
// externalTrafficPolicy is only valid for LoadBalancer/NodePort Services.
|
||||||
|
if svcType == corev1.ServiceTypeLoadBalancer || svcType == corev1.ServiceTypeNodePort {
|
||||||
|
client.Spec.ExternalTrafficPolicy = c.Spec.Service.ExternalTrafficPolicy
|
||||||
|
}
|
||||||
return r.upsertService(ctx, c, client)
|
return r.upsertService(ctx, c, client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ func (r *BindClusterReconciler) upsertService(ctx context.Context, c *bindv1alph
|
|||||||
existing.Spec.Selector = desired.Spec.Selector
|
existing.Spec.Selector = desired.Spec.Selector
|
||||||
existing.Spec.Type = desired.Spec.Type
|
existing.Spec.Type = desired.Spec.Type
|
||||||
existing.Spec.LoadBalancerIP = desired.Spec.LoadBalancerIP
|
existing.Spec.LoadBalancerIP = desired.Spec.LoadBalancerIP
|
||||||
|
existing.Spec.ExternalTrafficPolicy = desired.Spec.ExternalTrafficPolicy
|
||||||
if desired.Annotations != nil {
|
if desired.Annotations != nil {
|
||||||
if existing.Annotations == nil {
|
if existing.Annotations == nil {
|
||||||
existing.Annotations = map[string]string{}
|
existing.Annotations = map[string]string{}
|
||||||
|
|||||||
Reference in New Issue
Block a user