build prometheus for monitor

This commit is contained in:
pengtao 2022-04-11 22:59:04 +08:00
parent 05ef2c1e3c
commit ddfce77eaf
7 changed files with 119 additions and 1 deletions

26
app03/app-deploy.yaml Normal file
View File

@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: miles01
namespace: app02
labels:
app: fastapi
spec:
replicas: 1
selector:
matchLabels:
app: fastapi
template:
metadata:
labels:
app: fastapi
name: fastapi
spec:
containers:
- name: fastapi
image: ub20:v1
imagePullPolicy: Never
ports:
- containerPort: 8000
# command:
# - ["/usr/bin/python3", "/app/app.py"]

13
app03/app-service.yaml Normal file
View File

@ -0,0 +1,13 @@
kind: Service
apiVersion: v1
metadata:
name: miles01
namespace: app02
spec:
type: NodePort
ports:
- port: 8000
nodePort: 30000
selector:
name: miles01
# curl http://127.0.0.1:30000/docs

View File

@ -0,0 +1,8 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: monitor
labels:
name: monitor
type: namespace

View File

@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: monitor
data:
prometheus.yml: |
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']

View File

@ -0,0 +1,51 @@
apiVersion: v1
kind: "Service"
metadata:
name: prometheus
namespace: monitor
labels:
name: prometheus
spec:
ports:
- name: prometheus
protocol: TCP
port: 9090
targetPort: 9090
selector:
name: prometheus
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
name: prometheus
name: prometheus
namespace: monitor
spec:
replicas: 1
selector:
matchLabels:
name: prometheus
template:
metadata:
labels:
name: prometheus
spec:
containers:
- name: prometheus
image: prom/prometheus:v2.2.1
command:
- "/bin/prometheus"
args:
- "--config.file=/etc/prometheus/prometheus.yml"
ports:
- containerPort: 9090
protocol: TCP
volumeMounts:
- mountPath: "/etc/prometheus"
name: prometheus-config
volumes:
- name: prometheus-config
configMap:
name: prometheus-config

View File

@ -44,4 +44,8 @@ kubectl run busybox --image=busybox --command -- ping baidu.com
kubectl exec -it busybox -- /bin/bash
k describe replicaset.apps/app01-redis-64847ffc48
k get all -ALL
k describe pods
k describe pods
# minikube 使用本地image 方法
eval $(minikube -p minikube docker-env)
docker build -t .

2
start_mini.sh Normal file
View File

@ -0,0 +1,2 @@
#minikube config set driver hyperkit
minikube start --driver=hyperkit