apiVersion: v1
kind: Service
metadata:
  labels:
    name: etcd-torus
  name: etcd-torus
spec:
  type: NodePort
  ports:
    - port: 2379
      name: etcd-client
      targetPort: etcd-client
      nodePort: 32379
  selector:
    name: etcd-torus
---
apiVersion: v1
kind: Service
metadata:
  labels:
    name: etcd-torus-internal
  name: etcd-torus-internal
spec:
  clusterIP: 10.3.0.100
  ports:
    - port: 2379
      name: etcd-client
      targetPort: etcd-client
  selector:
    name: etcd-torus
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    name: etcd-torus
  name: etcd-torus
spec:
  containers:
  - image: quay.io/coreos/etcd:v3.0.0-beta.0
    name: etcd-torus
    ports:
    - name: etcd-peers
      containerPort: 2380
    - name: etcd-client
      containerPort: 2379
    volumeMounts:
    - name: data
      mountPath: /var/lib/etcd
    env:
    - name: POD_IP
      valueFrom:
        fieldRef:
          fieldPath: status.podIP
    - name: ETCD_DATA_DIR
      value: /var/lib/etcd
    - name: ETCD_NAME
      value: etcd
    - name: ETCD_INITIAL_CLUSTER
      value: etcd=http://$(POD_IP):2380
    - name: ETCD_INITIAL_ADVERTISE_PEER_URLS
      value: http://$(POD_IP):2380
    - name: ETCD_ADVERTISE_CLIENT_URLS
      value: http://$(POD_IP):2379
    - name: ETCD_LISTEN_CLIENT_URLS
      value: http://0.0.0.0:2379
    - name: ETCD_LISTEN_PEER_URLS
      value: http://$(POD_IP):2380
  volumes:
    - name: data
      emptyDir: {}
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: torus
  labels:
    app: torus
spec:
  template:
    metadata:
      name: torus
      labels:
        daemon: torus
    spec:
      containers:
      - name: torus
        image: quay.io/coreos/torus:latest
        ports:
        - name: peer
          containerPort: 40000
        - name: http
          containerPort: 4321
        env:
        - name: ETCD_HOST
          value: $(ETCD_TORUS_SERVICE_HOST)
        - name: STORAGE_SIZE
          value: 2GiB
        - name: LISTEN_HOST
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: AUTO_JOIN
          value: "1"
        - name: DEBUG_INIT
          value: "1"
        - name: DROP_MOUNT_BIN
          value: "0"
        volumeMounts:
        - name: data
          mountPath: /data
          readOnly: false
      volumes:
        - name: data
          hostPath:
            path: /srv/torus
      imagePullSecrets:
        - name: quay-torus
