-
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 root README with updated instructions
Signed-off-by: Jayapriya Pai <[email protected]>
- Loading branch information
Showing
6 changed files
with
108 additions
and
35 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 |
---|---|---|
|
@@ -4,58 +4,71 @@ | |
|
||
For each example config, check README page in respective folder. | ||
|
||
Examples are created in `default` namespace | ||
|
||
## Pre-requisites | ||
|
||
Create kind cluster or minikube cluster (examples in this repo are tested with minikube) | ||
Create kind cluster or minikube cluster (examples in this repo are tested with kind cluster) | ||
|
||
## Create a playground kubernetes cluster | ||
|
||
### kind cluster | ||
|
||
This will create a multi-node kind cluster with one control plane node | ||
and two worker nodes | ||
|
||
```bash | ||
$ minikube delete && minikube start --kubernetes-version=v1.26.5 --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 | ||
kind create cluster --name multi-node --config kind-config.yaml | ||
``` | ||
|
||
[kube-prometheus](https://github.com/prometheus-operator/kube-prometheus#quickstart) stack is configured in cluster before running any examples. Quick start creates a namespace `monitoring` and deploys monitoring components in that. This will help us setup monitoring stack out of the box. | ||
or | ||
|
||
### minikube (not fully tested for all examples) | ||
|
||
```bash | ||
git clone [email protected]:prometheus-operator/kube-prometheus.git; | ||
cd kube-prometheus; | ||
kubectl apply --server-side -f manifests/setup | ||
kubectl wait \ | ||
--for condition=Established \ | ||
--all CustomResourceDefinition \ | ||
--namespace=monitoring | ||
kubectl apply -f manifests/ | ||
minikube start --nodes 3 -p multi-node --kubernetes-version=v1.27.3 --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 | ||
``` | ||
|
||
You should see following pods after quick start commands are applied (This will take a while for all pods to come up) | ||
### Configure prometheus-operator | ||
|
||
```bash | ||
░▒▓ ~/gi/s/kube-prometheus on main ?1 kubectl get pods -n monitoring ✔ 3.9.5 1.20.2 2.7.3 at minikube ⎈ at 21:55:02 ▓▒░ | ||
NAME READY STATUS RESTARTS AGE | ||
alertmanager-main-0 2/2 Running 0 2m39s | ||
alertmanager-main-1 2/2 Running 0 2m39s | ||
alertmanager-main-2 1/2 Running 0 2m39s | ||
blackbox-exporter-6bc47b9578-lc5f8 3/3 Running 0 5m8s | ||
grafana-57f885b6c8-jdglq 1/1 Running 0 5m7s | ||
kube-state-metrics-f76ffbf8b-kfp9j 3/3 Running 0 5m7s | ||
node-exporter-46c4s 2/2 Running 0 5m6s | ||
prometheus-adapter-6b88dfd544-jv2rd 1/1 Running 0 5m6s | ||
prometheus-adapter-6b88dfd544-p8bzk 1/1 Running 0 5m6s | ||
prometheus-k8s-0 2/2 Running 0 2m39s | ||
prometheus-k8s-1 2/2 Running 0 2m39s | ||
prometheus-operator-58899ccbf4-9pv7p 2/2 Running 0 5m6s | ||
git clone https://github.com/prometheus-operator/prometheus-operator.git | ||
cd prometheus-operator | ||
# install crds | ||
kubectl create -f example/prometheus-operator-crd-full | ||
# deploy prometheus-operator | ||
kubectl create -f example/rbac/prometheus-operator | ||
``` | ||
|
||
## Helpful Commands | ||
You should see prometheus-operator pod running | ||
|
||
- Access Prometheus UI | ||
```bash | ||
kubectl get pods | ||
NAME READY STATUS RESTARTS AGE | ||
prometheus-operator-bcbbc87bd-mmbrl 1/1 Running 0 3m47s | ||
``` | ||
|
||
```bash | ||
kubectl -n monitoring port-forward svc/prometheus-k8s 9090& | ||
``` | ||
### Create Prometheus stack | ||
|
||
From this repo path: | ||
|
||
```bash | ||
kubectl create -f prometheus_only_stack | ||
``` | ||
|
||
- Access AlertManager UI | ||
You should see prometheus pods running after a while | ||
|
||
```bash | ||
prometheus-prometheus-0 2/2 Running 0 3m20s | ||
prometheus-prometheus-1 2/2 Running 0 3m20s | ||
``` | ||
|
||
## Helpful Commands | ||
|
||
- Access Prometheus UI | ||
|
||
```bash | ||
kubectl -n monitoring port-forward svc/alertmanager-main 9093& | ||
kubectl -n default port-forward svc/prometheus-operated 9090& | ||
``` | ||
|
||
## Notes | ||
|
@@ -66,12 +79,12 @@ Port-forward the app deployed to see more metrices generated by the [prometheus- | |
|
||
If app is deployed as a pod: | ||
|
||
``` | ||
```bash | ||
kubectl port-forward pod/<pod-name> 8080 | ||
``` | ||
|
||
If service exists/deployed as a Deployment and exposed it through service | ||
|
||
``` | ||
```bash | ||
kubectl port-forward svc/<service-name> 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,7 @@ | ||
# three node (two workers) cluster config | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
- role: worker | ||
- role: worker |
12 changes: 12 additions & 0 deletions
12
prometheus_only_stack/prometheus-cluster-role-binding.yaml
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 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: prometheus | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: prometheus | ||
subjects: | ||
- kind: ServiceAccount | ||
name: prometheus | ||
namespace: default |
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,24 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: prometheus | ||
rules: | ||
- apiGroups: [""] | ||
resources: | ||
- nodes | ||
- nodes/metrics | ||
- services | ||
- endpoints | ||
- pods | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: [""] | ||
resources: | ||
- configmaps | ||
verbs: ["get"] | ||
- apiGroups: | ||
- networking.k8s.io | ||
resources: | ||
- ingresses | ||
verbs: ["get", "list", "watch"] | ||
- nonResourceURLs: ["/metrics"] | ||
verbs: ["get"] |
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,4 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: prometheus |
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: Prometheus | ||
metadata: | ||
name: prometheus | ||
labels: | ||
prometheus: prometheus | ||
spec: | ||
replicas: 2 | ||
serviceAccountName: prometheus | ||
serviceMonitorSelector: {} | ||
podMonitorSelector: {} | ||
probeSelector: {} | ||
scrapeConfigSelector: {} |