<p>I have a service and pod in node.js . .consider hello world ..
exposed port : 80 on http</p>
<p>I want to seamlessly restart my service/pod</p>
<p>pod/service restart is taking a lot of time, thus there is downtime.</p>
<p>Using : kubectl delete; then recreate it with kubectl.</p>
<p>How can i avoid delay and downtime ?</p>

shrw
<p>Considering continuous deployments, your previous Pods will be terminated &amp; new Pods will be created. Therefore, downtime of service is possible.</p>
<p>To avoid this add <em>strategy</em> in your deployment spec</p>
<p>example:</p>
<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: api
spec:
  replicas: 4
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
</code></pre>
<p>where maxUnavailable: 0 defines that at any given time more than 1 pods should be available</p>
<p><strong>Extra:</strong></p>
<p>If you service takes some time to be live you can use readiness probe in spec to avoid traffic to be routed before the pods are ready .</p>
<p>example :</p>
<pre><code>readinessProbe:
  tcpSocket:
    port: 80
  initialDelaySeconds: 15
  periodSeconds: 30
</code></pre>
