From 03cdf9f355a65a1d3aa7fbe15289870cc06f80c4 Mon Sep 17 00:00:00 2001 From: Nik Afiq Date: Mon, 9 Mar 2026 21:48:07 +0900 Subject: [PATCH] Add Glances deployment and configuration for Debian and Kubernetes --- ansible/playbooks/setup-glances-debian.yaml | 13 +++ ansible/roles/glances/handlers/main.yaml | 6 ++ ansible/roles/glances/tasks/main.yaml | 35 ++++++++ config/dashy/conf.yml | 53 ++++++------ manifests/glances-debian-ingress.yaml | 49 +++++++++++ manifests/glances.yaml | 94 +++++++++++++++++++++ values/pihole.yaml | 4 +- 7 files changed, 225 insertions(+), 29 deletions(-) create mode 100644 ansible/playbooks/setup-glances-debian.yaml create mode 100644 ansible/roles/glances/handlers/main.yaml create mode 100644 ansible/roles/glances/tasks/main.yaml create mode 100644 manifests/glances-debian-ingress.yaml create mode 100644 manifests/glances.yaml diff --git a/ansible/playbooks/setup-glances-debian.yaml b/ansible/playbooks/setup-glances-debian.yaml new file mode 100644 index 0000000..8cf0047 --- /dev/null +++ b/ansible/playbooks/setup-glances-debian.yaml @@ -0,0 +1,13 @@ +--- +# Run: ansible-playbook ansible/playbooks/setup-glances-debian.yaml +# +# What this does: +# - Deploys Glances on Debian as a Docker container +# - Accessible at http://192.168.7.183:61208 + +- name: Deploy Glances on Debian + hosts: debian + gather_facts: true + + roles: + - glances \ No newline at end of file diff --git a/ansible/roles/glances/handlers/main.yaml b/ansible/roles/glances/handlers/main.yaml new file mode 100644 index 0000000..27003d4 --- /dev/null +++ b/ansible/roles/glances/handlers/main.yaml @@ -0,0 +1,6 @@ +--- +- name: Restart Glances container + community.docker.docker_container: + name: glances + state: started + restart: true \ No newline at end of file diff --git a/ansible/roles/glances/tasks/main.yaml b/ansible/roles/glances/tasks/main.yaml new file mode 100644 index 0000000..73064fd --- /dev/null +++ b/ansible/roles/glances/tasks/main.yaml @@ -0,0 +1,35 @@ +--- +- name: Create Glances config directory + ansible.builtin.file: + path: /etc/glances + state: directory + mode: "0755" + become: true + +- name: Write Glances config + ansible.builtin.copy: + dest: /etc/glances/glances.conf + content: | + [fs] + hide=/etc/.*,/boot.* + mode: "0644" + become: true + notify: Restart Glances container + +- name: Run Glances container + community.docker.docker_container: + name: glances + image: nicolargo/glances:latest-full + state: started + restart_policy: unless-stopped + pid_mode: host + network_mode: host + privileged: true + env: + GLANCES_OPT: "-w --config /etc/glances/glances.conf" + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - /proc:/proc:ro + - /sys:/sys:ro + - /mnt:/mnt:ro + - /etc/glances:/etc/glances:ro \ No newline at end of file diff --git a/config/dashy/conf.yml b/config/dashy/conf.yml index 41b2727..580a274 100644 --- a/config/dashy/conf.yml +++ b/config/dashy/conf.yml @@ -75,53 +75,50 @@ sections: cols: 2 collapsed: false hideForGuests: false - - name: System + - name: System — Minisforum icon: mdi-server widgets: - type: gl-current-cpu - label: CPU (current) + label: CPU options: - hostname: http://nik4nao.home.arpa:61208 + hostname: https://glances.home.arpa apiVersion: 4 - id: 0_645_glcurrentcpu - type: gl-current-mem - label: Memory (current) + label: Memory options: - hostname: http://nik4nao.home.arpa:61208 + hostname: https://glances.home.arpa apiVersion: 4 - id: 1_645_glcurrentmem - type: gl-cpu-history - label: CPU (history) + label: CPU History options: - hostname: http://nik4nao.home.arpa:61208 + hostname: https://glances.home.arpa apiVersion: 4 limit: 60 - id: 2_645_glcpuhistory - type: gl-mem-history - label: Memory (history) + label: Memory History options: - hostname: http://nik4nao.home.arpa:61208 + hostname: https://glances.home.arpa apiVersion: 4 - limit: 80 - id: 3_645_glmemhistory - displayData: - sortBy: default - rows: 10 - cols: 1 - collapsed: false - hideForGuests: false - - name: Storage + limit: 60 + + - name: System — Debian icon: mdi-harddisk widgets: - - type: gl-disk-space - label: Storage Pool (/mnt/storage) + - type: gl-current-cpu + label: CPU options: - hostname: http://nik4nao.home.arpa:61208 + hostname: https://glances-debian.home.arpa + apiVersion: 4 + - type: gl-current-mem + label: Memory + options: + hostname: https://glances-debian.home.arpa + apiVersion: 4 + - type: gl-disk-space + label: Debian Storage + options: + hostname: https://glances-debian.home.arpa apiVersion: 4 - id: 0_725_gldiskspace - displayData: - rows: 1 - cols: 1 - name: Shortcuts icon: mdi-bookmark-outline items: diff --git a/manifests/glances-debian-ingress.yaml b/manifests/glances-debian-ingress.yaml new file mode 100644 index 0000000..8db7a85 --- /dev/null +++ b/manifests/glances-debian-ingress.yaml @@ -0,0 +1,49 @@ +# Glances — Debian node, proxied via Traefik +# Apply: kubectl apply -f manifests/glances-debian-ingress.yaml +apiVersion: v1 +kind: Endpoints +metadata: + name: glances-debian + namespace: glances +subsets: + - addresses: + - ip: 192.168.7.183 + ports: + - port: 61208 +--- +apiVersion: v1 +kind: Service +metadata: + name: glances-debian + namespace: glances +spec: + ports: + - port: 61208 + targetPort: 61208 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: glances-debian + namespace: glances + annotations: + traefik.ingress.kubernetes.io/router.entrypoints: websecure + traefik.ingress.kubernetes.io/router.tls: "true" + cert-manager.io/cluster-issuer: internal-ca-issuer +spec: + ingressClassName: traefik + tls: + - secretName: glances-debian-tls + hosts: + - glances-debian.home.arpa + rules: + - host: glances-debian.home.arpa + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: glances-debian + port: + number: 61208 \ No newline at end of file diff --git a/manifests/glances.yaml b/manifests/glances.yaml new file mode 100644 index 0000000..7ec21fc --- /dev/null +++ b/manifests/glances.yaml @@ -0,0 +1,94 @@ +# Glances — system monitoring +# Apply: kubectl apply -f manifests/glances.yaml +apiVersion: v1 +kind: Namespace +metadata: + name: glances +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: glances + namespace: glances +spec: + selector: + matchLabels: + app: glances + template: + metadata: + labels: + app: glances + spec: + nodeSelector: + node-role: primary + hostPID: true + hostNetwork: true + containers: + - name: glances + image: nicolargo/glances:latest-full + ports: + - containerPort: 61208 + env: + - name: GLANCES_OPT + value: "-w" + securityContext: + privileged: true + volumeMounts: + - name: host-proc + mountPath: /proc + readOnly: true + - name: host-sys + mountPath: /sys + readOnly: true + - name: host-etc + mountPath: /etc/glances + readOnly: true + volumes: + - name: host-proc + hostPath: + path: /proc + - name: host-sys + hostPath: + path: /sys + - name: host-etc + hostPath: + path: /etc +--- +apiVersion: v1 +kind: Service +metadata: + name: glances + namespace: glances +spec: + selector: + app: glances + ports: + - port: 61208 + targetPort: 61208 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: glances + namespace: glances + annotations: + traefik.ingress.kubernetes.io/router.entrypoints: websecure + traefik.ingress.kubernetes.io/router.tls: "true" + cert-manager.io/cluster-issuer: internal-ca-issuer +spec: + ingressClassName: traefik + tls: + - secretName: glances-tls + hosts: + - glances.home.arpa + rules: + - host: glances.home.arpa + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: glances + port: + number: 61208 \ No newline at end of file diff --git a/values/pihole.yaml b/values/pihole.yaml index ffe4ea0..17a618b 100644 --- a/values/pihole.yaml +++ b/values/pihole.yaml @@ -76,4 +76,6 @@ dnsmasq: - address=/dashy.home.arpa/192.168.7.77 - address=/jellyfin.home.arpa/192.168.7.77 - address=/qbittorrent.home.arpa/192.168.7.77 - - address=/jdownloader.home.arpa/192.168.7.77 \ No newline at end of file + - address=/jdownloader.home.arpa/192.168.7.77 + - address=/glances.home.arpa/192.168.7.77 + - address=/glances-debian.home.arpa/192.168.7.77 \ No newline at end of file