1.下载heapster镜像
在运维主机(mfyxw50.mfyxw.com)执行
[root@mfyxw50 ~]# docker pull quay.io/bitnami/heapster:1.5.4
2.对heapster打标签并上传至私有仓库
在运维主机(mfyxw50.mfyxw.com)执行
[root@mfyxw50 ~]# docker images | grep heapster
[root@mfyxw50 ~]# docker tag quay.io/bitnami/heapster:1.5.4 harbor.od.com/public/heapster:v1.5.4
[root@mfyxw50 ~]# docker login harbor.od.com
[root@mfyxw50 ~]# docker push harbor.od.com/public/heapster:v1.5.4
3.准备heapster资源配置清单
在运维主机(mfyxw50.mfyxw.com)上执行
[root@mfyxw50 ~]# mkdir -p /data/k8s-yaml/heapster
[root@mfyxw50 ~]# cd /data/k8s-yaml/heapster
heapster的rbac.ymal资源配置清单如下:
[root@mfyxw50 heapster]# cat > /data/k8s-yaml/heapster/rbac.yaml << EOF
apiVersion: v1
kind: ServiceAccount
metadata:
name: heapster
namespace: kube-system
---
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
EOF
heapster的deployment.yaml资源配置清单如下:
[root@mfyxw50 heapster]# cat > /data/k8s-yaml/heapster/deployment.yaml << EOF
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.od.com/public/heapster:v1.5.4
imagePullPolicy: IfNotPresent
command:
- /opt/bitnami/heapster/bin/heapster
- --source=kubernetes:https://kubernetes.default
EOF
heapster的svc.yaml资源配置清单如下:
[root@mfyxw50 heapster]# cat > /data/k8s-yaml/heapster/svc.yaml << EOF
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
EOF
4.应用heapster资源配置清单
在master节点(mfyxw30.mfyxw.com或mfyxw40.mfyxw.com)任意一台上执行命令即可
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/heapster/rbac.yaml
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/heapster/deployment.yaml
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/heapster/svc.yaml