apiVersion: apps/v1
kind: Deployment
metadata:
  name: alameda-grafana
  namespace: federatorai
  labels:
    app: alameda
    component: alameda-grafana
  annotations:
    description: Defines how to deploy the application grafana
    template.alpha.openshift.io/wait-for-ready: 'true'
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
        component: alameda-grafana
  template:
    metadata:
      labels:
        app: alameda
        component: alameda-grafana
    spec:
      initContainers:
      - name: gettoken
        image: "alpine"
        command: ["sh","/shell/gettoken.sh"]
        volumeMounts:
        - mountPath: /shell
          name: get-token-shell
        - mountPath: /datasources
          name: datasources
        - mountPath: /etc/grafana/provisioning/datasources
          name: prometheus-datasource
      containers:
      - name: grafana
        image: grafana/grafana:5.4.3
        imagePullPolicy: IfNotPresent
        ports:
          - containerPort: 3000
            name: http
            protocol: TCP
        resources:
          limits:
            cpu: 200m
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
          - mountPath: /var/lib/grafana/dashboards/alameda
            name: dashboards-json
          - mountPath: /etc/grafana/provisioning/datasources
            name: prometheus-datasource
          - mountPath: /etc/grafana/provisioning/dashboards
            name: dashboardproviders
      volumes:
        - name: prometheus-datasource
          emptyDir: {}
        - name: grafana-data-storage
        - name: grafana-log-storage
        - configMap:
            items:
            - key: gettoken.sh
              path: gettoken.sh
            name: grafana-datasources
          name: get-token-shell
        - configMap:
            defaultMode: 420
            items:
            - key: prometheus.yaml
              path: prometheus.yaml
            name: grafana-datasources
          name: datasources
        - configMap:
            name: dashboards-config
            items:
            - key: clusterhealth.json
              path: clusterhealth.json
            - key: nodehealth.json
              path: nodehealth.json
            - key: hpa-recommendation.json
              path: hpa-recommendation.json
            - key: vpa-recommendation.json
              path: vpa-recommendation.json
            - key: vpa-recommendation-cluster.json
              path: vpa-recommendation-cluster.json
            - key: vpa-recommendation-namespace.json
              path: vpa-recommendation-namespace.json
            - key: vpa-recommendation-alamedascaler.json
              path: vpa-recommendation-alamedascaler.json
            - key: prediction-1day.json
              path: prediction-1day.json
          name: dashboards-json
        - configMap:
            name: dashboards-config
            items:
            - key: dashboardproviders.yaml
              path: dashboardproviders.yaml
          name: dashboardproviders
      serviceAccount: alameda-grafana
      serviceAccountName: alameda-grafana
