Kubernetes RC wait until pod is ready before scaling down

5/27/2016

I have a ruby on rails app on kubernetes.

Here's what I do

  1. kubernetes rolling-update new_file

  2. Kubernetes began to create new pods

  3. When the new pods are ready, Kubernetes kills the old pod.

However, although my new pod are in ready state, they are actually doing rails assets build/compressing. They aren't ready yet. How can I let kubernetes know that it's not ready yet?

-- Steve Ng
kubernetes

1 Answer

5/27/2016

This sounds like a prime example for a readiness probe: It tells Kubernetes to not take a pod into load balancing until a certain condition holds, often an HTTP endpoint that returns positively. Here's an example probe defined along a Deployment specification:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
spec:
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
        readinessProbe:
          httpGet:
            path: /index.html
            port: 80
          initialDelaySeconds: 30    
          timeoutSeconds: 1

See the user guide for a starter and follow-up links contained.

-- Timo Reimann
Source: StackOverflow