<p>We are running a workload against a cluster hosting 2 instances of a small (3 container) pod.  Accessing the pod using a service w/nodeport.  If we stop a pod and rc starts a new one, our constant (low volume) workload has numerous failures (Rational Perf Tester, http test hitting the service on the master ... but likely same if it were hitting either minion ... master also has a minion).  Anyway, if we just add a pod with kubectl scale, we also get errors.  If we then take down this a pod (rc doesn't start a new one because we had one more than needed due to scale) ... no errors.  Seems that service starts sending work to new pod because kubelet has done his thing, even though containers are not up.  Thus, any time a pod is started ... it starts receiving work a little too soon (after kubelet did his work, but before all containers are ready).  Is there a way to guarantee that the service will not route to this pod until all containers are up?  Barring that is there some way to say wait 'n' seconds before sending to this pod?  I may be wrong, but behavior seems to suggest this scenario.</p>

<p>This is precisely what the <code>readinessProbe</code> option is :)</p>

<p>It's documented more <a href="http://kubernetes.io/v1.0/docs/user-guide/pod-states.html#container-probes" rel="nofollow">here</a> and <a href="http://kubernetes.io/v1.0/docs/user-guide/production-pods.html#liveness-and-readiness-probes-aka-health-checks" rel="nofollow">here</a>, and is part of the <a href="http://kubernetes.io/v1.0/docs/api-reference/definitions.html#_v1_container" rel="nofollow"><code>container</code> definition</a> in a pod specification.</p>

<p>For example, you might use a pod specification like the one below to ensure that your nginx pod won't be marked as ready (and thus won't have traffic sent to it) until it responds to an HTTP request for <code>/index.html</code>:</p>

<pre><code>apiVersion: v1
kind: ReplicationController
metadata:
  name: my-nginx
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
        lifecycle:
          httpGet:
            path: /index.html
            port: 80
          initialDelaySeconds: 10
          timeoutSeconds: 5
</code></pre>
