<p>We have the following configuration for our service that's deployed to EKS but it causes downtime for about 120s whenever we make a deployment.</p>
<p>I can successfully make requests to the new pod when I port forward to it directly, so the pod itself seems fine. It seems to be either the AWS NLB that's not routing the traffic or something network related but I'm not sure, and I don't know where to debug further for this.</p>
<p>I tried a few things to no avail: added a <code>readinessProbe</code>, tried increasing the <code>initialDelaySeconds</code> to <code>120</code>, tried switching to an <code>IP</code> ELB target, rather than an <code>instance</code> ELB target type, tried reducing the NLB's health check interval but it's not actually being applied and remains as 30s.</p>
<p>Any help would be greatly appreciated!</p>
<pre><code>---
# Autoscaler for the frontend

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: my-frontend
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: my-frontend
  minReplicas: 3
  maxReplicas: 8
  targetCPUUtilizationPercentage: 60

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-frontend
  labels:
    app: my-frontend
spec:
  replicas: 3
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  selector:
    matchLabels:
      app: my-frontend
  template:
    metadata:
      labels:
        app: my-frontend
    spec:
      containers:
        - name: my-frontend
          image: ${DOCKER_IMAGE}
          ports:
            - containerPort: 3001
              name: web
          resources:
            requests:
              cpu: &quot;300m&quot;
              memory: &quot;256Mi&quot;
          livenessProbe:
            httpGet:
              scheme: HTTP
              path: /v1/ping
              port: 3001
            initialDelaySeconds: 5
            timeoutSeconds: 1
            periodSeconds: 10
          readinessProbe:
            httpGet:
              scheme: HTTP
              path: /v1/ping
              port: 3001
            initialDelaySeconds: 5
            timeoutSeconds: 1
            periodSeconds: 10
      restartPolicy: Always

---
apiVersion: v1
kind: Service
metadata:
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: nlb
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: ${SSL_CERTIFICATE_ARN}
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: &quot;https&quot;
    service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: &quot;true&quot;
    service.beta.kubernetes.io/aws-load-balancer-healthcheck-interval: &quot;10&quot;
    service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled: &quot;true&quot;
    service.beta.kubernetes.io/aws-load-balancer-connection-draining-timeout: &quot;60&quot;
  name: my-frontend
  labels:
    service: my-frontend
spec:
  ports:
    - name: http
      port: 80
      targetPort: 3001
    - name: https
      port: 443
      targetPort: 3001
  externalTrafficPolicy: Local
  selector:
    app: my-frontend
  type: LoadBalancer
</code></pre>

n00b
<p>This is most likely caused by NLB not reacting quickly enough to the target changes which is related directly to your <code>externalTrafficPolicy</code> settings.</p>
<p>If your application does not make any use of client IP you can set the <code>externalTrafficPolicy</code> to <code>ClusterIP</code> or leave it to default by removing it.</p>
<p>In case where your application requires to preserve client IP you may use the solution discussed in this <a href="https://github.com/kubernetes/kubernetes/issues/73362#issuecomment-460790924" rel="nofollow noreferrer">github issue</a> which in short requires you to use <a href="https://www.ianlewis.org/en/bluegreen-deployments-kubernetes#:%7E:text=Kubernetes%20has%20a%20really%20awesome%20built-in%20feature%20called%20Deployments.&amp;text=With%20blue/green%20deployments%20a,the%20new%20version%20%28green%29." rel="nofollow noreferrer">blue-green deployment</a>.</p>
