From a076a384adb11cfccd0cd1e3500603d050b55d19 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Fri, 22 Mar 2019 16:11:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=89=E8=A3=85dashboard?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E5=AE=89=E8=A3=85heapster?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../heapster/heapster-only/heapster.yaml | 74 +++++++++++++++++++ roles/cluster-addon/defaults/main.yml | 2 +- roles/cluster-addon/tasks/main.yml | 4 +- 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 manifests/heapster/heapster-only/heapster.yaml diff --git a/manifests/heapster/heapster-only/heapster.yaml b/manifests/heapster/heapster-only/heapster.yaml new file mode 100644 index 0000000..e916970 --- /dev/null +++ b/manifests/heapster/heapster-only/heapster.yaml @@ -0,0 +1,74 @@ +--- +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: apps/v1beta1 +kind: Deployment +metadata: + name: heapster + namespace: kube-system +spec: + replicas: 1 + selector: + matchLabels: + k8s-app: heapster + template: + metadata: + labels: + task: monitoring + k8s-app: heapster + spec: + serviceAccountName: heapster + containers: + - name: heapster + #image: gcr.io/google_containers/heapster-amd64:v1.5.4 + image: mirrorgooglecontainers/heapster-amd64:v1.5.4 + imagePullPolicy: IfNotPresent + command: + - /heapster + #- --source=kubernetes:https://kubernetes.default + - --source=kubernetes.summary_api:'' + #- --sink=influxdb:http://monitoring-influxdb.kube-system.svc:8086 + livenessProbe: + httpGet: + path: /healthz + port: 8082 + scheme: HTTP + initialDelaySeconds: 180 + timeoutSeconds: 5 +--- +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 diff --git a/roles/cluster-addon/defaults/main.yml b/roles/cluster-addon/defaults/main.yml index b66a3de..e109346 100644 --- a/roles/cluster-addon/defaults/main.yml +++ b/roles/cluster-addon/defaults/main.yml @@ -15,7 +15,7 @@ metricsserver_offline: "metrics-server_v0.3.1.tar" # dashboard 自动安装 dashboard_install: "yes" -dashboard_offline: "dashboard_v1.10.0.tar" +dashboard_offline: "dashboard_v1.10.1.tar" # ingress 自动安装,可选 "traefik" 和 "nginx-ingress" ingress_install: "no" diff --git a/roles/cluster-addon/tasks/main.yml b/roles/cluster-addon/tasks/main.yml index 2dc2c7a..d370500 100644 --- a/roles/cluster-addon/tasks/main.yml +++ b/roles/cluster-addon/tasks/main.yml @@ -67,6 +67,7 @@ when: '"metrics-server" not in pod_info.stdout and metricsserver_install == "yes"' ignore_errors: true +# 现阶段 dashboard 获取metrics仍旧依赖于heapster,因此需连带安装heapster - block: - name: 尝试推送离线 dashboard镜像(若执行失败,可忽略) copy: src={{ base_dir }}/down/{{ dashboard_offline }} dest=/opt/kube/images/{{ dashboard_offline }} @@ -81,7 +82,8 @@ when: 'dashboard_offline in image_info.stdout' - name: 创建 dashboard部署 - shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/dashboard" + shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/dashboard && \ + {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/heapster/heapster-only" delegate_to: "{{ groups.deploy[0] }}" run_once: true when: '"kubernetes-dashboard" not in pod_info.stdout and dashboard_install == "yes"'