diff --git a/roles/kubernetes-apps/heapster/default/main.yml b/roles/kubernetes-apps/heapster/default/main.yml new file mode 100644 index 000000000..6dc88d0d8 --- /dev/null +++ b/roles/kubernetes-apps/heapster/default/main.yml @@ -0,0 +1,2 @@ +--- +heapster_namespace: kube-system diff --git a/roles/kubernetes-apps/heapster/tasks/main.yml b/roles/kubernetes-apps/heapster/tasks/main.yml new file mode 100644 index 000000000..fa8278a1b --- /dev/null +++ b/roles/kubernetes-apps/heapster/tasks/main.yml @@ -0,0 +1,23 @@ +--- +- name: Heapster | Lay Down Heaspter Templates + template: src={{item.file}} dest={{kube_config_dir}}/{{item.file}} + with_items: + - {file: grafana-deployment.yaml, type: deployment, name: monitoring-grafana} + - {file: grafana-service.yaml, type: svc, name: monitoring-grafana} + - {file: heapster-deployment.yaml, type: deployment, name: heapster} + - {file: heapster-service.yaml, type: svc, name: heapster} + - {file: influxdb-deployment.yaml, type: deployment, name: monitoring-influxdb} + - {file: influxdb-service.yaml, type: svc, name: monitoring-influxdb} + register: manifests + when: inventory_hostname == groups['kube-master'][0] + +- name: Heapster| Start Resources + kube: + name: "{{item.item.name}}" + namespace: "{{heapster_namespace}}" + kubectl: "{{bin_dir}}/kubectl" + resource: "{{item.item.type}}" + filename: "{{kube_config_dir}}/{{item.item.file}}" + state: "{{item.changed | ternary('latest','present') }}" + with_items: "{{ manifests.results }}" + when: inventory_hostname == groups['kube-master'][0] diff --git a/roles/kubernetes-apps/heapster/templates/grafana-deployment.yaml b/roles/kubernetes-apps/heapster/templates/grafana-deployment.yaml new file mode 100644 index 000000000..fffa92151 --- /dev/null +++ b/roles/kubernetes-apps/heapster/templates/grafana-deployment.yaml @@ -0,0 +1,44 @@ +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: gcr.io/google_containers/heapster-grafana-amd64:v4.0.2 + 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 + # 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: {} diff --git a/roles/kubernetes-apps/heapster/templates/grafana-service.yaml b/roles/kubernetes-apps/heapster/templates/grafana-service.yaml new file mode 100644 index 000000000..2f14612dd --- /dev/null +++ b/roles/kubernetes-apps/heapster/templates/grafana-service.yaml @@ -0,0 +1,21 @@ +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 + ports: + - port: 80 + targetPort: 3000 + selector: + k8s-app: grafana diff --git a/roles/kubernetes-apps/heapster/templates/heapster-deployment.yaml b/roles/kubernetes-apps/heapster/templates/heapster-deployment.yaml new file mode 100644 index 000000000..78f7478f6 --- /dev/null +++ b/roles/kubernetes-apps/heapster/templates/heapster-deployment.yaml @@ -0,0 +1,21 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: heapster + namespace: kube-system +spec: + replicas: 1 + template: + metadata: + labels: + task: monitoring + k8s-app: heapster + spec: + containers: + - name: heapster + image: gcr.io/google_containers/heapster-amd64:v1.3.0-beta.1 + imagePullPolicy: IfNotPresent + command: + - /heapster + - --source=kubernetes:https://kubernetes.default + - --sink=influxdb:http://monitoring-influxdb:8086 diff --git a/roles/kubernetes-apps/heapster/templates/heapster-service.yaml b/roles/kubernetes-apps/heapster/templates/heapster-service.yaml new file mode 100644 index 000000000..097d8ee05 --- /dev/null +++ b/roles/kubernetes-apps/heapster/templates/heapster-service.yaml @@ -0,0 +1,17 @@ +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/kubernetes-apps/heapster/templates/influxdb-deployment.yaml b/roles/kubernetes-apps/heapster/templates/influxdb-deployment.yaml new file mode 100644 index 000000000..bb6bd2b35 --- /dev/null +++ b/roles/kubernetes-apps/heapster/templates/influxdb-deployment.yaml @@ -0,0 +1,22 @@ +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: gcr.io/google_containers/heapster-influxdb-amd64:v1.1.1 + volumeMounts: + - mountPath: /data + name: influxdb-storage + volumes: + - name: influxdb-storage + emptyDir: {} diff --git a/roles/kubernetes-apps/heapster/templates/influxdb-service.yaml b/roles/kubernetes-apps/heapster/templates/influxdb-service.yaml new file mode 100644 index 000000000..6b5689d53 --- /dev/null +++ b/roles/kubernetes-apps/heapster/templates/influxdb-service.yaml @@ -0,0 +1,17 @@ +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 diff --git a/roles/kubernetes-apps/meta/main.yml b/roles/kubernetes-apps/meta/main.yml index c2dd39d73..ec3e4cc4a 100644 --- a/roles/kubernetes-apps/meta/main.yml +++ b/roles/kubernetes-apps/meta/main.yml @@ -15,3 +15,5 @@ dependencies: - role: kubernetes-apps/helm when: helm_enabled tags: [ apps, helm ] + - role: kubernetes-apps/heapster + tags: [ apps, heapster ]