#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you 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: Namespace
metadata:
  name: monitoring-layer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: prometheus-deployment
  labels:
    app: prometheus
  namespace: monitoring-layer
spec:
  replicas: 1
  selector:
    matchLabels:
      app: prometheus-deployment
  template:
    metadata:
      labels:
        app: prometheus-deployment
    spec:
      containers:
      - name: prometheus-deployment
        image: prom/prometheus
        volumeMounts:
          - name: config-volume
            mountPath: /etc/prometheus/prometheus.yml
            subPath: prometheus.yml
        ports:
        - containerPort: 9090
      - name: grafana-deployment
        image: grafana/grafana  
        ports:
        - containerPort: 3000
      volumes:
        - name: config-volume
          configMap:
           name: prometheus-config
---
kind: Service
apiVersion: v1
metadata:
  name: prometheus-service
  namespace: monitoring-layer
spec:
  type: NodePort
  selector:
    app: prometheus-deployment
  ports:
  - name: promui
    protocol: TCP
    port: 9090
    targetPort: 9090
    nodePort: 30090
---
kind: Service
apiVersion: v1
metadata:
  name: grafana-service
  namespace: monitoring-layer
spec:
  type: NodePort
  selector:
    app: prometheus-deployment
  ports:
  - name: grafui
    protocol: TCP
    port: 3000
    targetPort: 3000
    nodePort: 30030

