From 0a38bbe0fea401fb6d68ba421157ac60f9e91a0c Mon Sep 17 00:00:00 2001 From: Massaki Archambault Date: Thu, 26 Aug 2021 12:42:32 -0400 Subject: [PATCH] add promtheus --- .../cert-manager/cert-manager-namespace.patch | 12 +++--- .../bases/drone/drone-runner-deployment.yaml | 34 +++++++++++++---- .../bases/drone/drone-server-deployment.yaml | 27 +++++++++----- .../bases/drone/drone-server-ingress.yaml | 4 +- kustomize/bases/gitea/gitea-deployment.yaml | 19 ++++++---- kustomize/bases/gitea/gitea-ingress.yaml | 2 +- .../bases/grafana/grafana-deployment.yaml | 11 +++--- kustomize/bases/grafana/grafana-ingress.yaml | 2 +- .../bases/grafana/provision/datasources.yaml | 2 +- .../kube-state-metrics-servicemonitors.yaml | 6 +-- .../kube-state-metrics.yaml | 0 .../kube-state-metrics/kustomization.yaml | 13 +++++++ .../dashboard-ingress.yaml | 2 +- .../kube-state-metrics/kustomization.yaml | 8 ---- .../prometheus-operator/kustomization.yaml | 2 - .../monitoring/prometheus/kustomization.yaml | 7 ---- .../monitoring/prometheus/prometheus.yaml | 35 ------------------ kustomize/bases/nextcloud/ingress.yaml | 2 +- .../bases/nextcloud/nextcloud-deployment.yaml | 16 ++++---- .../node-exporter/kustomization.yaml | 1 + .../node-exporter-daemonset.yaml | 16 ++++---- .../node-exporter-servicemonitor.yaml | 13 +++++++ .../prometheus-operator/kustomization.yaml | 2 + .../prometheus-operator.yaml | 0 kustomize/bases/prometheus/kustomization.yaml | 6 +++ .../bases/prometheus/prometheus-ingress.yaml | 25 +++++++++++++ .../prometheus/prometheus-rbac.yaml | 0 kustomize/bases/prometheus/prometheus.yaml | 17 +++++++++ .../prometheus/servicemonitors.yaml | 37 +++++++++---------- .../bases/prometheus/traefik-podmonitor.yaml | 16 ++++++++ .../traefik/traefik-helmchartconfig.yaml | 7 ++-- .../namespaces/monitoring/kustomization.yaml | 10 +++++ .../namespaces/monitoring/namespace.yaml | 4 ++ .../namespaces/operators/kustomization.yaml | 7 ++++ kustomize/namespaces/operators/namespace.yaml | 4 ++ .../overlays/dev-cluster/kustomization.yaml | 1 + kustomize/overlays/dev/kustomization.yaml | 3 +- kustomize/overlays/dev/placeholders.txt | 1 + 38 files changed, 234 insertions(+), 140 deletions(-) rename kustomize/bases/{monitoring => }/kube-state-metrics/kube-state-metrics-servicemonitors.yaml (67%) rename kustomize/bases/{monitoring => }/kube-state-metrics/kube-state-metrics.yaml (100%) create mode 100644 kustomize/bases/kube-state-metrics/kustomization.yaml delete mode 100644 kustomize/bases/monitoring/kube-state-metrics/kustomization.yaml delete mode 100644 kustomize/bases/monitoring/prometheus-operator/kustomization.yaml delete mode 100644 kustomize/bases/monitoring/prometheus/kustomization.yaml delete mode 100644 kustomize/bases/monitoring/prometheus/prometheus.yaml rename kustomize/bases/{monitoring => }/node-exporter/kustomization.yaml (53%) rename kustomize/bases/{monitoring => }/node-exporter/node-exporter-daemonset.yaml (83%) create mode 100644 kustomize/bases/node-exporter/node-exporter-servicemonitor.yaml create mode 100644 kustomize/bases/prometheus-operator/kustomization.yaml rename kustomize/bases/{monitoring => }/prometheus-operator/prometheus-operator.yaml (100%) create mode 100644 kustomize/bases/prometheus/kustomization.yaml create mode 100644 kustomize/bases/prometheus/prometheus-ingress.yaml rename kustomize/bases/{monitoring => }/prometheus/prometheus-rbac.yaml (100%) create mode 100644 kustomize/bases/prometheus/prometheus.yaml rename kustomize/bases/{monitoring => }/prometheus/servicemonitors.yaml (90%) create mode 100644 kustomize/bases/prometheus/traefik-podmonitor.yaml create mode 100644 kustomize/namespaces/monitoring/kustomization.yaml create mode 100644 kustomize/namespaces/monitoring/namespace.yaml create mode 100644 kustomize/namespaces/operators/kustomization.yaml create mode 100644 kustomize/namespaces/operators/namespace.yaml diff --git a/kustomize/bases/cert-manager/cert-manager-namespace.patch b/kustomize/bases/cert-manager/cert-manager-namespace.patch index 837cd89..2b93e3b 100644 --- a/kustomize/bases/cert-manager/cert-manager-namespace.patch +++ b/kustomize/bases/cert-manager/cert-manager-namespace.patch @@ -7,7 +7,7 @@ - cert-manager.io/inject-ca-from-secret: 'cert-manager/cert-manager-webhook-ca' + cert-manager.io/inject-ca-from-secret: 'kube-system/cert-manager-webhook-ca' labels: - app: 'cert-manager' + app.kubernetes.io/name: 'cert-manager' app.kubernetes.io/name: 'cert-manager' @@ -54,7 +54,7 @@ # webhookClientConfig is required when strategy is `Webhook` and it configures the webhook endpoint to be called by API server. @@ -25,7 +25,7 @@ - cert-manager.io/inject-ca-from-secret: 'cert-manager/cert-manager-webhook-ca' + cert-manager.io/inject-ca-from-secret: 'kube-system/cert-manager-webhook-ca' labels: - app: 'cert-manager' + app.kubernetes.io/name: 'cert-manager' app.kubernetes.io/name: 'cert-manager' @@ -623,7 +623,7 @@ # webhookClientConfig is required when strategy is `Webhook` and it configures the webhook endpoint to be called by API server. @@ -43,7 +43,7 @@ - cert-manager.io/inject-ca-from-secret: 'cert-manager/cert-manager-webhook-ca' + cert-manager.io/inject-ca-from-secret: 'kube-system/cert-manager-webhook-ca' labels: - app: 'cert-manager' + app.kubernetes.io/name: 'cert-manager' app.kubernetes.io/name: 'cert-manager' @@ -1831,7 +1831,7 @@ # webhookClientConfig is required when strategy is `Webhook` and it configures the webhook endpoint to be called by API server. @@ -61,7 +61,7 @@ - cert-manager.io/inject-ca-from-secret: 'cert-manager/cert-manager-webhook-ca' + cert-manager.io/inject-ca-from-secret: 'kube-system/cert-manager-webhook-ca' labels: - app: 'cert-manager' + app.kubernetes.io/name: 'cert-manager' app.kubernetes.io/name: 'cert-manager' @@ -6291,7 +6291,7 @@ # webhookClientConfig is required when strategy is `Webhook` and it configures the webhook endpoint to be called by API server. @@ -79,7 +79,7 @@ - cert-manager.io/inject-ca-from-secret: 'cert-manager/cert-manager-webhook-ca' + cert-manager.io/inject-ca-from-secret: 'kube-system/cert-manager-webhook-ca' labels: - app: 'cert-manager' + app.kubernetes.io/name: 'cert-manager' app.kubernetes.io/name: 'cert-manager' @@ -12115,7 +12115,7 @@ # webhookClientConfig is required when strategy is `Webhook` and it configures the webhook endpoint to be called by API server. @@ -97,7 +97,7 @@ - cert-manager.io/inject-ca-from-secret: 'cert-manager/cert-manager-webhook-ca' + cert-manager.io/inject-ca-from-secret: 'kube-system/cert-manager-webhook-ca' labels: - app: 'cert-manager' + app.kubernetes.io/name: 'cert-manager' app.kubernetes.io/name: 'cert-manager' @@ -17940,7 +17940,7 @@ # webhookClientConfig is required when strategy is `Webhook` and it configures the webhook endpoint to be called by API server. diff --git a/kustomize/bases/drone/drone-runner-deployment.yaml b/kustomize/bases/drone/drone-runner-deployment.yaml index 8885ded..95e70c9 100644 --- a/kustomize/bases/drone/drone-runner-deployment.yaml +++ b/kustomize/bases/drone/drone-runner-deployment.yaml @@ -3,18 +3,18 @@ kind: Deployment metadata: name: drone-runner labels: - app: drone - component: runner + app.kubernetes.io/name: drone + app.kubernetes.io/component: runner spec: selector: matchLabels: - app: drone - component: runner + app.kubernetes.io/name: drone + app.kubernetes.io/component: runner template: metadata: labels: - app: drone - component: runner + app.kubernetes.io/name: drone + app.kubernetes.io/component: runner spec: containers: - name: drone @@ -31,7 +31,7 @@ spec: key: rpc_secret ports: - name: http - containerPort: 80 + containerPort: 3000 resources: requests: cpu: 2000m @@ -72,4 +72,22 @@ subjects: roleRef: kind: Role name: drone-runner-role - apiGroup: rbac.authorization.k8s.io \ No newline at end of file + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: v1 +kind: Service +metadata: + name: drone-runner + labels: + app.kubernetes.io/name: drone + app.kubernetes.io/component: runner + # monitor: prometheus +spec: + selector: + app.kubernetes.io/name: drone + app.kubernetes.io/component: runner + ports: + - name: http + protocol: TCP + port: 3000 + targetPort: http \ No newline at end of file diff --git a/kustomize/bases/drone/drone-server-deployment.yaml b/kustomize/bases/drone/drone-server-deployment.yaml index 39feba2..197a8ea 100644 --- a/kustomize/bases/drone/drone-server-deployment.yaml +++ b/kustomize/bases/drone/drone-server-deployment.yaml @@ -3,18 +3,18 @@ kind: Deployment metadata: name: drone-server labels: - app: drone - component: server + app.kubernetes.io/name: drone + app.kubernetes.io/component: server spec: selector: matchLabels: - app: drone - component: server + app.kubernetes.io/name: drone + app.kubernetes.io/component: server template: metadata: labels: - app: drone - component: server + app.kubernetes.io/name: drone + app.kubernetes.io/component: server spec: containers: - name: drone @@ -22,6 +22,8 @@ spec: env: - name: DRONE_SERVER_HOST value: ${DRONE_EXTERNAL_HOST} + - name: DRONE_SERVER_PORT + value: ":80" - name: DRONE_SERVER_PROTO value: https - name: DRONE_GITEA_SERVER @@ -41,6 +43,9 @@ spec: secretKeyRef: name: drone-secret key: rpc_secret + ports: + - name: http + containerPort: 80 resources: requests: cpu: 500m @@ -49,13 +54,15 @@ spec: apiVersion: v1 kind: Service metadata: - name: drone + name: drone-server labels: - app: drone + app.kubernetes.io/name: drone + app.kubernetes.io/component: server + # monitor: prometheus spec: selector: - app: drone - component: server + app.kubernetes.io/name: drone + app.kubernetes.io/component: server ports: - name: http protocol: TCP diff --git a/kustomize/bases/drone/drone-server-ingress.yaml b/kustomize/bases/drone/drone-server-ingress.yaml index 7845e67..a9b8de9 100644 --- a/kustomize/bases/drone/drone-server-ingress.yaml +++ b/kustomize/bases/drone/drone-server-ingress.yaml @@ -3,7 +3,7 @@ kind: Ingress metadata: name: drone labels: - app: drone + app.kubernetes.io/name: drone annotations: # nginx.ingress.kubernetes.io/rewrite-target: / # cert-manager.io/cluster-issuer: letsencrypt @@ -20,6 +20,6 @@ spec: pathType: Prefix backend: service: - name: drone + name: drone-server port: name: http diff --git a/kustomize/bases/gitea/gitea-deployment.yaml b/kustomize/bases/gitea/gitea-deployment.yaml index 83c939d..fb31e3b 100644 --- a/kustomize/bases/gitea/gitea-deployment.yaml +++ b/kustomize/bases/gitea/gitea-deployment.yaml @@ -3,16 +3,16 @@ kind: Deployment metadata: name: gitea labels: - app: gitea + app.kubernetes.io/name: gitea spec: replicas: 1 # replica count must be set to 1 in database is sqlite selector: matchLabels: - app: gitea + app.kubernetes.io/name: gitea template: metadata: labels: - app: gitea + app.kubernetes.io/name: gitea spec: containers: - name: gitea @@ -30,6 +30,8 @@ spec: value: https://${GITEA_EXTERNAL_HOST} - name: SSH_DOMAIN value: ${GITEA_EXTERNAL_HOST} + - name: GITEA__METRICS__ENABLED + value: "true" # - name: DB_TYPE # value: postgres # - name: DB_HOST @@ -74,7 +76,7 @@ spec: # metadata: # name: gitea-data-nfs # labels: -# app: gitea +# app.kubernetes.io/name: gitea # spec: # accessModes: # - ReadWriteMany @@ -90,7 +92,7 @@ kind: PersistentVolumeClaim metadata: name: gitea-pvc labels: - app: gitea + app.kubernetes.io/name: gitea spec: # storageClassName: "" accessModes: @@ -100,17 +102,18 @@ spec: storage: 10Gi # selector: # matchLabels: - # app: gitea + # app.kubernetes.io/name: gitea --- apiVersion: v1 kind: Service metadata: name: gitea labels: - app: gitea + app.kubernetes.io/name: gitea + monitor: prometheus spec: selector: - app: gitea + app.kubernetes.io/name: gitea ports: - name: http protocol: TCP diff --git a/kustomize/bases/gitea/gitea-ingress.yaml b/kustomize/bases/gitea/gitea-ingress.yaml index 779b59a..4fd8310 100644 --- a/kustomize/bases/gitea/gitea-ingress.yaml +++ b/kustomize/bases/gitea/gitea-ingress.yaml @@ -3,7 +3,7 @@ kind: Ingress metadata: name: gitea labels: - app: gitea + app.kubernetes.io/name: gitea annotations: # nginx.ingress.kubernetes.io/rewrite-target: / # cert-manager.io/cluster-issuer: letsencrypt diff --git a/kustomize/bases/grafana/grafana-deployment.yaml b/kustomize/bases/grafana/grafana-deployment.yaml index 0b3bb74..f81f233 100644 --- a/kustomize/bases/grafana/grafana-deployment.yaml +++ b/kustomize/bases/grafana/grafana-deployment.yaml @@ -3,15 +3,15 @@ kind: Deployment metadata: name: grafana labels: - app: grafana + app.kubernetes.io/name: grafana spec: selector: matchLabels: - app: grafana + app.kubernetes.io/name: grafana template: metadata: labels: - app: grafana + app.kubernetes.io/name: grafana spec: containers: - name: grafana @@ -97,10 +97,11 @@ kind: Service metadata: name: grafana labels: - app: grafana + app.kubernetes.io/name: grafana + monitor: prometheus spec: selector: - app: grafana + app.kubernetes.io/name: grafana ports: - name: http protocol: TCP diff --git a/kustomize/bases/grafana/grafana-ingress.yaml b/kustomize/bases/grafana/grafana-ingress.yaml index 4ed12d9..2315f25 100644 --- a/kustomize/bases/grafana/grafana-ingress.yaml +++ b/kustomize/bases/grafana/grafana-ingress.yaml @@ -3,7 +3,7 @@ kind: Ingress metadata: name: grafana labels: - app: grafana + app.kubernetes.io/name: grafana annotations: # nginx.ingress.kubernetes.io/rewrite-target: / # cert-manager.io/cluster-issuer: letsencrypt diff --git a/kustomize/bases/grafana/provision/datasources.yaml b/kustomize/bases/grafana/provision/datasources.yaml index a89d2c0..7b54bb2 100644 --- a/kustomize/bases/grafana/provision/datasources.yaml +++ b/kustomize/bases/grafana/provision/datasources.yaml @@ -3,5 +3,5 @@ datasources: - name: prometheus type: prometheus access: proxy - url: http://prometheus-main.monitoring.svc:9090 + url: http://prometheus-operated.monitoring.svc:9090 is_default: true diff --git a/kustomize/bases/monitoring/kube-state-metrics/kube-state-metrics-servicemonitors.yaml b/kustomize/bases/kube-state-metrics/kube-state-metrics-servicemonitors.yaml similarity index 67% rename from kustomize/bases/monitoring/kube-state-metrics/kube-state-metrics-servicemonitors.yaml rename to kustomize/bases/kube-state-metrics/kube-state-metrics-servicemonitors.yaml index a2dc10a..7a55873 100644 --- a/kustomize/bases/monitoring/kube-state-metrics/kube-state-metrics-servicemonitors.yaml +++ b/kustomize/bases/kube-state-metrics/kube-state-metrics-servicemonitors.yaml @@ -3,13 +3,11 @@ kind: ServiceMonitor metadata: name: kube-state-metrics labels: - monitor: main + monitor: prometheus spec: selector: matchLabels: - managed-by: kustomize - app: kube-state-metrics + app.kubernetes.io/name: kube-state-metrics endpoints: - port: http-metrics - path: /metrics honorLabels: true diff --git a/kustomize/bases/monitoring/kube-state-metrics/kube-state-metrics.yaml b/kustomize/bases/kube-state-metrics/kube-state-metrics.yaml similarity index 100% rename from kustomize/bases/monitoring/kube-state-metrics/kube-state-metrics.yaml rename to kustomize/bases/kube-state-metrics/kube-state-metrics.yaml diff --git a/kustomize/bases/kube-state-metrics/kustomization.yaml b/kustomize/bases/kube-state-metrics/kustomization.yaml new file mode 100644 index 0000000..f9d6b36 --- /dev/null +++ b/kustomize/bases/kube-state-metrics/kustomization.yaml @@ -0,0 +1,13 @@ +resources: + - kube-state-metrics-servicemonitors.yaml + - https://raw.githubusercontent.com/kubernetes/kube-state-metrics/v2.1.1/examples/standard/cluster-role-binding.yaml + - https://raw.githubusercontent.com/kubernetes/kube-state-metrics/v2.1.1/examples/standard/cluster-role.yaml + - https://raw.githubusercontent.com/kubernetes/kube-state-metrics/v2.1.1/examples/standard/deployment.yaml + - https://raw.githubusercontent.com/kubernetes/kube-state-metrics/v2.1.1/examples/standard/service-account.yaml + - https://raw.githubusercontent.com/kubernetes/kube-state-metrics/v2.1.1/examples/standard/service.yaml + +commonLabels: + app.kubernetes.io/name: kube-state-metrics + +# generators: +# - kube-state-metrics.yaml \ No newline at end of file diff --git a/kustomize/bases/kubernetes-dashboard/dashboard-ingress.yaml b/kustomize/bases/kubernetes-dashboard/dashboard-ingress.yaml index 46ed7a3..1570f2c 100644 --- a/kustomize/bases/kubernetes-dashboard/dashboard-ingress.yaml +++ b/kustomize/bases/kubernetes-dashboard/dashboard-ingress.yaml @@ -3,7 +3,7 @@ kind: Ingress metadata: name: kubernetes-dashboard labels: - app: kubernetes-dashboard + app.kubernetes.io/name: kubernetes-dashboard annotations: # nginx.ingress.kubernetes.io/rewrite-target: / # nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" diff --git a/kustomize/bases/monitoring/kube-state-metrics/kustomization.yaml b/kustomize/bases/monitoring/kube-state-metrics/kustomization.yaml deleted file mode 100644 index 0ab1aa6..0000000 --- a/kustomize/bases/monitoring/kube-state-metrics/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -resources: - - kube-state-metrics-servicemonitors.yaml - -commonLabels: - app: kube-state-metrics - -generators: - - kube-state-metrics.yaml \ No newline at end of file diff --git a/kustomize/bases/monitoring/prometheus-operator/kustomization.yaml b/kustomize/bases/monitoring/prometheus-operator/kustomization.yaml deleted file mode 100644 index cdea3e7..0000000 --- a/kustomize/bases/monitoring/prometheus-operator/kustomization.yaml +++ /dev/null @@ -1,2 +0,0 @@ -generators: - - prometheus-operator.yaml \ No newline at end of file diff --git a/kustomize/bases/monitoring/prometheus/kustomization.yaml b/kustomize/bases/monitoring/prometheus/kustomization.yaml deleted file mode 100644 index 2a0ee88..0000000 --- a/kustomize/bases/monitoring/prometheus/kustomization.yaml +++ /dev/null @@ -1,7 +0,0 @@ -resources: - - prometheus.yaml - - prometheus-rbac.yaml - - servicemonitors.yaml - -commonLabels: - app: prometheus \ No newline at end of file diff --git a/kustomize/bases/monitoring/prometheus/prometheus.yaml b/kustomize/bases/monitoring/prometheus/prometheus.yaml deleted file mode 100644 index 757296a..0000000 --- a/kustomize/bases/monitoring/prometheus/prometheus.yaml +++ /dev/null @@ -1,35 +0,0 @@ -apiVersion: monitoring.coreos.com/v1 -kind: Prometheus -metadata: - name: main -spec: - serviceAccountName: prometheus - serviceMonitorSelector: - matchLabels: - monitor: main - resources: - requests: - memory: 300Mi - limits: - memory: 500Mi ---- -apiVersion: networking.k8s.io/v1beta1 -kind: Ingress -metadata: - name: prometheus - annotations: - nginx.ingress.kubernetes.io/rewrite-target: / - cert-manager.io/cluster-issuer: letsencrypt -spec: - tls: - - hosts: - - prometheus.127.0.0.1.nip.io - secretName: letsencrypt-cert - rules: - - host: prometheus.127.0.0.1.nip.io - http: - paths: - - path: / - backend: - serviceName: prometheus-operated - servicePort: web \ No newline at end of file diff --git a/kustomize/bases/nextcloud/ingress.yaml b/kustomize/bases/nextcloud/ingress.yaml index 9f164d8..b474d2a 100644 --- a/kustomize/bases/nextcloud/ingress.yaml +++ b/kustomize/bases/nextcloud/ingress.yaml @@ -3,7 +3,7 @@ kind: Ingress metadata: name: nextcloud labels: - app: nextcloud + app.kubernetes.io/name: nextcloud annotations: nginx.ingress.kubernetes.io/rewrite-target: / cert-manager.io/cluster-issuer: letsencrypt diff --git a/kustomize/bases/nextcloud/nextcloud-deployment.yaml b/kustomize/bases/nextcloud/nextcloud-deployment.yaml index 9d9693d..28b9de9 100644 --- a/kustomize/bases/nextcloud/nextcloud-deployment.yaml +++ b/kustomize/bases/nextcloud/nextcloud-deployment.yaml @@ -3,15 +3,15 @@ kind: Deployment metadata: name: nextcloud labels: - app: nextcloud + app.kubernetes.io/name: nextcloud spec: selector: matchLabels: - app: nextcloud + app.kubernetes.io/name: nextcloud template: metadata: labels: - app: nextcloud + app.kubernetes.io/name: nextcloud spec: containers: - name: nextcloud @@ -55,7 +55,7 @@ kind: PersistentVolume metadata: name: nextcloud-data-nfs labels: - app: nextcloud + app.kubernetes.io/name: nextcloud spec: accessModes: - ReadWriteMany @@ -71,7 +71,7 @@ kind: PersistentVolumeClaim metadata: name: nextcloud-data labels: - app: nextcloud + app.kubernetes.io/name: nextcloud spec: storageClassName: "" accessModes: @@ -81,17 +81,17 @@ spec: storage: 100Mi selector: matchLabels: - app: nextcloud + app.kubernetes.io/name: nextcloud --- apiVersion: v1 kind: Service metadata: name: nextcloud labels: - app: nextcloud + app.kubernetes.io/name: nextcloud spec: selector: - app: nextcloud + app.kubernetes.io/name: nextcloud ports: - name: http protocol: TCP diff --git a/kustomize/bases/monitoring/node-exporter/kustomization.yaml b/kustomize/bases/node-exporter/kustomization.yaml similarity index 53% rename from kustomize/bases/monitoring/node-exporter/kustomization.yaml rename to kustomize/bases/node-exporter/kustomization.yaml index afe897a..2f177ac 100644 --- a/kustomize/bases/monitoring/node-exporter/kustomization.yaml +++ b/kustomize/bases/node-exporter/kustomization.yaml @@ -1,2 +1,3 @@ resources: - node-exporter-daemonset.yaml + - node-exporter-servicemonitor.yaml diff --git a/kustomize/bases/monitoring/node-exporter/node-exporter-daemonset.yaml b/kustomize/bases/node-exporter/node-exporter-daemonset.yaml similarity index 83% rename from kustomize/bases/monitoring/node-exporter/node-exporter-daemonset.yaml rename to kustomize/bases/node-exporter/node-exporter-daemonset.yaml index 20c915d..5451e3c 100644 --- a/kustomize/bases/monitoring/node-exporter/node-exporter-daemonset.yaml +++ b/kustomize/bases/node-exporter/node-exporter-daemonset.yaml @@ -4,16 +4,16 @@ metadata: name: node-exporter namespace: kube-monitoring labels: - app: node-exporter + app.kubernetes.io/name: node-exporter spec: selector: matchLabels: - app: node-exporter + app.kubernetes.io/name: node-exporter template: metadata: name: node-exporter labels: - app: node-exporter + app.kubernetes.io/name: node-exporter spec: hostNetwork: true hostPID: true @@ -56,14 +56,12 @@ kind: Service metadata: name: nodes-exporter labels: - app: node-exporter - monitor: main + app.kubernetes.io/name: node-exporter spec: - type: ClusterIP + selector: + app.kubernetes.io/name: node-exporter ports: - name: http-metrics port: 9100 protocol: TCP - targetPort: http-metrics - selector: - app: node-exporter \ No newline at end of file + targetPort: http-metrics \ No newline at end of file diff --git a/kustomize/bases/node-exporter/node-exporter-servicemonitor.yaml b/kustomize/bases/node-exporter/node-exporter-servicemonitor.yaml new file mode 100644 index 0000000..02b7ca0 --- /dev/null +++ b/kustomize/bases/node-exporter/node-exporter-servicemonitor.yaml @@ -0,0 +1,13 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: node-exporter + labels: + app.kubernetes.io/name: node-exporter + monitor: prometheus +spec: + selector: + matchLabels: + app.kubernetes.io/name: node-exporter + endpoints: + - port: http-metrics \ No newline at end of file diff --git a/kustomize/bases/prometheus-operator/kustomization.yaml b/kustomize/bases/prometheus-operator/kustomization.yaml new file mode 100644 index 0000000..9754c49 --- /dev/null +++ b/kustomize/bases/prometheus-operator/kustomization.yaml @@ -0,0 +1,2 @@ +resources: + - https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.50/bundle.yaml \ No newline at end of file diff --git a/kustomize/bases/monitoring/prometheus-operator/prometheus-operator.yaml b/kustomize/bases/prometheus-operator/prometheus-operator.yaml similarity index 100% rename from kustomize/bases/monitoring/prometheus-operator/prometheus-operator.yaml rename to kustomize/bases/prometheus-operator/prometheus-operator.yaml diff --git a/kustomize/bases/prometheus/kustomization.yaml b/kustomize/bases/prometheus/kustomization.yaml new file mode 100644 index 0000000..cfc8ea5 --- /dev/null +++ b/kustomize/bases/prometheus/kustomization.yaml @@ -0,0 +1,6 @@ +resources: + - prometheus.yaml + - prometheus-rbac.yaml + - prometheus-ingress.yaml + - traefik-podmonitor.yaml + - servicemonitors.yaml \ No newline at end of file diff --git a/kustomize/bases/prometheus/prometheus-ingress.yaml b/kustomize/bases/prometheus/prometheus-ingress.yaml new file mode 100644 index 0000000..4bc6652 --- /dev/null +++ b/kustomize/bases/prometheus/prometheus-ingress.yaml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: prometheus + labels: + app.kubernetes.io/name: prometheus + annotations: + # nginx.ingress.kubernetes.io/rewrite-target: / + # cert-manager.io/cluster-issuer: letsencrypt +spec: + # tls: + # - hosts: + # - ${prometheus_EXTERNAL_HOST} + # secretName: letsencrypt-cert + rules: + - host: ${PROMETHEUS_EXTERNAL_HOST} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: prometheus-operated + port: + name: web diff --git a/kustomize/bases/monitoring/prometheus/prometheus-rbac.yaml b/kustomize/bases/prometheus/prometheus-rbac.yaml similarity index 100% rename from kustomize/bases/monitoring/prometheus/prometheus-rbac.yaml rename to kustomize/bases/prometheus/prometheus-rbac.yaml diff --git a/kustomize/bases/prometheus/prometheus.yaml b/kustomize/bases/prometheus/prometheus.yaml new file mode 100644 index 0000000..30a21a0 --- /dev/null +++ b/kustomize/bases/prometheus/prometheus.yaml @@ -0,0 +1,17 @@ +apiVersion: monitoring.coreos.com/v1 +kind: Prometheus +metadata: + name: prometheus +spec: + serviceAccountName: prometheus + serviceMonitorSelector: + matchLabels: + monitor: prometheus + podMonitorSelector: + matchLabels: + monitor: prometheus + resources: + requests: + memory: 3Gi + limits: + memory: 4Gi \ No newline at end of file diff --git a/kustomize/bases/monitoring/prometheus/servicemonitors.yaml b/kustomize/bases/prometheus/servicemonitors.yaml similarity index 90% rename from kustomize/bases/monitoring/prometheus/servicemonitors.yaml rename to kustomize/bases/prometheus/servicemonitors.yaml index 49b3ed7..9fa89cf 100644 --- a/kustomize/bases/monitoring/prometheus/servicemonitors.yaml +++ b/kustomize/bases/prometheus/servicemonitors.yaml @@ -3,37 +3,21 @@ kind: ServiceMonitor metadata: name: prometheus labels: - monitor: main + app.kubernetes.io/name: prometheus + monitor: prometheus spec: selector: matchLabels: operated-prometheus: "true" endpoints: - port: web - path: /metrics ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - name: servicemonitor-http - labels: - monitor: main -spec: - namespaceSelector: - any: true - selector: - matchLabels: - monitor: main - endpoints: - - port: http - path: /metrics --- apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: kubelet labels: - monitor: main + monitor: prometheus spec: namespaceSelector: matchNames: @@ -60,3 +44,18 @@ spec: tlsConfig: caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt insecureSkipVerify: true +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: servicemonitor-http + labels: + monitor: prometheus +spec: + namespaceSelector: + any: true + selector: + matchLabels: + monitor: prometheus + endpoints: + - port: http diff --git a/kustomize/bases/prometheus/traefik-podmonitor.yaml b/kustomize/bases/prometheus/traefik-podmonitor.yaml new file mode 100644 index 0000000..e7c5f4f --- /dev/null +++ b/kustomize/bases/prometheus/traefik-podmonitor.yaml @@ -0,0 +1,16 @@ +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: traefik + labels: + app.kubernetes.io/name: traefik + monitor: prometheus +spec: + namespaceSelector: + matchNames: + - kube-system + selector: + matchLabels: + app.kubernetes.io/name: traefik + podMetricsEndpoints: + - port: traefik \ No newline at end of file diff --git a/kustomize/bases/traefik/traefik-helmchartconfig.yaml b/kustomize/bases/traefik/traefik-helmchartconfig.yaml index 0b004ec..b31e4a1 100644 --- a/kustomize/bases/traefik/traefik-helmchartconfig.yaml +++ b/kustomize/bases/traefik/traefik-helmchartconfig.yaml @@ -6,6 +6,7 @@ spec: valuesContent: |- additionalArguments: - '--serversTransport.insecureSkipVerify=true' - ports: - web: - redirectTo: websecure \ No newline at end of file + - '--metrics.prometheus=true' + # ports: + # web: + # redirectTo: websecure \ No newline at end of file diff --git a/kustomize/namespaces/monitoring/kustomization.yaml b/kustomize/namespaces/monitoring/kustomization.yaml new file mode 100644 index 0000000..71d5dca --- /dev/null +++ b/kustomize/namespaces/monitoring/kustomization.yaml @@ -0,0 +1,10 @@ +bases: + - ../../bases/prometheus + - ../../bases/node-exporter + - ../../bases/kube-state-metrics + # - ../../base/postgres + +resources: + - namespace.yaml + +namespace: monitoring diff --git a/kustomize/namespaces/monitoring/namespace.yaml b/kustomize/namespaces/monitoring/namespace.yaml new file mode 100644 index 0000000..3335b6a --- /dev/null +++ b/kustomize/namespaces/monitoring/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: monitoring \ No newline at end of file diff --git a/kustomize/namespaces/operators/kustomization.yaml b/kustomize/namespaces/operators/kustomization.yaml new file mode 100644 index 0000000..5137336 --- /dev/null +++ b/kustomize/namespaces/operators/kustomization.yaml @@ -0,0 +1,7 @@ +bases: + - ../../bases/prometheus-operator + +resources: + - namespace.yaml + +namespace: operators diff --git a/kustomize/namespaces/operators/namespace.yaml b/kustomize/namespaces/operators/namespace.yaml new file mode 100644 index 0000000..bd80088 --- /dev/null +++ b/kustomize/namespaces/operators/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: operators \ No newline at end of file diff --git a/kustomize/overlays/dev-cluster/kustomization.yaml b/kustomize/overlays/dev-cluster/kustomization.yaml index f499082..5c80f23 100644 --- a/kustomize/overlays/dev-cluster/kustomization.yaml +++ b/kustomize/overlays/dev-cluster/kustomization.yaml @@ -1,5 +1,6 @@ bases: - ../../namespaces/kube-system + - ../../namespaces/operators # - ../../namespaces/cert-manager # allow "kubectl apply -l managed-by=cluster --prune ..." diff --git a/kustomize/overlays/dev/kustomization.yaml b/kustomize/overlays/dev/kustomization.yaml index 045b361..25ad5b4 100644 --- a/kustomize/overlays/dev/kustomization.yaml +++ b/kustomize/overlays/dev/kustomization.yaml @@ -2,6 +2,7 @@ bases: - ../../namespaces/kubernetes-dashboard - ../../namespaces/gitea - ../../namespaces/grafana + - ../../namespaces/monitoring # - ../../namespaces/nextcloud # resources: @@ -43,7 +44,7 @@ commonlabels: transformers: - transformers/placeholders.yaml - - transformers/ssm-secrets.yaml + # - transformers/ssm-secrets.yaml # configurations: # - cert-manager/kustomizeconfig.yaml diff --git a/kustomize/overlays/dev/placeholders.txt b/kustomize/overlays/dev/placeholders.txt index 2cb8da5..f7ded37 100644 --- a/kustomize/overlays/dev/placeholders.txt +++ b/kustomize/overlays/dev/placeholders.txt @@ -3,3 +3,4 @@ GITEA_EXTERNAL_HOST=gitea.localhost GRAFANA_EXTERNAL_HOST=grafana.localhost KUBERNETES_DASHBOARD_EXTERNAL_HOST=kubernetes-dashboard.localhost NEXTCLOUD_EXTERNAL_HOST=nextcloud.localhost +PROMETHEUS_EXTERNAL_HOST=prometheus.localhost