diff --git a/.gitignore b/.gitignore index 51662fd..69c94eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .vagrant -config.rb +admin.conf diff --git a/README.md b/README.md index 36d2cad..04073e1 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,9 @@ weave-net-ph7l3 2/2 Running 0 1h - weave-net - dashboard +## Extra plugins +- Grafana + InfluxDB (must be activated in config.rb) + ## Prerequisites - Vagrant 1.8 (with NFS support) @@ -54,6 +57,8 @@ $master_memory = 1536 $worker_count = 2 # Total memory of nodes $worker_memory = 1536 +# Add Grafana with InfluxDB (work with heapster) +$grafana = false ``` ### Basic usage diff --git a/Vagrantfile b/Vagrantfile index 98a116e..238d7f4 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -44,6 +44,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| s.inline = "sh /vagrant/install.sh $1 $2 $3 $4" if i == $worker_count s.args = ["-node", "#{ip}", "-last", "#{$token}"] + #EXTRA ADDONS + if $grafana + node.vm.provision :shell, :inline => "kubectl --kubeconfig /shared/admin.conf apply -f /vagrant/influxdb/" + end else s.args = ["-node", "#{ip}", "none", "#{$token}"] end diff --git a/config.rb b/config.rb new file mode 100644 index 0000000..2485ae2 --- /dev/null +++ b/config.rb @@ -0,0 +1,10 @@ +# If you change, Keep the structure with the dot. [0-9 a-f] +$token = "56225f.9096af3559800a6a" +# Total memory of master +$master_memory = 1536 +# Increment to have more nodes +$worker_count = 2 +# Total memory of nodes +$worker_memory = 1536 +# Add Grafana with InfluxDB (work with heapster) +$grafana = false diff --git a/influxdb/grafana-deployment.yaml b/influxdb/grafana-deployment.yaml new file mode 100644 index 0000000..7edfee1 --- /dev/null +++ b/influxdb/grafana-deployment.yaml @@ -0,0 +1,43 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: monitoring-grafana + namespace: kube-system +spec: + 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: / diff --git a/influxdb/grafana-service.yaml b/influxdb/grafana-service.yaml new file mode 100644 index 0000000..ce7070a --- /dev/null +++ b/influxdb/grafana-service.yaml @@ -0,0 +1,20 @@ +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 + type: NodePort + ports: + - port: 80 + targetPort: 3000 + selector: + k8s-app: grafana diff --git a/influxdb/heapster-deployment.yaml b/influxdb/heapster-deployment.yaml new file mode 100644 index 0000000..369560a --- /dev/null +++ b/influxdb/heapster-deployment.yaml @@ -0,0 +1,22 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: heapster + namespace: kube-system +spec: + replicas: 1 + template: + metadata: + labels: + task: monitoring + k8s-app: heapster + version: v6 + spec: + containers: + - name: heapster + image: gcr.io/google_containers/heapster:v1.2.0 + imagePullPolicy: Always + command: + - /heapster + - --source=kubernetes:https://kubernetes.default + - --sink=influxdb:http://monitoring-influxdb:8086 diff --git a/influxdb/heapster-service.yaml b/influxdb/heapster-service.yaml new file mode 100644 index 0000000..097d8ee --- /dev/null +++ b/influxdb/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/influxdb/influxdb-deployment.yaml b/influxdb/influxdb-deployment.yaml new file mode 100644 index 0000000..dae1254 --- /dev/null +++ b/influxdb/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: + volumes: + - name: influxdb-storage + emptyDir: {} + containers: + - name: influxdb + image: kubernetes/heapster_influxdb:v0.6 + volumeMounts: + - mountPath: /data + name: influxdb-storage diff --git a/influxdb/influxdb-service.yaml b/influxdb/influxdb-service.yaml new file mode 100644 index 0000000..44a7da0 --- /dev/null +++ b/influxdb/influxdb-service.yaml @@ -0,0 +1,24 @@ +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: + # InfluxDB has a UI that can be used to query, uncomment the `http` port and expose + # to access this service. + # type: NodePort + ports: + # - name: http + # port: 80 + # targetPort: 8083 + - name: api + port: 8086 + targetPort: 8086 + selector: + k8s-app: influxdb