--- ################################################### # Prometeus Service Account ################################################### apiVersion: v1 kind: ServiceAccount metadata: name: prometheus namespace: monitoring --- ################################################### # Prometeus Roles ################################################### apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRole metadata: name: prometheus namespace: monitoring rules: - apiGroups: [""] resources: - nodes - nodes/proxy - services - endpoints - pods verbs: ["get", "list", "watch"] - apiGroups: - extensions resources: - ingresses verbs: ["get", "list", "watch"] - nonResourceURLs: ["/metrics"] verbs: ["get"] --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: prometheus roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: prometheus subjects: - kind: ServiceAccount name: prometheus namespace: monitoring --- ################################################### # Prometeus Deployment ################################################### apiVersion: apps/v1 kind: Deployment metadata: name: prometheus namespace: monitoring labels: #name: prometheus app: prometheus spec: replicas: 1 selector: matchLabels: app: prometheus template: metadata: labels: app: prometheus spec: serviceAccountName: prometheus containers: - name: prometheus image: prom/prometheus:v2.1.0 imagePullPolicy: Always ports: - containerPort: 9090 protocol: TCP volumeMounts: - mountPath: "/etc/prometheus" name: config-prometheus volumes: - name: config-prometheus configMap: name: prometheus-config --- ################################################### # Prometeus Service ################################################### apiVersion: v1 kind: Service metadata: name: prometheus namespace: monitoring spec: type: ClusterIP ports: - port: 9090 targetPort: 9090 selector: app: prometheus