This repository is here to guide you through the GitHub tutorial that goes hand-in-hand with a video available on YouTube and a detailed blog post on my website. Together, these resources are designed to give you a complete understanding of the topic.
Here are the links to the related assets:
- YouTube Video: How to collect metrics in K8s
- Blog Post: How to collect metrics in a Kubernetes cluster
Feel free to explore the materials, star the repository, and follow along at your own pace.
This repository showcases the usage of Prometheus by using GKE with the HipsterShop
The following tools need to be installed on your machine :
- jq
- kubectl
- git
- gcloud (if you're using GKE)
- Helm
PROJECT_ID="<your-project-id>"
gcloud services enable container.googleapis.com --project ${PROJECT_ID}
gcloud services enable monitoring.googleapis.com \
cloudtrace.googleapis.com \
clouddebugger.googleapis.com \
cloudprofiler.googleapis.com \
--project ${PROJECT_ID}
ZONE=us-central1-b
gcloud containr clusters create isitobservable \
--project=${PROJECT_ID} --zone=${ZONE} \
--machine-type=e2-standard-2 --num-nodes=4
git clone https://github.com/isItObservable/Episode1---Kubernetes-Prometheus
cd Episode1---Kubernetes-Prometheus
cd hipstershop
./setup.sh
helm install prometheus stable/prometheus-operator
kubectl get svc
kubectl edit svc prometheus-grafana
change to type NodePort
apiVersion: v1
kind: Service
metadata:
annotations:
meta.helm.sh/release-name: prometheus
meta.helm.sh/release-namespace: default
labels:
app.kubernetes.io/instance: prometheus
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: grafana
app.kubernetes.io/version: 7.0.3
helm.sh/chart: grafana-5.3.0
name: prometheus-grafana
namespace: default
resourceVersion: "89873265"
selfLink: /api/v1/namespaces/default/services/prometheus-grafana
spec:
clusterIP: IPADRESSS
externalTrafficPolicy: Cluster
ports:
- name: service
nodePort: 30806
port: 80
protocol: TCP
targetPort: 3000
selector:
app.kubernetes.io/instance: prometheus
app.kubernetes.io/name: grafana
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}
Deploy the ingress by making sure to replace the service name of your Grafana
cd ..\grafana
kubectl apply -f ingress.yaml
Get the login user and password of Grafana
- For the password :
kubectl get secret --namespace default prometheus-grafana -o jsonpath="{.data.admin-password}" | base64 --decode
- For the login user:
kubectl get secret --namespace default prometheus-grafana -o jsonpath="{.data.admin-user}" | base64 --decode