kubernetes部署-Heapster(十)

kubernetes部署-Heapster
 

部署 Heapster 插件

官方github下载地址需要新版可以去下

创建所需yaml文件

cd /data/src
wget https://github.com/kubernetes/heapster/archive/v1.4.3.tar.gz
tar zxvf v1.4.3.tar.gz

cd heapster-1.4.3/deploy/kube-config/influxdb

[root@node influxdb]# pwd
/data/src/heapster-1.4.3/deploy/kube-config/influxdb
ls 
grafana.yaml  heapster.yaml  influxdb.yaml
————————————————————————————————————————
cat 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
      containers:
      - name: heapster
        image: benjjlu/heapster-amd64-v1.3.0-beta.1:1.0  #修改镜像地址
        imagePullPolicy: IfNotPresent
        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
———————————————————————————————————————— 
cat 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: benjjlu/heapster-influxdb-amd64-v1.1.1:1.1.1
        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
————————————————————————————————————————
cat 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: benjjlu/heapster-grafana-amd64-v4.0.2:1.0
        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 you're only using the API Server proxy, set this value instead:
          # value: /api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/
          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
  type: NodePort    #添加一行
  ports:
  - port: 80
    targetPort: 3000
  selector:
    k8s-app: grafana
————————————————————————————————————————
/data/src/heapster-1.4.3/deploy/kube-config/rbac
cat 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


get一下svc看一下端口

[root@node influxdb]# kubectl get svc --all-namespaces
NAMESPACE     NAME                   TYPE           CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
kube-system   heapster               ClusterIP      10.0.0.51    <none>        80/TCP           4h7m
kube-system   kube-dns               ClusterIP      10.0.0.2     <none>        53/UDP,53/TCP    4h32m
kube-system   kubernetes-dashboard   ClusterIP      10.0.0.233   <none>        443/TCP          5d23h
kube-system   monitoring-grafana     NodePort       10.0.0.111   <none>        80:44137/TCP     4h7m
kube-system   monitoring-influxdb    ClusterIP      10.0.0.132   <none>        8086/TCP         4h7m

可以看到端口是44137 我们可以单独访问grafana https://10.167.130.205:44137

kubernetes部署-Heapster(十)_第1张图片
参考文章
Kubernetes监控体系(三)之Heapster介绍

问题:发现图形数据是不更新的,以后再研究吧。

你可能感兴趣的:(k8s)