apiVersion: v1
kind: Namespace
metadata:
  name: icinga

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: icinga-for-kubernetes
  namespace: icinga

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: icinga-for-kubernetes
rules:
  - apiGroups: [ "*" ]
    resources: [ "*" ]
    verbs: [ "get", "list", "watch" ]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: icinga-for-kubernetes
roleRef:
  apiGroup: "rbac.authorization.k8s.io"
  kind: ClusterRole
  name: icinga-for-kubernetes
subjects:
  - kind: ServiceAccount
    name: icinga-for-kubernetes
    namespace: icinga
#  - kind: User
#    name: icinga-for-kubernetes

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: icinga-for-kubernetes
  namespace: icinga
data:
  config.yml: |-
    # This is the configuration file for Icinga for Kubernetes.
    
    # Connection configuration for the database to which Icinga for Kubernetes synchronizes data.
    # This is also the database used in Icinga for Kubernetes Web to view and work with the data.
    database:
      # Database type. Only 'mysql' is supported yet which is the default.
    #  type: mysql
    
      # Database host or absolute Unix socket path.
      host: mysql
    
      # Database port. By default, the MySQL port.
    #  port:
    
      # Database name.
      database: kubernetes
    
      # Database user.
      user: kubernetes
    
      # Database password.
      password: CHANGEME
    
    # Configuration for Prometheus metrics API.
    prometheus:
      # Prometheus server URL.
    #  url: http://localhost:9090

---
apiVersion: v1
kind: Pod
metadata:
  name: icinga-for-kubernetes
  namespace: icinga
spec:
  serviceAccountName: icinga-for-kubernetes
  containers:
    - name: icinga-for-kubernetes
      image: icinga/icinga-kubernetes
      volumeMounts:
        - name: config-volume
          mountPath: /config.yml
          subPath: config.yml
  volumes:
    - name: config-volume
      configMap:
        name: icinga-for-kubernetes
