feat: add prometheus manifest

This commit is contained in:
2026-06-14 14:42:02 +02:00
parent 79ce4f928c
commit d18ed0799c
3 changed files with 79 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
---
- name: Install initial dependencies
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
state: present
update_cache: yes
- name: Add Docker official GPG key
apt_key:
url: https://download.docker.com/linux/debian/gpg
state: present
- name: Set up Docker repository for ARM architecture
apt_repository:
repo: "deb [arch={{ 'arm64' if ansible_architecture == 'aarch64' else 'armhf' }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
state: present
- name: Install Docker Engine and CLI components
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
state: present
update_cache: yes
- name: Ensure Docker service is started and enabled
systemd:
name: docker
state: started
enabled: yes
- name: Add current user to docker group
user:
name: "{{ ansible_user }}"
groups: docker
append: yes

View File

@@ -0,0 +1,13 @@
- name: Download and execute K3s installation script with monitoring metrics enabled
shell: |
curl -sfL https://get.k3s.io | sh -
environment:
INSTALL_K3S_EXEC: "--server --write-kubeconfig-mode 644 --kube-controller-manager-arg bind-address=0.0.0.0 --kube-proxy-arg metrics-bind-address=0.0.0.0 --kube-scheduler-arg bind-address=0.0.0.0"
args:
creates: /usr/local/bin/k3s
- name: Ensure K3s service is started and enabled
systemd:
name: k3s
state: started
enabled: yes

View File

@@ -0,0 +1,24 @@
- name: Create monitoring namespace
kubernetes.core.k8s:
name: monitoring
kind: Namespace
state: present
- name: Add Prometheus community Helm repository
kubernetes.core.helm_repository:
name: prometheus-community
repo_url: "https://prometheus-community.github.io/helm-charts"
- name: Copy Prometheus customization values
template:
src: values.yml.j2
dest: /tmp/prometheus-values.yml
- name: Deploy kube-prometheus-stack via Helm
kubernetes.core.helm:
name: kube-prometheus-stack
chart_ref: prometheus-community/kube-prometheus-stack
release_namespace: monitoring
values_files:
- /tmp/prometheus-values.yml
state: present