---
# System prepended metadata

title: slurm-exporter
tags: [k8s, slurm-exporter, slurm, app, SlinkyProject, Kubernetes]

---

slurm-exporter
===
###### tags: `SlinkyProject`
###### tags: `Kubernetes`, `k8s`, `app`, `slurm`, `SlinkyProject`, `slurm-exporter`

<br>

[TOC]

<br>

## Intro

- ### github
    > https://github.com/SlinkyProject/slurm-exporter

- ### Helm Chart
    > https://github.com/SlinkyProject/slurm-exporter/tree/main/helm/slurm-exporter
    
    - `values.yaml`
        > https://github.com/SlinkyProject/slurm-exporter/blob/main/helm/slurm-exporter/values.yaml
    - `service-monitor.yaml`
        > https://github.com/SlinkyProject/slurm-exporter/blob/main/helm/slurm-exporter/templates/metrics/service-monitor.yaml

- ### 教學範本
    - [[HackMD] 教學範本：slurm-exporter 串接 Prometheus](/zt5I9GvXSVOYVA2Er6hzmQ)

<br>

---

## Q & A

### Slurm Cluster 如何引入 `slurm-exporter` project?
- ### `Chart.yaml`
    > https://github.com/SlinkyProject/slurm-operator/blob/main/helm/slurm/Chart.yaml#L27-L31

    ```yaml=27
    dependencies:  <-- 引入相依專案
      - name: slurm-exporter
        repository: oci://ghcr.io/slinkyproject/charts
        version: 0.3.1
        condition: slurm-exporter.enabled <-- 引入條件
    ```
    - ### 引入 `slurm-exporter` 專案的條件：
        - `slurm-exporter.enabled`
            > https://github.com/SlinkyProject/slurm-operator/blob/main/helm/slurm/values.yaml#L272
            > ![](https://hackmd.io/_uploads/B1rf0byigl.png)

<br>

---

### ServiceMonitor 能擴充 labels ？ -> 不行
- ### `metadata.labels`
    > https://github.com/SlinkyProject/slurm-exporter/blob/main/helm/slurm-exporter/templates/metrics/service-monitor.yaml#L9-L13
    > ![](https://hackmd.io/_uploads/rJATRZkjlg.png)
    > labels 清單，取決於：`slurm-exporter.labels` function

- ### `slurm-exporter.labels`
    > https://github.com/SlinkyProject/slurm-exporter/blob/main/helm/slurm-exporter/templates/_helpers.tpl#L34-L45
    > ![](https://hackmd.io/_uploads/HylS1zJjge.png)
    
    - **render 結果**
        ```yaml
        helm.sh/chart: slurm-exporter-0.4.0
        app.kubernetes.io/version: "25.05"
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/component: slurm-exporter
        ```
        - 剩餘 labels ，取決於：`slurm-exporter.selectorLabels` function

- ### `slurm-exporter.selectorLabels`
    > https://github.com/SlinkyProject/slurm-exporter/blob/main/helm/slurm-exporter/templates/_helpers.tpl#L55-L61
    > ![](https://hackmd.io/_uploads/SkDn1M1ile.png)
    - **render 結果**
        ```yaml
        app.kubernetes.io/name: slurm-exporter
        app.kubernetes.io/instance: slurm-exporter
        ```
        - `slurm-exporter.name`
            > https://github.com/SlinkyProject/slurm-exporter/blob/main/helm/slurm-exporter/templates/_helpers.tpl#L6-L11
            - `.Chart.Name`
                > https://github.com/SlinkyProject/slurm-exporter/blob/main/helm/slurm-exporter/Chart.yaml#L8
- ### 最終 render 結果
    ```
    helm.sh/chart: slurm-exporter-0.4.0
    app.kubernetes.io/version: "25.05"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: slurm-exporter
    app.kubernetes.io/name: slurm-exporter
    app.kubernetes.io/instance: slurm-exporter
    ```
- ### 結論
    都是內建的 labels，Chart 並沒有額外開出給 user 來自定義 `ServiceMonitor` labels

<br>

{%hackmd vaaMgNRPS4KGJDSFG0ZE0w %}
