Skip to content

Commit

Permalink
add the monitoring of resources on the cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjones-cisco committed Aug 19, 2015
1 parent ff65292 commit 474a559
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 3 deletions.
7 changes: 5 additions & 2 deletions group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ dns_replicas: 1
# Set to 'false' to disable default Kubernetes UI setup
enable_ui: true

# Set fo 'false' to disable default Elasticsearch + Kibana logging setup
enable_logging: true
# Set to 'false' to disable default Elasticsearch + Kibana logging setup
enable_logging: true

# Set to "false' to disable default Monitoring (cAdvisor + heapster + influxdb + grafana)
enable_monitoring: true
15 changes: 15 additions & 0 deletions roles/addons/files/grafana-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: monitoring-grafana
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "Grafana"
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: influxGrafana

32 changes: 32 additions & 0 deletions roles/addons/files/heapster-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v1
kind: ReplicationController
metadata:
name: monitoring-heapster-v8
namespace: kube-system
labels:
k8s-app: heapster
version: v8
kubernetes.io/cluster-service: "true"
spec:
replicas: 1
selector:
k8s-app: heapster
version: v8
template:
metadata:
labels:
k8s-app: heapster
version: v8
kubernetes.io/cluster-service: "true"
spec:
containers:
- image: gcr.io/google_containers/heapster:v0.17.0
name: heapster
resources:
limits:
cpu: 100m
memory: 300Mi
command:
- /heapster
- --source=kubernetes:''
- --sink=influxdb:http://monitoring-influxdb:8086
14 changes: 14 additions & 0 deletions roles/addons/files/heapster-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
kind: Service
apiVersion: v1
metadata:
name: monitoring-heapster
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "Heapster"
spec:
ports:
- port: 80
targetPort: 8082
selector:
k8s-app: heapster
53 changes: 53 additions & 0 deletions roles/addons/files/influxdb-grafana-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: v1
kind: ReplicationController
metadata:
name: monitoring-influx-grafana-v1
namespace: kube-system
labels:
k8s-app: influxGrafana
version: v1
kubernetes.io/cluster-service: "true"
spec:
replicas: 1
selector:
k8s-app: influxGrafana
version: v1
template:
metadata:
labels:
k8s-app: influxGrafana
version: v1
kubernetes.io/cluster-service: "true"
spec:
containers:
- image: gcr.io/google_containers/heapster_influxdb:v0.3
name: influxdb
resources:
limits:
cpu: 100m
memory: 200Mi
ports:
- containerPort: 8083
hostPort: 8083
- containerPort: 8086
hostPort: 8086
volumeMounts:
- name: influxdb-persistent-storage
mountPath: /data
- image: gcr.io/google_containers/heapster_grafana:v0.7
name: grafana
resources:
limits:
cpu: 100m
memory: 100Mi
env:
- name: INFLUXDB_EXTERNAL_URL
value: /api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb:api/db/
- name: INFLUXDB_HOST
value: monitoring-influxdb
- name: INFLUXDB_PORT
value: "8086"
volumes:
- name: influxdb-persistent-storage
emptyDir: {}

19 changes: 19 additions & 0 deletions roles/addons/files/influxdb-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: monitoring-influxdb
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "InfluxDB"
spec:
ports:
- name: http
port: 8083
targetPort: 8083
- name: api
port: 8086
targetPort: 8086
selector:
k8s-app: influxGrafana

5 changes: 4 additions & 1 deletion roles/addons/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@
when: enable_ui

- include: logging.yml
when: enable_logging
when: enable_logging

- include: monitoring.yml
when: enable_monitoring
121 changes: 121 additions & 0 deletions roles/addons/tasks/monitoring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
- name: Monitoring | Influxdb | Write controller file
sudo: yes
copy:
src: influxdb-grafana-controller.yaml
dest: "{{ kube_manifest_dir }}/influxdb-grafana-controller.yaml"
register: influxdb_rc_def
when: enable_monitoring
tags:
- addons
- monitoring

- name: Monitoring | Influxdb | Write service file
sudo: yes
copy:
src: influxdb-service.yaml
dest: "{{ kube_manifest_dir }}/influxdb-service.yaml"
register: influxdb_svc_def
when: enable_monitoring
tags:
- addons
- monitoring

- name: Monitoring | Grafana | Write service file
sudo: yes
copy:
src: grafana-service.yaml
dest: "{{ kube_manifest_dir }}/grafana-service.yaml"
register: grafana_svc_def
when: enable_monitoring
tags:
- addons
- monitoring

- name: Monitoring | Heapster | Write controller file
sudo: yes
copy:
src: heapster-controller.yaml
dest: "{{ kube_manifest_dir }}/heapster-controller.yaml"
register: heapster_rc_def
when: enable_monitoring
tags:
- addons
- monitoring

- name: Monitoring | Heapster | Write service file
sudo: yes
copy:
src: heapster-service.yaml
dest: "{{ kube_manifest_dir }}/heapster-service.yaml"
register: heapster_svc_def
when: enable_monitoring
tags:
- addons
- monitoring

- name: Monitoring | Influxdb | Create/update replication controller
sudo: yes
kube:
namespace: kube-system
resource: rc
name: monitoring-influx-grafana-v1
filename: "{{ kube_manifest_dir }}/influxdb-grafana-controller.yaml"
state: "{{ influxdb_rc_def.changed | ternary('latest','present') }}"
when: enable_monitoring
tags:
- addons
- monitoring

- name: Monitoring | Influxdb | Create/update service
sudo: yes
kube:
namespace: kube-system
resource: svc
name: monitoring-influxdb
filename: "{{ kube_manifest_dir }}/influxdb-service.yaml"
state: "{{ influxdb_svc_def.changed | ternary('latest','present') }}"
when: enable_monitoring
tags:
- addons
- monitoring

- name: Monitoring | Grafana | Create/update service
sudo: yes
kube:
namespace: kube-system
resource: svc
name: monitoring-grafana
filename: "{{ kube_manifest_dir }}/grafana-service.yaml"
state: "{{ grafana_svc_def.changed | ternary('latest','present') }}"
when: enable_monitoring
tags:
- addons
- monitoring

- name: Monitoring | Heapster | Create/update replication controller
sudo: yes
kube:
namespace: kube-system
resource: rc
name: monitoring-heapster-v8
filename: "{{ kube_manifest_dir }}/heapster-controller.yaml"
state: "{{ heapster_rc_def.changed | ternary('latest','present') }}"
when: enable_monitoring
tags:
- addons
- monitoring

- name: Monitoring | Heapster | Create/update service
sudo: yes
kube:
namespace: kube-system
resource: svc
name: monitoring-heapster
filename: "{{ kube_manifest_dir }}/heapster-service.yaml"
state: "{{ heapster_svc_def.changed | ternary('latest','present') }}"
when: enable_monitoring
tags:
- addons
- monitoring

0 comments on commit 474a559

Please sign in to comment.