Skip to content

Commit

Permalink
Add Grafana to conduit install
Browse files Browse the repository at this point in the history
`conduit install` deploys prometheus, but lacks a general-purpose way to
visualize that data.

This change adds a Grafana container to the `conduit install` command. It
includes two sample dashboards, viz and health, in their own respective
source files.

Part of #420

Signed-off-by: Andrew Seigner <[email protected]>
  • Loading branch information
siggy committed Feb 28, 2018
1 parent 41bef41 commit b3d4e69
Show file tree
Hide file tree
Showing 9 changed files with 711 additions and 1 deletion.
4 changes: 4 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ bin/conduit stat deployments

# view a live pipeline of requests
bin/conduit tap deploy emojivoto/voting

# view grafana dashboard
kubectl -n conduit port-forward $(kubectl --namespace=conduit get po --selector=app=grafana -o jsonpath='{.items[*].metadata.name}') 3000:3000
open http://localhost:3000
```

## Go
Expand Down
6 changes: 6 additions & 0 deletions cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ type installConfig struct {
ControllerImage string
WebImage string
PrometheusImage string
GrafanaImage string
VizDashboard string
HealthDashboard string
ControllerReplicas uint
WebReplicas uint
PrometheusReplicas uint
Expand Down Expand Up @@ -63,6 +66,9 @@ func validateAndBuildConfig() (*installConfig, error) {
ControllerImage: fmt.Sprintf("%s/controller:%s", dockerRegistry, conduitVersion),
WebImage: fmt.Sprintf("%s/web:%s", dockerRegistry, conduitVersion),
PrometheusImage: "prom/prometheus:v2.1.0",
GrafanaImage: "grafana/grafana:5.0.0-beta4",
VizDashboard: install.Viz,
HealthDashboard: install.Health,
ControllerReplicas: controllerReplicas,
WebReplicas: webReplicas,
PrometheusReplicas: prometheusReplicas,
Expand Down
3 changes: 3 additions & 0 deletions cli/cmd/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func TestRender(t *testing.T) {
ControllerImage: "ControllerImage",
WebImage: "WebImage",
PrometheusImage: "PrometheusImage",
GrafanaImage: "GrafanaImage",
VizDashboard: "VizDashboard",
HealthDashboard: "HealthDashboard",
ControllerReplicas: 1,
WebReplicas: 2,
PrometheusReplicas: 3,
Expand Down
7 changes: 6 additions & 1 deletion cli/cmd/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ func diffCompare(t *testing.T, actual string, expected string) {
if actual != expected {
dmp := diffmatchpatch.New()
diffs := dmp.DiffMain(expected, actual, true)
patches := dmp.PatchMake(expected, diffs)

// colorized output for local testing
// t.Fatalf("Unexpected output:\n%+v", dmp.DiffPrettyText(diffs))

diffs = dmp.DiffCleanupSemantic(diffs)
patches := dmp.PatchMake(diffs)
patchText := dmp.PatchToText(patches)
t.Fatalf("Unexpected output:\n%+v", patchText)
}
Expand Down
269 changes: 269 additions & 0 deletions cli/cmd/testdata/install_default.golden
Original file line number Diff line number Diff line change
Expand Up @@ -546,4 +546,273 @@ data:
- source_labels: [__meta_kubernetes_pod_container_name]
action: replace
target_label: job

### Grafana ###
---
kind: Service
apiVersion: v1
metadata:
name: grafana
namespace: conduit
labels:
conduit.io/control-plane-component: grafana
annotations:
conduit.io/created-by: conduit/cli undefined
spec:
type: ClusterIP
selector:
conduit.io/control-plane-component: grafana
ports:
- name: http
port: 3000
targetPort: 3000

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
conduit.io/created-by: conduit/cli undefined
creationTimestamp: null
labels:
conduit.io/control-plane-component: grafana
name: grafana
namespace: conduit
spec:
replicas: 1
strategy: {}
template:
metadata:
annotations:
conduit.io/created-by: conduit/cli undefined
conduit.io/proxy-version: undefined
creationTimestamp: null
labels:
conduit.io/control-plane-component: grafana
conduit.io/control-plane-ns: conduit
spec:
containers:
- image: grafana/grafana:5.0.0-beta4
imagePullPolicy: IfNotPresent
name: grafana
ports:
- containerPort: 3000
name: http
resources: {}
volumeMounts:
- mountPath: /etc/grafana
name: grafana-config
readOnly: true
- mountPath: /var/lib/grafana/dashboards
name: grafana-dashboards
- mountPath: /usr/share/grafana/public/dashboards
name: grafana-dashboard-home
readOnly: true
- env:
- name: CONDUIT_PROXY_LOG
value: warn,conduit_proxy=info
- name: CONDUIT_PROXY_CONTROL_URL
value: tcp://proxy-api.conduit.svc.cluster.local:8086
- name: CONDUIT_PROXY_CONTROL_LISTENER
value: tcp://0.0.0.0:4190
- name: CONDUIT_PROXY_PRIVATE_LISTENER
value: tcp://127.0.0.1:4140
- name: CONDUIT_PROXY_PUBLIC_LISTENER
value: tcp://0.0.0.0:4143
- name: CONDUIT_PROXY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: CONDUIT_PROXY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: CONDUIT_PROXY_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: CONDUIT_PROXY_DESTINATIONS_AUTOCOMPLETE_FQDN
value: Kubernetes
image: gcr.io/runconduit/proxy:undefined
imagePullPolicy: IfNotPresent
name: conduit-proxy
ports:
- containerPort: 4143
name: conduit-proxy
resources: {}
securityContext:
runAsUser: 2102
initContainers:
- args:
- --incoming-proxy-port
- "4143"
- --outgoing-proxy-port
- "4140"
- --proxy-uid
- "2102"
- --inbound-ports-to-ignore
- "4190"
image: gcr.io/runconduit/proxy-init:undefined
imagePullPolicy: IfNotPresent
name: conduit-init
resources: {}
securityContext:
capabilities:
add:
- NET_ADMIN
privileged: false
volumes:
- configMap:
items:
- key: grafana.ini
path: grafana.ini
- key: datasources.yaml
path: provisioning/datasources/datasources.yaml
- key: dashboards.yaml
path: provisioning/dashboards/dashboards.yaml
name: grafana-config
name: grafana-config
- configMap:
name: grafana-dashboards
name: grafana-dashboards
- configMap:
items:
- key: conduit-viz.json
path: home.json
name: grafana-dashboards
name: grafana-dashboard-home
status: {}
---
kind: ConfigMap
apiVersion: v1
metadata:
name: grafana-config
namespace: conduit
labels:
conduit.io/control-plane-component: grafana
annotations:
conduit.io/created-by: conduit/cli undefined
data:
grafana.ini: |-
instance_name = conduit-grafana

[auth]
disable_login_form = true

[auth.anonymous]
enabled = true
org_role = Editor

[auth.basic]
enabled = false

datasources.yaml: |-
apiVersion: 1
datasources:
- name: prometheus
type: prometheus
access: proxy
orgId: 1
url: http://prometheus.conduit.svc.cluster.local:9090
isDefault: true
jsonData:
timeInterval: "5s"
version: 1
editable: true

dashboards.yaml: |-
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: true
editable: true
options:
path: /var/lib/grafana/dashboards
homeDashboardId: conduit-viz

---
kind: ConfigMap
apiVersion: v1
metadata:
name: grafana-dashboards
namespace: conduit
labels:
conduit.io/control-plane-component: grafana
annotations:
conduit.io/created-by: conduit/cli undefined
data:
conduit-viz.json: |-
{
"rows": [
{
"collapse": false,
"height": "50px",
"panels": [
{
"content": "<div>\n <div style=\"position: absolute; top: 0, left: 0\">\n <a href=\"https://conduit.io\" target=\"_blank\"><img src=\"https://conduit.io/images/conduit-primary-white.svg\" style=\"height: 30px;\"></a>\n </div>\n <div style=\"position: absolute; top: 0; right: 0; font-size: 15px\">\n <a href=\"https://conduit.io\" target=\"_blank\">Conduit</a> is a next-generation ultralight service mesh for Kubernetes.\n <br>\n Need help? Visit <a href=\"https://conduit.io\" target=\"_blank\">conduit.io</a>.\n </div>\n</div>",
"height": "1px",
"id": 14,
"links": [],
"mode": "html",
"span": 12,
"title": "",
"transparent": true,
"type": "text"
}
],
"showTitle": false
},
{
"collapse": false,
"height": 250,
"panels": [
{
"legend": {
},
"lines": true,
"targets": [
{
"expr": "sum(irate(responses_total[20s])) by (target_deployment)",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{target_deployment}}",
"refId": "A"
}
],
"title": "Request Volume",
"type": "graph",
"xaxis": {
"show": true
},
"yaxes": [
{
"format": "rps",
"show": true
},
{
"show": true
}
]
}
],
"showTitle": false
}
],
"refresh": "5s",
"time": {
"from": "now-5m",
"to": "now"
},
"title": "conduit-viz"
}


conduit-health.json: |-
{
"title": "conduit-health"
}

---
Loading

0 comments on commit b3d4e69

Please sign in to comment.