# Copyright 2017 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ReplicationController
metadata:
  name: influxdb-grafana
  labels:
    k8s-app: influx-grafana
    kubernetes.io/minikube-addons: heapster
    addonmanager.kubernetes.io/mode: Reconcile
  namespace: kube-system
spec:
  replicas: 1
  selector:
    k8s-app: influx-grafana
    addonmanager.kubernetes.io/mode: Reconcile
  template:
    metadata:
      labels:
        k8s-app: influx-grafana
        addonmanager.kubernetes.io/mode: Reconcile
    spec:
      containers:
      - name: influxdb
        image: k8s.gcr.io/heapster-influxdb-amd64:v1.3.3
        imagePullPolicy: IfNotPresent
        ports:
        - name: http
          containerPort: 8083
        - name: api
          containerPort: 8086
        volumeMounts:
        - mountPath: /data
          name: influxdb-storage
      - name: grafana
        image: k8s.gcr.io/heapster-grafana-amd64:v4.4.3
        imagePullPolicy: IfNotPresent
        env:
          - name: INFLUXDB_SERVICE_URL
            value: http://localhost:8086
            # The following env variables are required to make Grafana accessible via
            # the kubernetes api-server proxy. On production clusters, we recommend
            # removing these env variables, setup auth for grafana, and expose the grafana
            # service using a LoadBalancer or a public IP.
          - 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: /
        ports:
        - name: ui
          containerPort: 3000
        volumeMounts:
        - mountPath: /var
          name: grafana-storage
      volumes:
      - name: influxdb-storage
        emptyDir: {}
      - name: grafana-storage
        emptyDir: {}
