-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from ricsanfre/prometheus
Adding kube Prometheus stack
- Loading branch information
Showing
9 changed files
with
496 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
|
||
# Storage Settings | ||
prometheus_storage_size: "5Gi" | ||
prometheus_storage_class: "longhorn" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
- name: Create prometheus namespace. | ||
kubernetes.core.k8s: | ||
name: k3s-monitoring | ||
api_version: v1 | ||
kind: Namespace | ||
state: present | ||
|
||
- name: Add prometheus community chart repo. | ||
kubernetes.core.helm_repository: | ||
name: prometheus-community | ||
repo_url: "https://prometheus-community.github.io/helm-charts" | ||
|
||
- name: Deploy prometheus-stack Helm chart. | ||
kubernetes.core.helm: | ||
name: kube-prometheus-stack | ||
chart_ref: prometheus-community/kube-prometheus-stack | ||
release_namespace: k3s-monitoring | ||
state: present | ||
release_values: | ||
alertmanager: | ||
alertmanagerSpec: | ||
storage: | ||
volumeClaimTemplate: | ||
spec: | ||
storageClassName: "{{ prometheus_storage_class }}" | ||
accessModes: ["ReadWriteOnce"] | ||
resources: | ||
requests: | ||
storage: "{{ prometheus_storage_size }}" | ||
prometheus: | ||
prometheusSpec: | ||
storageSpec: | ||
volumeClaimTemplate: | ||
spec: | ||
storageClassName: "{{ prometheus_storage_class }}" | ||
accessModes: ["ReadWriteOnce"] | ||
resources: | ||
requests: | ||
storage: "{{ prometheus_storage_size }}" | ||
|
||
- name: Create Ingress rule for Prometheus, Alertmanager and Graphana UI | ||
kubernetes.core.k8s: | ||
definition: "{{ lookup('template', 'templates/' + item ) }}" | ||
state: present | ||
with_items: | ||
- prometheus_ingress.yml | ||
- grafana_ingress.yml | ||
- alertmanager_ingress.yml |
58 changes: 58 additions & 0 deletions
58
ansible/roles/prometheus/templates/alertmanager_ingress.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
# HTTPS Ingress | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: alertmanager-ingress | ||
namespace: k3s-monitoring | ||
annotations: | ||
# HTTPS as entry point | ||
traefik.ingress.kubernetes.io/router.entrypoints: websecure | ||
# Enable TLS | ||
traefik.ingress.kubernetes.io/router.tls: "true" | ||
# Use Basic Auth Midleware configured | ||
traefik.ingress.kubernetes.io/router.middlewares: traefik-system-basic-auth@kubernetescrd | ||
# Enable cert-manager to create automatically the SSL certificate and store in Secret | ||
cert-manager.io/cluster-issuer: self-signed-issuer | ||
cert-manager.io/common-name: alertmanager | ||
spec: | ||
tls: | ||
- hosts: | ||
- alertmanager.picluster.ricsanfre.com | ||
secretName: prometheus-tls | ||
rules: | ||
- host: alertmanager.picluster.ricsanfre.com | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: kube-prometheus-stack-alertmanager | ||
port: | ||
number: 9093 | ||
|
||
--- | ||
# http ingress for http->https redirection | ||
kind: Ingress | ||
apiVersion: networking.k8s.io/v1 | ||
metadata: | ||
name: alertmanager-redirect | ||
namespace: k3s-monitoring | ||
annotations: | ||
# Use redirect Midleware configured | ||
traefik.ingress.kubernetes.io/router.middlewares: traefik-system-redirect@kubernetescrd | ||
# HTTP as entrypoint | ||
traefik.ingress.kubernetes.io/router.entrypoints: web | ||
spec: | ||
rules: | ||
- host: alertmanager.picluster.ricsanfre.com | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: kube-prometheus-stack-alertmanager | ||
port: | ||
number: 9093 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
# HTTPS Ingress | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: grafana-ingress | ||
namespace: k3s-monitoring | ||
annotations: | ||
# HTTPS as entry point | ||
traefik.ingress.kubernetes.io/router.entrypoints: websecure | ||
# Enable TLS | ||
traefik.ingress.kubernetes.io/router.tls: "true" | ||
# Enable cert-manager to create automatically the SSL certificate and store in Secret | ||
cert-manager.io/cluster-issuer: self-signed-issuer | ||
cert-manager.io/common-name: grafana | ||
spec: | ||
tls: | ||
- hosts: | ||
- grafana.picluster.ricsanfre.com | ||
secretName: grafana-tls | ||
rules: | ||
- host: grafana.picluster.ricsanfre.com | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: kube-prometheus-stack-grafana | ||
port: | ||
number: 80 | ||
|
||
--- | ||
# http ingress for http->https redirection | ||
kind: Ingress | ||
apiVersion: networking.k8s.io/v1 | ||
metadata: | ||
name: grafana-redirect | ||
namespace: k3s-monitoring | ||
annotations: | ||
# Use redirect Midleware configured | ||
traefik.ingress.kubernetes.io/router.middlewares: traefik-system-redirect@kubernetescrd | ||
# HTTP as entrypoint | ||
traefik.ingress.kubernetes.io/router.entrypoints: web | ||
spec: | ||
rules: | ||
- host: grafana.picluster.ricsanfre.com | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: kube-prometheus-stack-grafana | ||
port: | ||
number: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
# HTTPS Ingress | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: prometheus-ingress | ||
namespace: k3s-monitoring | ||
annotations: | ||
# HTTPS as entry point | ||
traefik.ingress.kubernetes.io/router.entrypoints: websecure | ||
# Enable TLS | ||
traefik.ingress.kubernetes.io/router.tls: "true" | ||
# Use Basic Auth Midleware configured | ||
traefik.ingress.kubernetes.io/router.middlewares: traefik-system-basic-auth@kubernetescrd | ||
# Enable cert-manager to create automatically the SSL certificate and store in Secret | ||
cert-manager.io/cluster-issuer: self-signed-issuer | ||
cert-manager.io/common-name: prometheus | ||
spec: | ||
tls: | ||
- hosts: | ||
- prometheus.picluster.ricsanfre.com | ||
secretName: prometheus-tls | ||
rules: | ||
- host: prometheus.picluster.ricsanfre.com | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: kube-prometheus-stack-prometheus | ||
port: | ||
number: 9090 | ||
|
||
--- | ||
# http ingress for http->https redirection | ||
kind: Ingress | ||
apiVersion: networking.k8s.io/v1 | ||
metadata: | ||
name: prometheus-redirect | ||
namespace: k3s-monitoring | ||
annotations: | ||
# Use redirect Midleware configured | ||
traefik.ingress.kubernetes.io/router.middlewares: traefik-system-redirect@kubernetescrd | ||
# HTTP as entrypoint | ||
traefik.ingress.kubernetes.io/router.entrypoints: web | ||
spec: | ||
rules: | ||
- host: prometheus.picluster.ricsanfre.com | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: kube-prometheus-stack-prometheus | ||
port: | ||
number: 9090 |
Oops, something went wrong.