<p>I am using a ReplicationController to create a pod running redis container.</p>

<p>The redis container is monitored by Redis Sentinel.  And there is a problem, if redis crashed and restart too fast, it may cause trouble to Redis Sentinel when the voting is in progress. </p>

<pre><code>{
  "apiVersion": "v1",
  "kind": "ReplicationController",
  "metadata": {
    "name": "redis",
    "labels": { "name" : "redis" }
  },
  "spec": {  
    "replicas": 1,
    "selector": {
      "name":"redis"
    },
    "template": { 
      "metadata": {
        "labels": {
          "name":"redis"
        }
      },
      "spec": { 
        "volumes": [
            //...
        ],
        "containers": [
          //...
        ],
        "restartPolicy": "Always"
      }
    }
  }
}
</code></pre>

<p>Would it be possible to delay the restart ? i.e.  Restart the container after 60 seconds from last crash</p>

<p>Better alternatives to <code>sleep</code>:</p>
<ol>
<li><code>terminationGracePeriodSeconds</code>:</li>
</ol>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
    name: test
spec:
    replicas: 1
    template:
        spec:
            containers:
              - name: test
                image: ...
            terminationGracePeriodSeconds: 60
</code></pre>
<ol start="2">
<li><a href="https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/#define-poststart-and-prestop-handlers" rel="nofollow noreferrer">preStop handler</a>, read more about <a href="https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks" rel="nofollow noreferrer">lifecycle hooks</a></li>
</ol>
<p>Read also: <a href="https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-terminating-with-grace" rel="nofollow noreferrer">Kubernetes best practices: terminating with grace</a></p>
