基于 Kubernetes v1.14.0 之heapster与influxdb部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于 Kubernetes v1.14.0 之heapster与influxdb部署相关的知识,希望对你有一定的参考价值。
1、部署准备说明:所有的容器组都运行在kube-system 命名空间
github 项目地址 https://github.com/kubernetes-retired/heapster.git
mkdir heapster
git clone https://github.com/kubernetes-retired/heapster.git
cd heapster/deploy/kube-config/influxdb
2、influxdb 部署
2.1、创建influxdb pvc 源项目没相关yaml
vi influxdb-pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
# 挂载点名字influxdb-pvc
name: influxdb-pvc
namespace: kube-system
spec:
accessModes:
- ReadWriteMany
# 存储类型名字动态pvc名字nfs-storage 这里使用nfs
storageClassName: nfs-storage
resources:
requests:
#硬盘大小
storage: 50Gi
2.2、创建influxdb Deployment
修改容器源 juestnow/heapster-influxdb-amd64:v1.5.2
添加指定节点运行
nodeSelector:
dashboard: kubernetes-dashboard #指定节点运行
vi 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:
nodeSelector:
dashboard: kubernetes-dashboard
containers:
- name: influxdb
image: juestnow/heapster-influxdb-amd64:v1.5.2
volumeMounts:
- mountPath: /data
name: influxdb-storage
volumes:
- name: influxdb-storage
persistentVolumeClaim:
claimName: influxdb-pvc
---
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
2.3 执行生成yaml 文件
kubectl apply -f influxdb-pvc.yaml
kubectl apply -f influxdb.yaml
kubectl get pod -n kube-system -o wide | grep influxdb
[[email protected] kubernetes]# kubectl get pod -n kube-system -o wide | grep influxdb
monitoring-influxdb-75678b664f-z9zck 1/1 Running 0 21d 10.65.3.155 nginx-2 <none> <none>
http://10.65.3.155:8086/
返回404 证明访问正常
[[email protected] kubernetes]# kubectl get service -n kube-system | grep influxdb
monitoring-influxdb ClusterIP 10.64.39.166 <none> 8086/TCP 47d
http://10.64.39.166:8086/
同样返回404 证明服务正常
这里只做服务是否正常运行验证
3、heapster 部署
3.1、 创建clusterrole
vi heapster-clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
labels:
kubernetes.io/bootstrapping: rbac-defaults
name: system:heapster
rules:
- apiGroups:
- ""
resources:
- events
- namespaces
- nodes
- pods
- nodes/stats
verbs:
- create
- get
- list
- watch
- apiGroups:
- extensions
resources:
- deployments
verbs:
- get
- list
- watch
3.2 创建ClusterRoleBinding
vi heapster-rbac.yaml
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: heapster
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:heapster
subjects:
- kind: ServiceAccount
name: heapster
namespace: kube-system
3.3、heapster Deployment 合集
修改 - --source=kubernetes:https://kubernetes.default
--source=kubernetes:https://kubernetes.default?kubeletHttps=true&kubeletPort=10250&insecure=true
修改容器源 juestnow/heapster-amd64:v1.5.4
nodeSelector:
dashboard: kubernetes-dashboard #指定节点运行
vi heapster.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: heapster
namespace: kube-system
---
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
nodeSelector:
dashboard: kubernetes-dashboard
containers:
- name: heapster
image: juestnow/heapster-amd64:v1.5.4
imagePullPolicy: IfNotPresent
command:
- /heapster
- --source=kubernetes:https://kubernetes.default?kubeletHttps=true&kubeletPort=10250&insecure=true
- --sink=influxdb:http://monitoring-influxdb: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:
type: NodePort
ports:
- port: 80
targetPort: 8082
selector:
k8s-app: heapster
3.4 执行生成yaml 文件
kubectl apply -f .
3.5 验证heapster 状态
[[email protected] kubernetes]# kubectl get pod -n kube-system | grep heapster
heapster-6f76dc9d7-vzfz8 1/1 Running 0 21d
[[email protected] kubernetes]# kubectl get service -n kube-system | grep heapster
heapster NodePort 10.64.248.238 <none> 80:45389/TCP 47d
http://10.64.248.238/
返回404 正常
等待一段时间打开:kubernetes-dashboard 查看容器cpu内存使用由图表
如果出现图表证明heapster 安装 成功
下一篇: Kubernetes 生产环境安装部署 基于 Kubernetes v1.14.0 之 metrics-server 部署
以上是关于基于 Kubernetes v1.14.0 之heapster与influxdb部署的主要内容,如果未能解决你的问题,请参考以下文章
基于 Kubernetes v1.14.0 之 vpa 部署
基于 Kubernetes v1.14.0 之 Alertmanager 部署
基于 Kubernetes v1.14.0 之 CoreDNS部署