feature:TSG-X os新增prometheus systemd exporter
This commit is contained in:
@@ -174,6 +174,7 @@
|
||||
- {role: nm-config, tags: nm-config}
|
||||
- {role: tsg-os-logo, tags: tsg-os-logo}
|
||||
- {role: cm-cache, tags: cm-cache}
|
||||
- {role: exporter, tags: exporter}
|
||||
|
||||
- hosts: TSG-X-NXR620G40-R01-P0906-init
|
||||
remote_user: root
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
src: '{{ role_path }}/files/node_exporter'
|
||||
dest: /opt/tsg/exporter/node_exporter
|
||||
mode: 0755
|
||||
when: runtime_env != 'TSG-X-P0906'
|
||||
|
||||
- name: "copy systemd_exporter"
|
||||
copy:
|
||||
@@ -43,22 +44,27 @@
|
||||
src: '{{ role_path }}/files/redis_exporter'
|
||||
dest: /opt/tsg/exporter/redis_exporter
|
||||
mode: 0755
|
||||
when: monitor.enable_redis_exporter == 1
|
||||
when:
|
||||
- monitor.enable_redis_exporter == 1
|
||||
- runtime_env != 'TSG-X-P0906'
|
||||
|
||||
- name: "copy ipmi_exporter"
|
||||
copy:
|
||||
src: '{{ role_path }}/files/ipmi_exporter'
|
||||
dest: /opt/tsg/exporter/ipmi_exporter
|
||||
mode: 0755
|
||||
when: monitor.enable_ipmi_exporter == 1
|
||||
when:
|
||||
- monitor.enable_ipmi_exporter == 1
|
||||
- runtime_env != 'TSG-X-P0906'
|
||||
|
||||
- name: "templates atca-exporter-node.service"
|
||||
template:
|
||||
src: "{{role_path}}/templates/exporter-node.service.j2"
|
||||
dest: /usr/lib/systemd/system/exporter-node.service
|
||||
tags: template
|
||||
when: runtime_env != 'TSG-X-P0906'
|
||||
|
||||
- name: "templates atca-exporter-systemd.service"
|
||||
- name: "templates exporter-systemd.service"
|
||||
template:
|
||||
src: "{{role_path}}/templates/exporter-systemd.service.j2"
|
||||
dest: /usr/lib/systemd/system/exporter-systemd.service
|
||||
@@ -69,7 +75,9 @@
|
||||
src: "{{role_path}}/templates/exporter-ipmi.service.j2"
|
||||
dest: /usr/lib/systemd/system/exporter-ipmi.service
|
||||
tags: template
|
||||
when: monitor.enable_ipmi_exporter == 1
|
||||
when:
|
||||
- monitor.enable_ipmi_exporter == 1
|
||||
- runtime_env != 'TSG-X-P0906'
|
||||
|
||||
- name: "Create /usr/lib/systemd/system/exporter-node.service.d directory if it does not exist"
|
||||
file:
|
||||
@@ -78,6 +86,7 @@
|
||||
mode: '0755'
|
||||
with_items:
|
||||
- /usr/lib/systemd/system/exporter-node.service.d
|
||||
when: runtime_env != 'TSG-X-P0906'
|
||||
|
||||
- name: "Create /usr/lib/systemd/system/exporter-systemd.service.d directory if it does not exist"
|
||||
file:
|
||||
@@ -86,6 +95,7 @@
|
||||
mode: '0755'
|
||||
with_items:
|
||||
- /usr/lib/systemd/system/exporter-systemd.service.d
|
||||
when: runtime_env != 'TSG-X-P0906'
|
||||
|
||||
- name: "Create /usr/lib/systemd/system/exporter-ipmi.service.d directory if it does not exist"
|
||||
file:
|
||||
@@ -94,7 +104,9 @@
|
||||
mode: '0755'
|
||||
with_items:
|
||||
- /usr/lib/systemd/system/exporter-ipmi.service.d
|
||||
when: monitor.enable_ipmi_exporter == 1
|
||||
when:
|
||||
- monitor.enable_ipmi_exporter == 1
|
||||
- runtime_env != 'TSG-X-P0906'
|
||||
|
||||
- name: "copy slice file to exporter-node.service.d"
|
||||
copy:
|
||||
@@ -145,6 +157,8 @@
|
||||
systemd:
|
||||
name: exporter-node
|
||||
enabled: yes
|
||||
when: runtime_env != 'TSG-X-P0906'
|
||||
|
||||
|
||||
- name: 'exporter-systemd service start'
|
||||
systemd:
|
||||
@@ -155,4 +169,6 @@
|
||||
systemd:
|
||||
name: exporter-ipmi
|
||||
enabled: yes
|
||||
when: monitor.enable_ipmi_exporter == 1
|
||||
when:
|
||||
- monitor.enable_ipmi_exporter == 1
|
||||
- runtime_env != 'TSG-X-P0906'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
apiVersion: helm.cattle.io/v1
|
||||
kind: HelmChart
|
||||
metadata:
|
||||
name: exporter-mrzcpd
|
||||
name: mrzcpd-exporter
|
||||
namespace: kube-system
|
||||
spec:
|
||||
chart: https://%{KUBERNETES_API}%/static/charts/exporter-mrzcpd-1.0.1.tgz
|
||||
|
||||
24
ansible/roles/k3s-exporter/files/systemd/helm/Chart.yaml
Normal file
24
ansible/roles/k3s-exporter/files/systemd/helm/Chart.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
apiVersion: v2
|
||||
name: systemd-exporter
|
||||
description: A Helm chart for Kubernetes
|
||||
|
||||
# A chart can be either an 'application' or a 'library' chart.
|
||||
#
|
||||
# Application charts are a collection of templates that can be packaged into versioned archives
|
||||
# to be deployed.
|
||||
#
|
||||
# Library charts provide useful utilities or functions for the chart developer. They're included as
|
||||
# a dependency of application charts to inject those utilities and functions into the rendering
|
||||
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
||||
type: application
|
||||
|
||||
# This is the chart version. This version number should be incremented each time you make changes
|
||||
# to the chart and its templates, including the app version.
|
||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||
version: 0.1.0
|
||||
|
||||
# This is the version number of the application being deployed. This version number should be
|
||||
# incremented each time you make changes to the application. Versions are not expected to
|
||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||
# It is recommended to use it with quotes.
|
||||
appVersion: "1.16.0"
|
||||
@@ -0,0 +1,62 @@
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "systemd-exporter.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "systemd-exporter.fullname" -}}
|
||||
{{- if .Values.fullnameOverride }}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride }}
|
||||
{{- if contains $name .Release.Name }}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "systemd-exporter.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "systemd-exporter.labels" -}}
|
||||
helm.sh/chart: {{ include "systemd-exporter.chart" . }}
|
||||
{{ include "systemd-exporter.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "systemd-exporter.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "systemd-exporter.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "systemd-exporter.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "systemd-exporter.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,33 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: systemd-exporter
|
||||
name: systemd-exporter
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: systemd-exporter
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: systemd-exporter
|
||||
spec:
|
||||
hostNetwork: true
|
||||
containers:
|
||||
- env:
|
||||
- name: MERGER_URLS
|
||||
value: {{ .Values.exporter.urls }}
|
||||
- name: MERGER_PORT
|
||||
value: "{{ .Values.exporter.port }}"
|
||||
image: "{{ .Values.exporter.image.repository }}:{{ .Values.exporter.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.exporter.image.pullPolicy }}
|
||||
name: exporter
|
||||
ports:
|
||||
- name: ex-systemd-port
|
||||
containerPort: {{ .Values.exporter.port }}
|
||||
protocol: TCP
|
||||
@@ -0,0 +1,24 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: systemd-exporter
|
||||
name: systemd-exporter
|
||||
{{- with .Values.service.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- name: systemd-exporter-port
|
||||
{{- if .Values.service.nodePort }}
|
||||
nodePort: {{ .Values.service.nodePort }}
|
||||
{{- end }}
|
||||
port: {{ .Values.service.port }}
|
||||
targetPort: ex-systemd-port
|
||||
selector:
|
||||
app: systemd-exporter
|
||||
type: {{ .Values.service.type }}
|
||||
|
||||
13
ansible/roles/k3s-exporter/files/systemd/helm/values.yaml
Normal file
13
ansible/roles/k3s-exporter/files/systemd/helm/values.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
exporter:
|
||||
image:
|
||||
repository: quay.io/rebuy/exporter-merger
|
||||
pullPolicy: Never
|
||||
tag: "v0.2.0"
|
||||
port: "9008"
|
||||
urls: "http://127.0.0.1:9558/metrics"
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
# nodePort: "30081"
|
||||
port: "9008"
|
||||
annotations: {}
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: helm.cattle.io/v1
|
||||
kind: HelmChart
|
||||
metadata:
|
||||
name: systemd-exporter
|
||||
namespace: kube-system
|
||||
spec:
|
||||
chart: https://%{KUBERNETES_API}%/static/charts/systemd-exporter-1.0.1.tgz
|
||||
targetNamespace: tsg-os-system
|
||||
valuesContent: |-
|
||||
service:
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
|
||||
@@ -44,12 +44,12 @@
|
||||
- prometheus.tar
|
||||
- kube-state-metrics.tar
|
||||
|
||||
#### mrzcpd exporter start
|
||||
- name: "copy chart directory to dest"
|
||||
copy:
|
||||
src: "{{ role_path }}/files/mrzcpd/helm"
|
||||
dest: /tmp/exporter-mrzcpd/
|
||||
|
||||
#### mrzcpd exporter start
|
||||
- name: "create charts packages"
|
||||
shell: helm package --app-version 1.0.1 --version 1.0.1 -d /var/lib/rancher/k3s/server/static/charts/ /tmp/exporter-mrzcpd/helm
|
||||
|
||||
@@ -78,4 +78,20 @@
|
||||
src: "{{ role_path }}/files/mrzcpd/exporter-mrzcpd-crd.yaml"
|
||||
dest: /var/lib/rancher/k3s/server/manifests/exporter-mrzcpd-crd.yaml
|
||||
|
||||
#### mrzcpd exporter end
|
||||
#### mrzcpd exporter end
|
||||
|
||||
#### systemd exporter start
|
||||
- name: "copy chart directory to dest"
|
||||
copy:
|
||||
src: "{{ role_path }}/files/systemd/helm"
|
||||
dest: /tmp/systemd-exporter/
|
||||
|
||||
- name: "create charts packages"
|
||||
shell: helm package --app-version 1.0.1 --version 1.0.1 -d /var/lib/rancher/k3s/server/static/charts/ /tmp/systemd-exporter/helm
|
||||
|
||||
- name: "copy systemd-exporter-crd.yaml to dest"
|
||||
copy:
|
||||
src: "{{ role_path }}/files/systemd/systemd-exporter-crd.yaml"
|
||||
dest: /var/lib/rancher/k3s/server/manifests/systemd-exporter-crd.yaml
|
||||
|
||||
#### systemd exporter end
|
||||
|
||||
Reference in New Issue
Block a user