diff --git a/app03/app-deploy.yaml b/app03/app-deploy.yaml new file mode 100644 index 0000000..80fd0a5 --- /dev/null +++ b/app03/app-deploy.yaml @@ -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"] diff --git a/app03/app-service.yaml b/app03/app-service.yaml new file mode 100644 index 0000000..04eaf6c --- /dev/null +++ b/app03/app-service.yaml @@ -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 diff --git a/prometheus/monitor-namespace.yaml b/prometheus/monitor-namespace.yaml new file mode 100644 index 0000000..0880411 --- /dev/null +++ b/prometheus/monitor-namespace.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: monitor + labels: + name: monitor + type: namespace diff --git a/prometheus/prometheus-config.yaml b/prometheus/prometheus-config.yaml new file mode 100644 index 0000000..c807961 --- /dev/null +++ b/prometheus/prometheus-config.yaml @@ -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'] diff --git a/prometheus/prometheus-deploy.yaml b/prometheus/prometheus-deploy.yaml new file mode 100644 index 0000000..6db0f94 --- /dev/null +++ b/prometheus/prometheus-deploy.yaml @@ -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 diff --git a/readme.md b/readme.md index 927588f..b00f920 100644 --- a/readme.md +++ b/readme.md @@ -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 \ No newline at end of file +k describe pods + +# minikube 使用本地image 方法 +eval $(minikube -p minikube docker-env) +docker build -t . diff --git a/start_mini.sh b/start_mini.sh new file mode 100644 index 0000000..a01443e --- /dev/null +++ b/start_mini.sh @@ -0,0 +1,2 @@ +#minikube config set driver hyperkit +minikube start --driver=hyperkit