Skip to content

Kubernetes Template

madejackson edited this page Sep 18, 2024 · 1 revision

Kubernetes template

This template makes use of kubernetes configMaps, Generic Device Plugin and Reloader from Stakater to have all the config in one file. You DON'T need to mount any device or volume manually.

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ha-enoceanmqtt
  namespace: smarthome
  annotations:
    reloader.stakater.com/auto: "true"
spec:
  selector:
    matchLabels:
      app: ha-enoceanmqtt
  replicas: 1
  progressDeadlineSeconds: 600
  revisionHistoryLimit: 2
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: ha-enoceanmqtt
      annotations:
        deploy-date: "deploy-date-value"
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: feature.node.kubernetes.io/usb-ff_0403_6001.present
                operator: In
                values:
                - "true"
    spec:
      containers:
        - name: ha-enoceanmqtt
          image: ghcr.io/aseracorp/ha_enoceanmqtt
          env:
            - name: TZ
              value: "${TIMEZONE}"
          resources:
            limits:
              squat.ai/serial: 1
          volumeMounts:
            - mountPath: /config/enoceanmqtt.conf
              subPath: enoceanmqtt.conf
              name: ha-enoceanmqtt-config
              readOnly: true
      volumes:
        - name: ha-enoceanmqtt-config
          configMap:
            name: ha-enoceanmqtt-config
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: ha-enoceanmqtt-config
  namespace: smarthome
data:
  enoceanmqtt.conf: |-
    ## the general section defines parameter for the mqtt broker and the enocean interface
    [CONFIG]
    enocean_port    = /dev/ttyUSB0
    log_packets     = 1
    overlay         = HA
    #mapping_file    = /config/mapping.yaml # Uncomment if you want to use a custom mapping.yaml file
    #db_file         = /config/devices.db   # Uncomment if you want to specify another location for the device database

    ## the discovery prefix is used by MQTT discovery in Home Assistant
    mqtt_discovery_prefix = homeassistant/

    mqtt_host       = CHANGEME
    mqtt_port       = 1883
    mqtt_client_id  = enocean_gateway   # ensure that this is unique if you use multiple clients

    ## setting mqtt_keepalive = 0 sets the timeout to infinitive but does not work reliably
    ## due to an upstream issue https://github.com/eclipse/paho.mqtt.python/issues/473
    mqtt_keepalive  = 60

    ## the prefix is used for the mqtt value names; this is extended by the sensor name
    mqtt_prefix     = enoceanmqtt/

    # Set mqtt_user and mqtt_pwd (don't use quotes).
    mqtt_user       = CHANGEME
    mqtt_pwd        = CHANGEME

    ## enable SSL on MQTT connection
    ## Ensure that mqtt_host matches one of the hostnames contained in the broker's
    ## certificate, otherwise the client will refuse to connect.
    ##
    ## mqtt_ssl_ca_certs: CA certificates to be treated as trusted. Required if
    ##     the MQTT broker is configured with a self-signed certificate.
    ## mqtt_ssl_certfile, mqtt_ssl_keyfile: Client certificate and private key.
    ##     Only required if the broker requires clients to present a certificate.
    ## mqtt_ssl_insecure: Disable verification of the broker's certificate.
    ##     WARNING: do NOT use on production systems as this is insecure!
    ##
    # mqtt_ssl          = true
    # mqtt_ssl_ca_certs = /path/CA_files_merged.pem
    # mqtt_ssl_certfile = /path/client_cert.pem
    # mqtt_ssl_keyfile  = /path/client_key.pem
    # mqtt_ssl_insecure = true

    ## Enable/Disable MQTT debugging. Requires --debug on the command line.
    mqtt_debug      = false


    ## all other sections define the sensors to monitor

    *** ADD YOUR SENSORS HERE ***