志不强者智不达,言不信者行不果。这篇文章主要讲述k8s-监控组件:heaper部署相关的知识,希望能为你提供帮助。
ansible搭建k8s参考:??https://blog.51cto.com/taowenwu/5222088??
【k8s-监控组件:heaper部署】heapster:数据采集
influxdb:数据存储
grafana:web展示
1.准备镜像及配置文件
mkdir /etc/ansible/manifests/dns/kube-dns/heapster
cd /etc/ansible/manifests/dns/kube-dns/heapster
docker load -i heapster-amd64_v1.5.1.tar & & \\
docker load -i heapster-grafana-amd64-v4.4.3.tar & & \\
docker load -i heapster-influxdb-amd64_v1.3.3.tar
docker tag 4129aa919411harbor.gesila.com/k8s/heapster-amd64:v1.5.1 & & \\
docker tag 8cb3de219af7harbor.gesila.com/k8s/heapster-grafana-amd64:v4.4.3 & & \\
docker tag 1315f002663charbor.gesila.com/k8s/heapster-influxdb-amd64:v1.3.3
docker push harbor.gesila.com/k8s/heapster-amd64:v1.5.1 & & \\
docker push harbor.gesila.com/k8s/heapster-grafana-amd64:v4.4.3 & & \\
docker push harbor.gesila.com/k8s/heapster-influxdb-amd64:v1.3.3
3.修改配置文件镜像源
vim grafana.yaml
-name: grafana
images: harbor.gesila.com/k8s/heapster-grafana-amd64:v4.4.3
vim heapster.yaml
-name: heapster
images: harbor.gesila.com/k8s/heapster-amd64:v1.5.1
vim influxdb.yaml
-name: influxdb
images: harbor.gesila.com/k8s/heapster-influxdb-amd64:v1.3.3
4.构建
root@k8s-master:/etc/ansible/manifests/dns/kube-dns/heapster# kubectl apply -f .
deployment.extensions/monitoring-grafana created
service/monitoring-grafana created
serviceaccount/heapster created
clusterrolebinding.rbac.authorization.k8s.io/heapster created
deployment.extensions/heapster created
service/heapster created
deployment.extensions/monitoring-influxdb created
service/monitoring-influxdb created
5.查看
root@k8s-master:/etc/ansible/manifests/dns/kube-dns/heapster# kubectl get pods -n kube-system
NAMEREADYSTATUSRESTARTSAGE
calico-kube-controllers-64dfd5bf4c-q94ls1/1Running03h18m
calico-node-9ccdk2/2Running223h
calico-node-k297m2/2Running423h
calico-node-w6m6p2/2Running1023h
heapster-7689489d99-dlz5s1/1Running020s
kube-dns-5744cc9dff-rxgjk3/3Running045m
kubernetes-dashboard-7b5f5b777c-s7djw1/1Running03h18m
monitoring-grafana-6949dd99d6-4dcdq1/1Running021s
monitoring-influxdb-7cb4988b9c-ktqgz1/1Running021s
root@k8s-master:/etc/ansible/manifests/dns/kube-dns/heapster# kubectl cluster-info
Kubernetes master is running at https://192.168.47.49:6443
KubeDNS is running at https://192.168.47.49:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
kubernetes-dashboard is running at https://192.168.47.49:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
monitoring-grafana is running at https://192.168.47.49:6443/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
monitoring-influxdb is running at https://192.168.47.49:6443/api/v1/namespaces/kube-system/services/monitoring-influxdb/proxy
To further debug and diagnose cluster problems, use kubectl cluster-info dump.
6.文件
6.1.grafana.yaml
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: monitoring-grafana
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
task: monitoring
k8s-app: grafana
spec:
containers:
- name: grafana
image: harbor.gesila.com/k8s/heapster-grafana-amd64:v4.4.3
imagePullPolicy: Always
ports:
- containerPort: 3000
protocol: TCP
volumeMounts:
- mountPath: /var
name: grafana-storage
env:
- name: INFLUXDB_HOST
value: monitoring-influxdb
- name: GF_SERVER_HTTP_PORT
value: "3000"
# The following env variables are required to make Grafana accessible via
# the kubernetes api-server proxy. On production clusters, we recommend
# removing these env variables, setup auth for grafana, and expose the grafana
# service using a LoadBalancer or a public IP.
- name: GF_AUTH_BASIC_ENABLED
value: "false"
- name: GF_AUTH_ANONYMOUS_ENABLED
value: "true"
- name: GF_AUTH_ANONYMOUS_ORG_ROLE
value: Admin
- name: GF_SERVER_ROOT_URL
# If youre only using the API Server proxy, set this value instead:
value: /api/v1/namespaces/kube-system/services/monitoring-grafana/proxy/
#value: /
volumes:
- name: grafana-storage
emptyDir:
---
apiVersion: v1
kind: Service
metadata:
labels:
# For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
# If you are NOT using this as an addon, you should comment out this line.
kubernetes.io/cluster-service: true
kubernetes.io/name: monitoring-grafana
name: monitoring-grafana
namespace: kube-system
spec:
# In a production setup, we recommend accessing Grafana through an external Loadbalancer
# or through a public IP.
# type: LoadBalancer
# You could also use NodePort to expose the service at a randomly-generated port
# type: NodePort
ports:
- port: 80
targetPort: 3000
selector:
k8s-app: grafana
6.2.heapster.yaml
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: heapster
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: heapster
subjects:
- kind: ServiceAccount
name: heapster
namespace: kube-system
roleRef:
kind: ClusterRole
name: system:heapster
apiGroup: rbac.authorization.k8s.io
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: heapster
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
task: monitoring
k8s-app: heapster
spec:
serviceAccountName: heapster
containers:
- name: heapster
image: harbor.gesila.com/k8s/heapster-amd64:v1.5.1
imagePullPolicy: Always
command:
- /heapster
- --source=kubernetes:https://kubernetes.default
- --sink=influxdb:http://monitoring-influxdb.kube-system.svc:8086
---
apiVersion: v1
kind: Service
metadata:
labels:
task: monitoring
# For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
# If you are NOT using this as an addon, you should comment out this line.
#kubernetes.io/cluster-service: true
kubernetes.io/name: Heapster
name: heapster
namespace: kube-system
spec:
ports:
- port: 80
targetPort: 8082
selector:
k8s-app: heapster
6.3.influxdb.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: monitoring-influxdb
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
task: monitoring
k8s-app: influxdb
spec:
containers:
- name: influxdb
image: harbor.gesila.com/k8s/heapster-influxdb-amd64:v1.3.3
volumeMounts:
- mountPath: /data
name: influxdb-storage
volumes:
- name: influxdb-storage
emptyDir:
---
apiVersion: v1
kind: Service
metadata:
labels:
task: monitoring
# For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
# If you are NOT using this as an addon, you should comment out this line.
kubernetes.io/cluster-service: true
kubernetes.io/name: monitoring-influxdb
name: monitoring-influxdb
namespace: kube-system
spec:
ports:
- port: 8086
targetPort: 8086
selector:
k8s-app: influxdb
推荐阅读
- 使用APICloud & 科大讯飞SDK快速实现语音识别功能
- Nginx实现后端多台Tomcat的负载均衡调度
- 使用vue+docxtemplater导出word
- 基于Feature Flag的下一代开发模式
- HAC集群状态检查切换数据同步验证方法 目录
- JVS开源框架系列(??动态数据模型说明?「含软开企服的开源地址」)
- Angular项目实战Angular服务器渲染常遇的坑,这份填坑指南请收好~
- 印刷电路板(PCB)基础
- kettle庖丁解牛第10篇之表输入