-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from paulfantom/rewrite
Rewrite code to use newer design pattern.
- Loading branch information
Showing
9 changed files
with
632 additions
and
768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,34 @@ | ||
local grafana = import 'grafana/grafana.libsonnet'; | ||
|
||
local basicWithImageRenderer = | ||
(grafana { | ||
_config+:: { | ||
namespace: 'monitoring-grafana', | ||
versions+:: { | ||
grafanaImageRenderer: '1.0.9', | ||
}, | ||
|
||
imageRepos+:: { | ||
grafanaImageRenderer: 'grafana/grafana-image-renderer', | ||
}, | ||
|
||
grafana+:: { | ||
imageRendererPort: 8081, | ||
imageRendererContainer: { | ||
requests: { cpu: '100m', memory: '100Mi' }, | ||
limits: { cpu: '200m', memory: '200Mi' }, | ||
}, | ||
|
||
env+: [ | ||
{ name: 'GF_RENDERING_SERVER_URL', value: 'http://localhost:' + $._config.grafana.imageRendererPort + '/render' }, | ||
{ name: 'GF_RENDERING_CALLBACK_URL', value: 'http://localhost:' + $._config.grafana.port }, | ||
], | ||
|
||
containers+: [ | ||
{ | ||
name: 'grafana-image-renderer', | ||
image: $._config.imageRepos.grafanaImageRenderer + ':' + $._config.versions.grafanaImageRenderer, | ||
ports: [{ name: 'http', containerPort: $._config.grafana.imageRendererPort }], | ||
resources: { | ||
requests: $._config.grafana.imageRendererContainer.requests, | ||
limits: $._config.grafana.imageRendererContainer.limits, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}).grafana; | ||
local imageRenderer = { | ||
name: 'grafana-image-renderer', | ||
image: 'grafana/grafana-image-renderer:1.0.9', | ||
ports: [{ name: 'http', containerPort: 8081 }], | ||
resources: { | ||
requests: { cpu: '100m', memory: '100Mi' }, | ||
limits: { cpu: '200m', memory: '200Mi' }, | ||
}, | ||
}; | ||
|
||
{ | ||
apiVersion: 'v1', | ||
kind: 'List', | ||
items: [ | ||
basicWithImageRenderer.dashboardSources, | ||
basicWithImageRenderer.dashboardDatasources, | ||
basicWithImageRenderer.deployment, | ||
basicWithImageRenderer.serviceAccount, | ||
basicWithImageRenderer.service { | ||
spec+: { ports: [ | ||
port { | ||
nodePort: 30910, | ||
} | ||
for port in super.ports | ||
] }, | ||
_config:: { | ||
namespace: 'monitoring-grafana', | ||
env: [ | ||
{ name: 'GF_RENDERING_SERVER_URL', value: 'http://localhost:' + imageRenderer.ports[0].containerPort + '/render' }, | ||
{ name: 'GF_RENDERING_CALLBACK_URL', value: 'http://localhost:' + $.grafana._config.port }, | ||
], | ||
}, | ||
|
||
grafana: grafana($._config) + { | ||
service+: { | ||
spec+: { | ||
ports: [ | ||
port { | ||
nodePort: 30910, | ||
} | ||
for port in super.ports | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,20 @@ | ||
local grafana = import 'grafana/grafana.libsonnet'; | ||
|
||
{ | ||
local basic = | ||
(grafana { | ||
_config+:: { | ||
namespace: 'monitoring-grafana', | ||
}, | ||
}).grafana, | ||
_config:: { | ||
namespace: 'monitoring-grafana', | ||
}, | ||
|
||
apiVersion: 'v1', | ||
kind: 'List', | ||
items: | ||
basic.dashboardDefinitions + | ||
[ | ||
basic.dashboardSources, | ||
basic.dashboardDatasources, | ||
basic.deployment, | ||
basic.serviceAccount, | ||
basic.service { | ||
spec+: { ports: [ | ||
grafana: grafana($._config) + { | ||
service+: { | ||
spec+: { | ||
ports: [ | ||
port { | ||
nodePort: 30910, | ||
} | ||
for port in super.ports | ||
] }, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,54 @@ | ||
local grafana = import 'github.com/grafana/grafonnet-lib/grafonnet/grafana.libsonnet'; | ||
local dashboard = grafana.dashboard; | ||
local row = grafana.row; | ||
local prometheus = grafana.prometheus; | ||
local template = grafana.template; | ||
local graphPanel = grafana.graphPanel; | ||
local grafonnet = import 'github.com/grafana/grafonnet-lib/grafonnet/grafana.libsonnet'; | ||
local dashboard = grafonnet.dashboard; | ||
local row = grafonnet.row; | ||
local prometheus = grafonnet.prometheus; | ||
local template = grafonnet.template; | ||
local graphPanel = grafonnet.graphPanel; | ||
|
||
local grafana = import 'grafana/grafana.libsonnet'; | ||
|
||
local grafanaWithDashboards = | ||
(grafana | ||
{ | ||
_config+:: { | ||
namespace: 'monitoring-grafana', | ||
grafana+:: { | ||
dashboards+:: { | ||
'my-dashboard.json': | ||
dashboard.new('My Dashboard') | ||
.addTemplate( | ||
{ | ||
current: { | ||
text: 'Prometheus', | ||
value: 'Prometheus', | ||
}, | ||
hide: 0, | ||
label: null, | ||
name: 'datasource', | ||
options: [], | ||
query: 'prometheus', | ||
refresh: 1, | ||
regex: '', | ||
type: 'datasource', | ||
}, | ||
) | ||
.addRow( | ||
row.new() | ||
.addPanel( | ||
graphPanel.new('My Panel', span=6, datasource='$datasource') | ||
.addTarget(prometheus.target('vector(1)')), | ||
) | ||
), | ||
}, | ||
}, | ||
}, | ||
}).grafana; | ||
|
||
{ | ||
apiVersion: 'v1', | ||
kind: 'List', | ||
items: | ||
grafanaWithDashboards.dashboardDefinitions + | ||
[ | ||
grafanaWithDashboards.dashboardSources, | ||
grafanaWithDashboards.dashboardDatasources, | ||
grafanaWithDashboards.deployment, | ||
grafanaWithDashboards.serviceAccount, | ||
grafanaWithDashboards.service { | ||
spec+: { ports: [ | ||
_config:: { | ||
namespace: 'monitoring-grafana', | ||
dashboards+: { | ||
'my-dashboard.json': | ||
dashboard.new('My Dashboard') | ||
.addTemplate( | ||
{ | ||
current: { | ||
text: 'Prometheus', | ||
value: 'Prometheus', | ||
}, | ||
hide: 0, | ||
label: null, | ||
name: 'datasource', | ||
options: [], | ||
query: 'prometheus', | ||
refresh: 1, | ||
regex: '', | ||
type: 'datasource', | ||
}, | ||
) | ||
.addRow( | ||
row.new() | ||
.addPanel( | ||
graphPanel.new('My Panel', span=6, datasource='$datasource') | ||
.addTarget(prometheus.target('vector(1)')), | ||
) | ||
), | ||
}, | ||
}, | ||
|
||
grafana: grafana($._config) + { | ||
service+: { | ||
spec+: { | ||
ports: [ | ||
port { | ||
nodePort: 30910, | ||
} | ||
for port in super.ports | ||
] }, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
} |
Oops, something went wrong.