Skip to content

Commit 3a7b665

Browse files
committed
Playbook to install kube-prometheus-stack
1 parent 2fdcb58 commit 3a7b665

File tree

4 files changed

+144
-0
lines changed

4 files changed

+144
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
- name: Ensure kubernetes.core collection is installed
3+
hosts: masters
4+
gather_facts: no
5+
tasks:
6+
- name: Install required Ansible collection
7+
ansible.builtin.command:
8+
cmd: ansible-galaxy collection install kubernetes.core
9+
changed_when: false
10+
delegate_to: "{{ groups['masters'][0] }}"
11+
12+
- name: Install Helm
13+
hosts: masters
14+
become: yes
15+
tasks:
16+
- name: Download Helm install script
17+
ansible.builtin.get_url:
18+
url: https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
19+
dest: /tmp/get_helm.sh
20+
mode: '0700'
21+
delegate_to: "{{ groups['masters'][0] }}"
22+
23+
- name: Run Helm install script
24+
ansible.builtin.command: /tmp/get_helm.sh
25+
args:
26+
chdir: /tmp
27+
delegate_to: "{{ groups['masters'][0] }}"
28+
29+
- name: Deploy kube-prometheus-stack to Kubernetes
30+
hosts: masters
31+
become: yes
32+
roles:
33+
- install-monitoring
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
---
3+
helm_release_name: k8s-monitoring
4+
helm_chart_name: prometheus-community/kube-prometheus-stack
5+
helm_chart_version: "78.4.0"
6+
helm_namespace: monitoring
7+
helm_repo_name: prometheus-community
8+
helm_repo_url: https://prometheus-community.github.io/helm-charts
9+
helm_custom_values: "power-custom-values.yaml"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
grafana:
2+
image:
3+
registry: docker.io
4+
repository: sats23/sats
5+
tag: ppcgrafana
6+
pullPolicy: IfNotPresent
7+
8+
service:
9+
type: NodePort
10+
portName: http-web
11+
ipFamilies: []
12+
ipFamilyPolicy: ""
13+
port: 3000
14+
targetPort: 3000
15+
16+
adminUser: admin
17+
adminPassword: prom-operator
18+
19+
nodeSelector:
20+
kubernetes.io/role: infra
21+
22+
prometheusOperator:
23+
admissionWebhooks:
24+
deployment:
25+
nodeSelector:
26+
kubernetes.io/role: infra
27+
28+
patch:
29+
enabled: true
30+
image:
31+
registry: docker.io
32+
repository: sats23/sats
33+
tag: kube-webhook-certgen-ppc64le
34+
35+
nodeSelector:
36+
kubernetes.io/role: infra
37+
38+
prometheus:
39+
prometheusSpec:
40+
retention: 14d
41+
nodeSelector:
42+
kubernetes.io/role: infra
43+
44+
crds:
45+
upgradeJob:
46+
nodeSelector:
47+
kubernetes.io/role: infra
48+
49+
alertmanager:
50+
alertmanagerSpec:
51+
nodeSelector:
52+
kubernetes.io/role: infra
53+
54+
kube-state-metrics:
55+
nodeSelector:
56+
kubernetes.io/role: infra
57+
58+
thanosRuler:
59+
thanosRulerSpec:
60+
nodeSelector:
61+
kubernetes.io/role: infra
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
- name: Ensure namespace exists
3+
ansible.builtin.command: kubectl create namespace {{ helm_namespace }}
4+
ignore_errors: yes # Ignore error if namespace already exists
5+
6+
- name: Ensure Helm repository is added
7+
kubernetes.core.helm_repository:
8+
name: "{{ helm_repo_name }}"
9+
repo_url: "{{ helm_repo_url }}"
10+
state: present
11+
delegate_to: "{{ groups['masters'][0] }}"
12+
13+
- name: Download the default values of helm chart
14+
ansible.builtin.get_url:
15+
url: "https://raw.githubusercontent.com/prometheus-community/helm-charts/kube-prometheus-stack-78.4.0/charts/kube-prometheus-stack/values.yaml"
16+
dest: "/tmp/default-values.yaml"
17+
mode: '0644'
18+
19+
- name: Copy IBM Power specific helm chart values files
20+
copy:
21+
src: "{{ helm_custom_values }}"
22+
dest: /tmp/
23+
24+
- name: Install or upgrade kube-prometheus-stack chart
25+
kubernetes.core.helm:
26+
update_repo_cache: yes
27+
name: "{{ helm_release_name }}"
28+
chart_ref: "{{ helm_chart_name }}"
29+
namespace: "{{ helm_namespace }}"
30+
chart_version: "{{ helm_chart_version }}"
31+
values_files:
32+
- "/tmp/power-custom-values.yaml"
33+
timeout: 10m
34+
set_values:
35+
- value: grafana.adminUser="{{ grafana_admin_user }}"
36+
value_type: string
37+
- value: grafana.adminPassword="{{ grafana_admin_password }}"
38+
value_type: string
39+
state: present
40+
delegate_to: "{{ groups['masters'][0] }}"
41+

0 commit comments

Comments
 (0)