apiVersion: v1beta1
kind: ReplicationController
id: etcd-{{cell}}
desiredState:
  replicas: 3
  replicaSelector:
    name: etcd
    cell: {{cell}}
  podTemplate:
    desiredState:
      manifest:
        version: v1beta1
        id: etcd-{{cell}}
        containers:
          - name: etcd
            image: vitess/etcd:v0.4.6
            command:
              - bash
              - "-c"
              - >-
                ipaddr=$(hostname -i)

                if [ "{{cell}}" != "global" ]; then
                until curl -L
                http://$ETCD_GLOBAL_SERVICE_HOST:$ETCD_GLOBAL_SERVICE_PORT/v2/keys/vt/cells/{{cell}}
                -XPUT -d value=http://$ipaddr:4001; do
                echo "[$(date)] waiting for global etcd to register cell '{{cell}}'"; sleep 1;
                done;
                fi

                etcd -name $HOSTNAME -peer-addr $ipaddr:7001 -addr $ipaddr:4001 -discovery {{discovery}}
    labels:
      name: etcd
      cell: {{cell}}
labels:
  name: etcd
  cell: {{cell}}

apiVersion: v1beta1
kind: ReplicationController
id: etcd-{{cell}}
desiredState:
  replicas: 3
  replicaSelector:
    name: etcd
    cell: {{cell}}
  podTemplate:
    desiredState:
      manifest:
        version: v1beta1
        id: etcd-{{cell}}
        containers:
          - name: etcd
            image: vitess/etcd:v0.4.6
            command:
              - bash
              - "-c"
              - >-
                ipaddr=$(hostname -i)

                global_etcd=$ETCD_GLOBAL_SERVICE_HOST:$ETCD_GLOBAL_SERVICE_PORT

                cell="{{cell}}" &&
                local_etcd_host_var="ETCD_${cell^^}_SERVICE_HOST" &&
                local_etcd_port_var="ETCD_${cell^^}_SERVICE_PORT" &&
                local_etcd=${!local_etcd_host_var}:${!local_etcd_port_var}

                if [ "{{cell}}" != "global" ]; then
                until curl -L http://$global_etcd/v2/keys/vt/cells/{{cell}}
                -XPUT -d value=http://$local_etcd; do
                echo "[$(date)] waiting for global etcd to register cell '{{cell}}'"; sleep 1;
                done;
                fi

                etcd -name $HOSTNAME -peer-addr $ipaddr:7001 -addr $ipaddr:4001 -discovery {{discovery}}
    labels:
      name: etcd
      cell: {{cell}}
labels:
  name: etcd
  cell: {{cell}}

Use cell-local etcd service host, not each pod's IP.
Use cell-local etcd service host, not each pod's IP.
