apiVersion: v1
kind: ReplicationController
metadata:
  name: stolon-proxy
spec:
  replicas: 1
  selector:
    name: stolon-proxy
  template:
    metadata:
      labels:
        name: stolon-proxy
        stolon-cluster: "kube-stolon"
        stolon-proxy: "true"
    spec:
      containers:
      - name: stolon-proxy
        image: nebirhos/stolon:master
        imagePullPolicy: IfNotPresent
        env:
          - name: PROXY
            value: "true"
          - name: STPROXY_CLUSTER_NAME
          # TODO(sgotti) Get cluster name from "stoloncluster" label using a downward volume api instead of duplicating the name here
            value: "kube-stolon"
          - name: STPROXY_STORE_BACKEND
            value: "etcd" # Or consul
          - name: STPROXY_STORE_ENDPOINTS
            value: "{% for srv in groups['etcd'] %}{{ hostvars[srv]['access_ip'] | default(hostvars[srv]['ip']|default(hostvars[srv]['ansible_default_ipv4']['address'])) }}:2379{% if not loop.last %},{% endif %}{% endfor %}"
            # Enable debugging
          - name: STPROXY_DEBUG
            value: "true"
        ports:
          - containerPort: 5432
        readinessProbe:
          tcpSocket:
            port: 5432
          initialDelaySeconds: 10
          timeoutSeconds: 5
