Open obriensystems opened 2 months ago
on m1max mac michaelobrien@mbp7 rag % kubectl create namespace prometheus namespace/prometheus created michaelobrien@mbp7 rag % kubectl get namespaces NAME STATUS AGE default Active 25d kube-node-lease Active 25d kube-public Active 25d kube-system Active 25d prometheus Active 11s apiVersion: v1 kind: PersistentVolumeClaim metadata: name: prometheus-data-pvc namespace: prometheus spec: accessModes: - ReadWriteOnce volumeMode: Filesystem resources: requests: storage: 2Gi michaelobrien@mbp7 kubernetes % kubectl apply -f prometheus-storage.yaml persistentvolumeclaim/prometheus-data-pvc created michaelobrien@mbp7 kubernetes % kubectl get pvc -n prometheus NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE prometheus-data-pvc Bound pvc-5532fd6a-4bc0-440c-8d0d-831100c231b3 2Gi RWO hostpath <unset> 28s michaelobrien@mbp7 kubernetes % kubectl get pv NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS VOLUMEATTRIBUTESCLASS REASON AGE pvc-5532fd6a-4bc0-440c-8d0d-831100c231b3 2Gi RWO Delete Bound prometheus/prometheus-data-pvc hostpath <unset> 60s michaelobrien@mbp7 kubernetes % vi prometheus-configmap.yaml michaelobrien@mbp7 kubernetes % vi prometheus-service.yaml michaelobrien@mbp7 kubernetes % vi prometheus-deployment.yaml michaelobrien@mbp7 kubernetes % cat prometheus-configmap.yaml apiVersion: v1 data: prometheus.yml: | global: scrape_interval: 30s scrape_timeout: 25s scrape_configs: - job_name: "proemtheus" static_configs: - targets: ["localhost:9090"] kind: ConfigMap metadata: namespace: prometheus name: prometheus-configmap michaelobrien@mbp7 kubernetes % cat prometheus-service.yaml apiVersion: v1 kind: Service metadata: name: prometheus-service annotations: service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "http" namespace: prometheus labels: app: prometheus spec: type: LoadBalancer selector: app: prometheus ports: - protocol: TCP port: 9090 targetPort: 9090 michaelobrien@mbp7 kubernetes % cat prometheus-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: labels: app: prometheus name: prometheus-deploy namespace: prometheus spec: replicas: 1 selector: matchLabels: app: prometheus template: metadata: labels: app: prometheus spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/arch operator: In values: - amd64 - arm64 containers: - name: prometheus-container image: prom/prometheus:latest ports: - containerPort: 9090 volumeMounts: - name: prometheus-config-file mountPath: /etc/prometheus - name: prometheus-data-storage mountPath: /prometheus volumes: - name: prometheus-config-file configMap: name: prometheus-configmap - name: prometheus-data-storage persistentVolumeClaim: claimName: prometheus-data-pvc michaelobrien@mbp7 kubernetes % kubectl apply -f prometheus-configmap.yaml configmap/prometheus-configmap created michaelobrien@mbp7 kubernetes % kubectl apply -f prometheus-service.yaml service/prometheus-service created michaelobrien@mbp7 kubernetes % kubectl apply -f prometheus-deployment.yaml deployment.apps/prometheus-deploy created michaelobrien@mbp7 kubernetes % kubectl get deployments -n prometheus NAME READY UP-TO-DATE AVAILABLE AGE prometheus-deploy 1/1 1 1 92s michaelobrien@mbp7 kubernetes % kubectl describe deployment prometheus-deploy -n prometheus Name: prometheus-deploy Namespace: prometheus CreationTimestamp: Wed, 28 Aug 2024 09:18:07 -0400 Labels: app=prometheus Annotations: deployment.kubernetes.io/revision: 1 Selector: app=prometheus Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable StrategyType: RollingUpdate MinReadySeconds: 0 RollingUpdateStrategy: 25% max unavailable, 25% max surge Pod Template: Labels: app=prometheus Containers: prometheus-container: Image: prom/prometheus:latest Port: 9090/TCP Host Port: 0/TCP Environment: <none> Mounts: /etc/prometheus from prometheus-config-file (rw) /prometheus from prometheus-data-storage (rw) Volumes: prometheus-config-file: Type: ConfigMap (a volume populated by a ConfigMap) Name: prometheus-configmap Optional: false prometheus-data-storage: Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace) ClaimName: prometheus-data-pvc ReadOnly: false Node-Selectors: <none> Tolerations: <none> Conditions: Type Status Reason ---- ------ ------ Available True MinimumReplicasAvailable Progressing True NewReplicaSetAvailable OldReplicaSets: <none> NewReplicaSet: prometheus-deploy-7d7d88fd9b (1/1 replicas created) Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal ScalingReplicaSet 2m3s deployment-controller Scaled up replica set prometheus-deploy-7d7d88fd9b to 1
https://squaredup.com/blog/three-ways-to-run-prometheus/
http://127.0.0.1:9090/graph?g0.expr=&g0.tab=1&g0.display_mode=lines&g0.show_exemplars=0&g0.range_input=1h
https://squaredup.com/blog/three-ways-to-run-prometheus/