Add node-name label
This commit is contained in:
parent
dccf1aea6a
commit
a8012ce51d
19
app/main.py
19
app/main.py
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
# https://pimylifeup.com/raspberry-pi-temperature/
|
# https://pimylifeup.com/raspberry-pi-temperature/
|
||||||
|
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@ -11,12 +12,25 @@ REGISTRY.unregister(GC_COLLECTOR)
|
|||||||
REGISTRY.unregister(PLATFORM_COLLECTOR)
|
REGISTRY.unregister(PLATFORM_COLLECTOR)
|
||||||
REGISTRY.unregister(PROCESS_COLLECTOR)
|
REGISTRY.unregister(PROCESS_COLLECTOR)
|
||||||
|
|
||||||
|
|
||||||
def setup_gauge():
|
def setup_gauge():
|
||||||
g = Gauge(f'sys_cpu_temp_celsius_degrees', 'CPU Temperature')
|
g = Gauge(f'sys_cpu_temp_celsius_degrees', 'CPU Temperature', ['node_name'])
|
||||||
g.set_function(_get_temp)
|
g.set_function(_get_temp)
|
||||||
|
g.labels(_get_node_name())
|
||||||
|
|
||||||
|
|
||||||
def _get_temp():
|
def _get_temp():
|
||||||
return float(subprocess.run(['/usr/bin/vcgencmd', 'measure_temp'], capture_output=True).stdout.decode('utf-8').replace('temp=', '').replace("'C\n", ''))
|
return float(subprocess.run(['/usr/bin/vcgencmd', 'measure_temp'], capture_output=True).stdout.decode('utf-8')
|
||||||
|
.replace('temp=', '').replace("'C\n", ''))
|
||||||
|
|
||||||
|
|
||||||
|
def _get_node_name():
|
||||||
|
# https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/
|
||||||
|
try:
|
||||||
|
return os.environ['NODE_NAME']
|
||||||
|
except:
|
||||||
|
return 'unknown-node'
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setup_gauge()
|
setup_gauge()
|
||||||
@ -24,4 +38,3 @@ if __name__ == '__main__':
|
|||||||
while True:
|
while True:
|
||||||
# Stay alive!
|
# Stay alive!
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
@ -25,6 +25,11 @@ spec:
|
|||||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
env:
|
||||||
|
- name: NODE_NAME
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: spec.nodeName
|
||||||
ports:
|
ports:
|
||||||
- name: prometheus
|
- name: prometheus
|
||||||
containerPort: 8555
|
containerPort: 8555
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
replicaCount: 1
|
replicaCount: 1
|
||||||
|
|
||||||
image:
|
image:
|
||||||
repository: nginx
|
repository: "gitea.scubbo.org/scubbo/pi-temperature-monitoring"
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
# Overrides the image tag whose default is the chart appVersion.
|
# Overrides the image tag whose default is the chart appVersion.
|
||||||
tag: ""
|
tag: ""
|
||||||
@ -14,15 +14,6 @@ imagePullSecrets: []
|
|||||||
nameOverride: ""
|
nameOverride: ""
|
||||||
fullnameOverride: ""
|
fullnameOverride: ""
|
||||||
|
|
||||||
serviceAccount:
|
|
||||||
# Specifies whether a service account should be created
|
|
||||||
create: true
|
|
||||||
# Annotations to add to the service account
|
|
||||||
annotations: {}
|
|
||||||
# The name of the service account to use.
|
|
||||||
# If not set and create is true, a name is generated using the fullname template
|
|
||||||
name: ""
|
|
||||||
|
|
||||||
podAnnotations: {}
|
podAnnotations: {}
|
||||||
|
|
||||||
podSecurityContext: {}
|
podSecurityContext: {}
|
||||||
@ -68,13 +59,6 @@ resources: {}
|
|||||||
# cpu: 100m
|
# cpu: 100m
|
||||||
# memory: 128Mi
|
# memory: 128Mi
|
||||||
|
|
||||||
autoscaling:
|
|
||||||
enabled: false
|
|
||||||
minReplicas: 1
|
|
||||||
maxReplicas: 100
|
|
||||||
targetCPUUtilizationPercentage: 80
|
|
||||||
# targetMemoryUtilizationPercentage: 80
|
|
||||||
|
|
||||||
nodeSelector: {}
|
nodeSelector: {}
|
||||||
|
|
||||||
tolerations: []
|
tolerations: []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user