apiVersion: v1
kind: ReplicationController
metadata:
  name: influx-grafana
spec:
  replicas: 1
  template:
    metadata:
      name: influxGrafana
      labels:
        name: influxGrafana
    spec:
      containers:
      - name: influx
        image: tutum/influxdb
        ports:
        - containerPort: 8086
        - containerPort: 8083
        volumeMounts:
        - name: influx-storage
          mountPath: /data
        resources:
          # keep request = limit to keep this container in guaranteed class
          limits:
            cpu: 100m
            memory: 500Mi
          requests:
            cpu: 100m
            memory: 500Mi
      - name: grafana
        image: gcr.io/google_containers/heapster_grafana:v2.6.0-2
        resources:
          # keep request = limit to keep this container in guaranteed class
          limits:
            cpu: 100m
            memory: 100Mi
          requests:
            cpu: 100m
            memory: 100Mi
        env:
          - name: INFLUXDB_SERVICE_URL
            value: http://influx:8086
          - name: GF_AUTH_BASIC_ENABLED
            value: "false"
          - name: GF_AUTH_ANONYMOUS_ENABLED
            value: "true"
          - name: GF_AUTH_ANONYMOUS_ORG_ROLE
            value: Admin
          - name: GF_SERVER_ROOT_URL
            value: /api/v1/proxy/namespaces/default/services/grafana/
          # So, VERY HELPFULLY, K8s will set GRAFANA_PORT if a "grafana" service exists.
          # SMARTLY, gcr.io/google_containers/heapster_grafana uses GRAFANA_PORT to set the port.
          # So yeah. Took me a while to figure out why it was listening to http://0.0.0.0:tcp://10.7.243.177:80/
          - name: GRAFANA_PORT
            value: "3000"
        volumeMounts:
        - mountPath: /var/lib/grafana
          name: grafana-storage
      volumes:
        - name: grafana-storage
          gcePersistentDisk:
            pdName: grafana-storage
            fsType: ext4
        - name: influx-storage
          gcePersistentDisk:
            pdName: influx-storage
            fsType: ext4
