diff --git a/apis/voyager/v1beta1/annotations.go b/apis/voyager/v1beta1/annotations.go index e255a0bc0..a2e88f156 100644 --- a/apis/voyager/v1beta1/annotations.go +++ b/apis/voyager/v1beta1/annotations.go @@ -282,9 +282,6 @@ func (r Ingress) ServiceAnnotations(provider string) (map[string]string, bool) { case "aws": // ref: https://github.com/kubernetes/kubernetes/blob/release-1.5/pkg/cloudprovider/providers/aws/aws.go#L79 filteredMap["service.beta.kubernetes.io/aws-load-balancer-proxy-protocol"] = "*" - case "gce", "gke", "azure", "acs": - // ref: https://kubernetes.io/docs/tutorials/services/source-ip/#source-ip-for-services-with-typeloadbalancer - filteredMap["service.beta.kubernetes.io/external-traffic"] = "OnlyLocal" } } return filteredMap, true diff --git a/pkg/ingress/hostport.go b/pkg/ingress/hostport.go index ce2e73ea0..43b34cac2 100644 --- a/pkg/ingress/hostport.go +++ b/pkg/ingress/hostport.go @@ -538,7 +538,7 @@ func (c *hostPortController) newPods() *apps.Deployment { }, Volumes: Volumes(secrets), HostNetwork: true, - DNSPolicy: apiv1.DNSClusterFirstWithHostNet, + DNSPolicy: apiv1.DNSClusterFirstWithHostNet, }, }, }, diff --git a/pkg/ingress/loadbalancer.go b/pkg/ingress/loadbalancer.go index 038b851fb..861059485 100644 --- a/pkg/ingress/loadbalancer.go +++ b/pkg/ingress/loadbalancer.go @@ -393,6 +393,15 @@ func (c *loadBalancerController) newService() *apiv1.Service { } } + if c.Ingress.LBType() == api.LBTypeLoadBalancer && c.Ingress.KeepSourceIP() { + switch c.Opt.CloudProvider { + case "gce", "gke", "azure", "acs": + // https://github.com/appscode/voyager/issues/276 + // ref: https://kubernetes.io/docs/tutorials/services/source-ip/#source-ip-for-services-with-typeloadbalancer + svc.Spec.ExternalTrafficPolicy = apiv1.ServiceExternalTrafficPolicyTypeLocal + } + } + switch c.Opt.CloudProvider { case "gce", "gke": if ip := c.Ingress.LoadBalancerIP(); ip != nil { diff --git a/pkg/ingress/update.go b/pkg/ingress/update.go index 3f501c3a9..4ed9ebf87 100644 --- a/pkg/ingress/update.go +++ b/pkg/ingress/update.go @@ -127,6 +127,11 @@ func (c *controller) serviceRequiresUpdate(current, desired *apiv1.Service, old current.Spec.LoadBalancerSourceRanges = desired.Spec.LoadBalancerSourceRanges } + if current.Spec.ExternalTrafficPolicy != desired.Spec.ExternalTrafficPolicy { + needsUpdate = true + current.Spec.ExternalTrafficPolicy = desired.Spec.ExternalTrafficPolicy + } + return current, needsUpdate }