Kubernetes 1.5安装 heapster

来源:互联网 发布:该死的妹子软件 编辑:程序博客网 时间:2024/05/11 12:34

接上一篇文章【Kubernetes 1.5安装 kubernetes dashboard】http://blog.csdn.net/wenwst/article/details/54410012

安装Heapster

yaml文件来自于github。

创建yaml文件

grafana-deployment.yaml 中的image,先用下面命令下载到别一个节点上面。

docker pull gcr.io/google_containers/heapster_grafana:v3.1.1
[root@localhost heapster]# cat grafana-deployment.yaml apiVersion: extensions/v1beta1kind: Deploymentmetadata:  name: monitoring-grafana  namespace: kube-systemspec:  replicas: 1  template:    metadata:      labels:        task: monitoring        k8s-app: grafana    spec:      volumes:      - name: grafana-storage        emptyDir: {}      containers:      - name: grafana        image: gcr.io/google_containers/heapster_grafana:v3.1.1        ports:          - containerPort: 3000            protocol: TCP        volumeMounts:        - mountPath: /var          name: grafana-storage        env:        - name: INFLUXDB_HOST          value: monitoring-influxdb        - name: GRAFANA_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          # value: /api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/          value: /

创建grafana-service.yaml

[root@localhost heapster]# cat grafana-service.yaml apiVersion: v1kind: Servicemetadata:  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-systemspec:  # In a production setup, we recommend accessing Grafana through an external Loadbalancer  # or through a public IP.  # type: LoadBalancer  type: NodePort  ports:  - port: 80    targetPort: 3000  selector:    k8s-app: grafana

创建influxdb-deployment.yaml文件

[root@localhost heapster]# cat influxdb-deployment.yaml apiVersion: extensions/v1beta1kind: Deploymentmetadata:  name: monitoring-influxdb  namespace: kube-systemspec:  replicas: 1  template:    metadata:      labels:        task: monitoring        k8s-app: influxdb    spec:      volumes:      - name: influxdb-storage        emptyDir: {}      containers:      - name: influxdb        image: kubernetes/heapster_influxdb:v0.6        volumeMounts:        - mountPath: /data          name: influxdb-storage

创建influxdb-service.yaml 文件

[root@localhost heapster]# cat influxdb-service.yaml apiVersion: v1kind: Servicemetadata:  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-systemspec:  # type: NodePort  ports:  - name: api    port: 8086    targetPort: 8086  selector:    k8s-app: influxdb

创建 heapster-deployment.yaml 文件

[root@localhost heapster]# cat heapster-deployment.yaml apiVersion: extensions/v1beta1kind: Deploymentmetadata:  name: heapster  namespace: kube-systemspec:  replicas: 1  template:    metadata:      labels:        task: monitoring        k8s-app: heapster        version: v6    spec:      containers:      - name: heapster        image: kubernetes/heapster:canary        imagePullPolicy: Always        command:        - /heapster        - --source=kubernetes:https://kubernetes.default        - --sink=influxdb:http://monitoring-influxdb:8086

创建 heapster-service.yaml 文件

[root@localhost heapster]# cat heapster-service.yaml apiVersion: v1kind: Servicemetadata:  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-systemspec:  ports:  - port: 80    targetPort: 8082  selector:    k8s-app: heapster

下载镜像文件

先把下面三个镜像下载到所有的节点,再进行下一步。
gcr.io/google_containers/heapster_grafana:v3.1.1
kubernetes/heapster_influxdb:v0.6
kubernetes/heapster:canary

docker pull gcr.io/google_containers/heapster_grafana:v3.1.1docker pull kubernetes/heapster_influxdb:v0.6docker pull kubernetes/heapster:canary

如果无法下载,或下载太慢,请查看别一篇blog:
http://blog.csdn.net/wenwst/article/details/54582141
这里面的东西可能会有用处。

部署安装

刚才我们创建了六个文件,现在使用kubectl create 来创建。

kubectl create -f grafana-deployment.yaml -f grafana-service.yaml -f influxdb-deployment.yaml -f  influxdb-service.yaml -f heapster-deployment.yaml -f  heapster-service.yaml  

创建完成后,使用命令

kubectl get pod --namespace=kube-system

查看pod的安装情况。

 [root@localhost heapster]# kubectl get pod --namespace=kube-systemNAME                                    READY     STATUS    RESTARTS   AGEdummy-2088944543-xjj21                  1/1       Running   0          2hetcd-centos-master                      1/1       Running   0          2hheapster-2193675300-j1jxn               1/1       Running   0          1hkube-apiserver-centos-master            1/1       Running   0          2hkube-controller-manager-centos-master   1/1       Running   0          2hkube-discovery-1769846148-c45gd         1/1       Running   0          1hkube-dns-2924299975-96xms               4/4       Running   0          1hkube-proxy-33lsn                        1/1       Running   0          1hkube-proxy-jnz6q                        1/1       Running   0          1hkube-proxy-vfql2                        1/1       Running   0          1hkube-scheduler-centos-master            1/1       Running   0          2hkubernetes-dashboard-3000605155-8mxgz   1/1       Running   0          1hmonitoring-grafana-810108360-h92v7      1/1       Running   0          1hmonitoring-influxdb-3065341217-q2445    1/1       Running   0          1hweave-net-k5tlz                         2/2       Running   0          1hweave-net-q3n89                         2/2       Running   0          1hweave-net-x57k7                         2/2       Running   0          1h

查看服务:

[root@localhost heapster]# kubectl get svc --namespace=kube-systemNAME                   CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGEheapster               10.98.45.1      <none>        80/TCP          1hkube-dns               10.96.0.10      <none>        53/UDP,53/TCP   2hkubernetes-dashboard   10.108.45.66    <nodes>       80:32155/TCP    1hmonitoring-grafana     10.97.110.225   <nodes>       80:30687/TCP    1hmonitoring-influxdb    10.96.175.67    <none>        8086/TCP        1h

查看grafana的详细信息:

[root@localhost heapster]# kubectl  --namespace=kube-system describe svc monitoring-grafanaName:                   monitoring-grafanaNamespace:              kube-systemLabels:                 kubernetes.io/cluster-service=true                        kubernetes.io/name=monitoring-grafanaSelector:               k8s-app=grafanaType:                   NodePortIP:                     10.97.110.225Port:                   <unset> 80/TCPNodePort:               <unset> 30687/TCPEndpoints:              10.32.0.2:3000Session Affinity:       NoneNo events.

看到开放端口为30687
通过节点IP加端口号访问:
这里写图片描述

点图标:
这里写图片描述

点默认;
这里写图片描述

然后确认是k8s:
这里写图片描述

接下来:
这里写图片描述

查看图形:
这里写图片描述

0 0