This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch refactor-with-go
in repository https://gitbox.apache.org/repos/asf/dubbo-admin.git


The following commit(s) were added to refs/heads/refactor-with-go by this push:
     new 023cda7  add prometheus (#996)
023cda7 is described below

commit 023cda707b63fa4fb4b52fc5ccbbb09002109139
Author: mfordjody <[email protected]>
AuthorDate: Sat Feb 25 18:11:39 2023 +0800

    add prometheus (#996)
---
 kubernetes/prometheus/configmap.yaml    | 14 +++++++++
 kubernetes/prometheus/pv.yaml           | 22 ++++++++++++++
 kubernetes/prometheus/pvc.yaml          | 11 +++++++
 kubernetes/prometheus/rbac.yaml         | 53 +++++++++++++++++++++++++++++++++
 kubernetes/prometheus/service.yaml      | 13 ++++++++
 kubernetes/prometheus/statefulset.yaml  | 49 ++++++++++++++++++++++++++++++
 kubernetes/prometheus/storageclass.yaml |  6 ++++
 7 files changed, 168 insertions(+)

diff --git a/kubernetes/prometheus/configmap.yaml 
b/kubernetes/prometheus/configmap.yaml
new file mode 100644
index 0000000..7299044
--- /dev/null
+++ b/kubernetes/prometheus/configmap.yaml
@@ -0,0 +1,14 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: prometheus-configmap
+  namespace: default
+data:
+  prometheus.yml: |
+    global:
+      scrape_interval: 15s
+      scrape_timeout: 15s
+    scrape_configs:
+    - job_name: 'prometheus'
+      static_configs:
+      - targets: ['localhost:9090']
\ No newline at end of file
diff --git a/kubernetes/prometheus/pv.yaml b/kubernetes/prometheus/pv.yaml
new file mode 100644
index 0000000..036cb75
--- /dev/null
+++ b/kubernetes/prometheus/pv.yaml
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: prometheus-pv
+spec:
+  capacity:
+    storage: 10Gi
+  volumeMode: Filesystem
+  accessModes:
+    - ReadWriteOnce
+  persistentVolumeReclaimPolicy: Retain
+  storageClassName: local
+  local:
+    path: /var/lib/prometheus
+  nodeAffinity:
+    required:
+      nodeSelectorTerms:
+        - matchExpressions:
+            - key: kubernetes.io/hostname
+              operator: In
+              values:
+                - master
\ No newline at end of file
diff --git a/kubernetes/prometheus/pvc.yaml b/kubernetes/prometheus/pvc.yaml
new file mode 100644
index 0000000..fbdb3cb
--- /dev/null
+++ b/kubernetes/prometheus/pvc.yaml
@@ -0,0 +1,11 @@
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: prometheus-pvc
+spec:
+  accessModes:
+    - ReadWriteOnce
+  resources:
+    requests:
+      storage: 5Gi
+  storageClassName: local
\ No newline at end of file
diff --git a/kubernetes/prometheus/rbac.yaml b/kubernetes/prometheus/rbac.yaml
new file mode 100644
index 0000000..355041d
--- /dev/null
+++ b/kubernetes/prometheus/rbac.yaml
@@ -0,0 +1,53 @@
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: prometheus
+  namespace: default
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRole
+metadata:
+  name: prometheus
+rules:
+  - apiGroups:
+      - ""
+    resources:
+      - nodes
+      - services
+      - endpoints
+      - pods
+      - nodes/proxy
+    verbs:
+      - get
+      - list
+      - watch
+  - apiGroups:
+      - "extensions"
+    resources:
+      - ingresses
+    verbs:
+      - get
+  - apiGroups:
+      - ""
+    resources:
+      - configmaps
+      - nodes/metrics
+    verbs:
+      - get
+  - nonResourceURLs:
+      - /metrics
+    verbs:
+      - get
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRoleBinding
+metadata:
+  name: prometheus
+roleRef:
+  apiGroup: rbac.authorization.k8s.io
+  kind: ClusterRole
+  name: prometheus
+subjects:
+  - kind: ServiceAccount
+    name: prometheus
+    namespace: default
\ No newline at end of file
diff --git a/kubernetes/prometheus/service.yaml 
b/kubernetes/prometheus/service.yaml
new file mode 100644
index 0000000..eb7f43c
--- /dev/null
+++ b/kubernetes/prometheus/service.yaml
@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: prometheus
+  namespace: default
+spec:
+  selector:
+    app: prometheus
+  type: NodePort
+  ports:
+    - name: http
+      port: 9090
+      targetPort: http
\ No newline at end of file
diff --git a/kubernetes/prometheus/statefulset.yaml 
b/kubernetes/prometheus/statefulset.yaml
new file mode 100644
index 0000000..1b060eb
--- /dev/null
+++ b/kubernetes/prometheus/statefulset.yaml
@@ -0,0 +1,49 @@
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: prometheus
+  namespace: default
+  labels:
+    app: prometheus
+spec:
+  selector:
+    matchLabels:
+      app: prometheus
+  template:
+    metadata:
+      labels:
+        app: prometheus
+    spec:
+      serviceAccountName: prometheus
+      containers:
+        - name: prometheus
+          image: prom/prometheus:v2.42.0
+          args:
+            - "--config.file=/etc/prometheus/prometheus.yml"
+            - "--storage.tsdb.path=/prometheus"
+            - "--storage.tsdb.retention.time=24h"
+            - "--web.enable-lifecycle"
+          ports:
+            - name: http
+              containerPort: 9090
+          volumeMounts:
+            - name: config
+              mountPath: "/etc/prometheus"
+            - name: storage
+              mountPath: "/var/lib/prometheus"
+          resources:
+            requests:
+              cpu: 100m
+              memory: 512Mi
+            limits:
+              cpu: 100m
+              memory: 512Mi
+      securityContext:
+        runAsUser: 0
+      volumes:
+        - name: config
+          configMap:
+            name: prometheus-configmap
+        - name: storage
+          persistentVolumeClaim:
+            claimName: prometheus-pvc
\ No newline at end of file
diff --git a/kubernetes/prometheus/storageclass.yaml 
b/kubernetes/prometheus/storageclass.yaml
new file mode 100644
index 0000000..f364d73
--- /dev/null
+++ b/kubernetes/prometheus/storageclass.yaml
@@ -0,0 +1,6 @@
+apiVersion: storage.k8s.io/v1
+kind: StorageClass
+metadata:
+  name: local
+provisioner: kubernetes.io/no-provisioner
+volumeBindingMode: WaitForFirstConsumer
\ No newline at end of file

Reply via email to