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/
|
||||
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
|
||||
@ -11,12 +12,25 @@ REGISTRY.unregister(GC_COLLECTOR)
|
||||
REGISTRY.unregister(PLATFORM_COLLECTOR)
|
||||
REGISTRY.unregister(PROCESS_COLLECTOR)
|
||||
|
||||
|
||||
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.labels(_get_node_name())
|
||||
|
||||
|
||||
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__':
|
||||
setup_gauge()
|
||||
@ -24,4 +38,3 @@ if __name__ == '__main__':
|
||||
while True:
|
||||
# Stay alive!
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -25,6 +25,11 @@ spec:
|
||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
ports:
|
||||
- name: prometheus
|
||||
containerPort: 8555
|
||||
|
@ -5,7 +5,7 @@
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: nginx
|
||||
repository: "gitea.scubbo.org/scubbo/pi-temperature-monitoring"
|
||||
pullPolicy: IfNotPresent
|
||||
# Overrides the image tag whose default is the chart appVersion.
|
||||
tag: ""
|
||||
@ -14,15 +14,6 @@ imagePullSecrets: []
|
||||
nameOverride: ""
|
||||
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: {}
|
||||
|
||||
podSecurityContext: {}
|
||||
@ -68,13 +59,6 @@ resources: {}
|
||||
# cpu: 100m
|
||||
# memory: 128Mi
|
||||
|
||||
autoscaling:
|
||||
enabled: false
|
||||
minReplicas: 1
|
||||
maxReplicas: 100
|
||||
targetCPUUtilizationPercentage: 80
|
||||
# targetMemoryUtilizationPercentage: 80
|
||||
|
||||
nodeSelector: {}
|
||||
|
||||
tolerations: []
|
||||
|
Loading…
x
Reference in New Issue
Block a user