-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README
- Loading branch information
Showing
21 changed files
with
295 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
# prometheus-operator-examples | ||
|
||
prometheus-operator example configs | ||
|
||
## Pre-requisites | ||
|
||
Create kind cluster or minikube cluster (examples in this repo are tested with minikube) | ||
|
||
```bash | ||
$ minikube delete && minikube start --kubernetes-version=v1.23.0 --memory=6g --bootstrapper=kubeadm --extra-config=kubelet.authentication-token-webhook=true --extra-config=kubelet.authorization-mode=Webhook --extra-config=scheduler.bind-address=0.0.0.0 --extra-config=controller-manager.bind-address=0.0.0.0 | ||
``` | ||
|
||
[kube-prometheus](https://github.com/prometheus-operator/kube-prometheus#quickstart) stack is configured in cluster before running any examples | ||
|
||
**Note:** The configs in this repo should be treated as examples only. This is not tested in production cluster. These examples can serve as a starting point for creating production ready configs |
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,18 @@ | ||
# Pod Monitor | ||
|
||
Monitor single or multiple pods | ||
|
||
Look at manifest files in respective directories | ||
|
||
- Create pod and pod monitors | ||
|
||
```bash | ||
kubectl apply -f ./single_pod | ||
``` | ||
|
||
```bash | ||
kubectl apply -f ./multiple_pods | ||
``` | ||
|
||
- Refresh prometheus target page it should show pod monitor targets | ||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,14 @@ | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PodMonitor | ||
metadata: | ||
name: multiple-pods-monitoring | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: multiple-pods-monitoring | ||
spec: | ||
selector: | ||
matchLabels: | ||
team: frontend | ||
podMetricsEndpoints: | ||
- port: web | ||
- port: metric |
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,15 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: pod-one | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: pod-one | ||
team: frontend | ||
spec: | ||
containers: | ||
- image: ghcr.io/rhobs/prometheus-example-app:0.4.1 | ||
name: prometheus-example-app | ||
ports: | ||
- name: web | ||
containerPort: 8080 |
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,15 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: pod-two | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: pod-two | ||
team: frontend | ||
spec: | ||
containers: | ||
- image: ghcr.io/rhobs/prometheus-example-app:0.4.1 | ||
name: prometheus-example-app | ||
ports: | ||
- name: metric | ||
containerPort: 8080 |
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,13 @@ | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PodMonitor | ||
metadata: | ||
name: single-instance-app | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: single-instance-app | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: single-instance-app | ||
podMetricsEndpoints: | ||
- port: web |
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,14 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: single-instance-app | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: single-instance-app | ||
spec: | ||
containers: | ||
- image: ghcr.io/rhobs/prometheus-example-app:0.4.1 | ||
name: prometheus-example-app | ||
ports: | ||
- name: web | ||
containerPort: 8080 |
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,43 @@ | ||
# Probe | ||
|
||
- Probe can be used to describe blackbox checks. Inorder to work with probe, blackbox_exporter has to be deployed | ||
|
||
- Monitor static targets or ingress | ||
|
||
- Look at manifest files in respective directories | ||
|
||
## Static Target Monitoring | ||
|
||
- Create probe | ||
|
||
```bash | ||
kubectl apply -f ./static_target | ||
``` | ||
|
||
- Refresh prometheus target page it should display probe ingress target | ||
|
||
 | ||
|
||
## Ingress Monitoring | ||
|
||
### Pre-requisites | ||
|
||
- Deploy Ingress Controller | ||
|
||
If using [minikube](https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/#enable-the-ingress-controller) simply enable ingress addon | ||
|
||
```bash | ||
minikube addons enable ingress | ||
``` | ||
|
||
### Monitor Ingress Object | ||
|
||
- Deploy app, create service, ingress and probe | ||
|
||
```bash | ||
kubectl apply -f ./ingress | ||
``` | ||
|
||
- Refresh prometheus target page it should show probe ingress target | ||
|
||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: example-app | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: example-app | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: example-app | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: example-app | ||
spec: | ||
containers: | ||
- name: prometheus-example-app | ||
image: ghcr.io/rhobs/prometheus-example-app:0.4.1 | ||
ports: | ||
- name: web | ||
containerPort: 8080 |
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,21 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: example-app-ingress | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: example-app | ||
annotations: | ||
nginx.ingress.kubernetes.io/rewrite-target: /$1 | ||
spec: | ||
rules: | ||
- host: example-app | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: web | ||
port: | ||
number: 8080 |
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,15 @@ | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: Probe | ||
metadata: | ||
name: probe-ingress | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: probe-ingress | ||
spec: | ||
prober: | ||
url: blackbox-exporter.monitoring.svc:19115 | ||
targets: | ||
ingress: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: example-app |
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,13 @@ | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: example-app | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: example-app | ||
spec: | ||
selector: | ||
app.kubernetes.io/name: example-app | ||
ports: | ||
- name: web | ||
port: 8080 |
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,17 @@ | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: Probe | ||
metadata: | ||
name: probe-static-target | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: probe-static-target | ||
spec: | ||
prober: | ||
url: blackbox-exporter.monitoring.svc:19115 | ||
targets: | ||
staticConfig: | ||
labels: | ||
environment: prometheus.io | ||
static: | ||
- 'https://demo.do.prometheus.io' | ||
- 'https://node.demo.do.prometheus.io' |
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,12 @@ | ||
# Service Monitor | ||
|
||
Monitor Kubernetes Services | ||
|
||
- Deploy app, create service and service monitor | ||
|
||
```bash | ||
kubectl apply -f . | ||
``` | ||
|
||
- Refresh prometheus target page it should show service monitor target | ||
 |
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,23 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: prometheus-example-app | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: prometheus-example-app | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: prometheus-example-app | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: prometheus-example-app | ||
spec: | ||
containers: | ||
- name: prometheus-example-app | ||
image: ghcr.io/rhobs/prometheus-example-app:0.4.1 | ||
ports: | ||
- name: web | ||
containerPort: 8080 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 @@ | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
name: prometheus-example-app | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: prometheus-example-app | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: prometheus-example-app | ||
endpoints: | ||
- port: web |
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,13 @@ | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: prometheus-example-app | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: prometheus-example-app | ||
spec: | ||
selector: | ||
app.kubernetes.io/name: prometheus-example-app | ||
ports: | ||
- name: web | ||
port: 8080 |