ace's grafana reads InfluxDB through a data source somebody typed into its database: a LAN address, a database InfluxDB 2 does not have, and a password for a v1 user of an earlier instance. Nothing in the mesh knew it existed, so migrating influxdb could only break it further. grafana now requires influxdb-api, contributes read access, and the mesh renders a provisioning file grafana reads at start: the address, port, org's default bucket (as the InfluxQL database) and its own login from the binding, the password by $__file from the pair credential the mesh delivers, 0400 for grafana's uid 472. It is a data source of its own name and uid, read-only in the UI and not the default, so the data source a person made is never overwritten; a changed binding or a rotated password restarts grafana, which re-reads the file. Includes #152 (merged into this branch): influxdb provides influxdb-api.
186 lines
5.9 KiB
JSON
186 lines
5.9 KiB
JSON
{
|
|
"module": "grafana",
|
|
"version": "1",
|
|
"emits": [
|
|
"alert.firing"
|
|
],
|
|
"own-secrets": {
|
|
"admin": "/var/lib/mesh/grafana/admin",
|
|
"broker": "/var/lib/mesh/grafana/broker"
|
|
},
|
|
"capabilities": [
|
|
"container-runtime"
|
|
],
|
|
"listens": [
|
|
{
|
|
"name": "web",
|
|
"port": 3000,
|
|
"protocol": "tcp",
|
|
"from": "mesh",
|
|
"why": "the dashboards. Also 3000 inside, like the forge - which is the mesh's port assignment earning its keep"
|
|
}
|
|
],
|
|
"resources": [
|
|
{
|
|
"id": "mesh-state",
|
|
"type": "directory",
|
|
"path": "/var/lib/mesh/grafana",
|
|
"mode": "0700"
|
|
},
|
|
{
|
|
"id": "state",
|
|
"type": "directory",
|
|
"mode": "0700",
|
|
"place": "."
|
|
},
|
|
{
|
|
"id": "data",
|
|
"type": "directory",
|
|
"mode": "0700",
|
|
"owner": "472:472"
|
|
},
|
|
{
|
|
"id": "admin-secret",
|
|
"type": "file",
|
|
"path": "${dir:state}/admin.secret",
|
|
"mode": "0400",
|
|
"owner": "472:472",
|
|
"content": "${secret:admin}"
|
|
},
|
|
{
|
|
"id": "oidc-secret",
|
|
"type": "file",
|
|
"path": "${dir:state}/oidc-client.secret",
|
|
"mode": "0400",
|
|
"owner": "472:472",
|
|
"content": "${secret:oidc-client}"
|
|
},
|
|
{
|
|
"id": "oidc-env",
|
|
"type": "file",
|
|
"path": "${dir:state}/oidc.env",
|
|
"mode": "0644",
|
|
"content": "GF_SERVER_ROOT_URL=https://${bound:route:name}\nGF_AUTH_GENERIC_OAUTH_ENABLED=true\nGF_AUTH_GENERIC_OAUTH_NAME=Keycloak\nGF_AUTH_GENERIC_OAUTH_CLIENT_ID=${bound:oidc-client:as}\nGF_AUTH_GENERIC_OAUTH_CLIENT_SECRET__FILE=/run/secrets/oidc-client\nGF_AUTH_GENERIC_OAUTH_SCOPES=openid email profile roles\nGF_AUTH_GENERIC_OAUTH_AUTH_URL=${bound:oidc-client:issuer}${bound:oidc-client:authorization-path}\nGF_AUTH_GENERIC_OAUTH_TOKEN_URL=${bound:oidc-client:issuer}${bound:oidc-client:token-path}\nGF_AUTH_GENERIC_OAUTH_API_URL=${bound:oidc-client:issuer}${bound:oidc-client:userinfo-path}\nGF_AUTH_GENERIC_OAUTH_ROLE_ATTRIBUTE_PATH=contains(roles[*], 'admin') && 'Admin' || contains(realm_access.roles[*], 'admin') && 'Admin' || 'Viewer'\nGF_AUTH_GENERIC_OAUTH_USE_PKCE=true\nGF_AUTH_GENERIC_OAUTH_ALLOW_SIGN_UP=true\nGF_AUTH_GENERIC_OAUTH_ALLOW_ASSIGN_GRAFANA_ADMIN=true\n"
|
|
},
|
|
{
|
|
"id": "influxdb-secret",
|
|
"type": "file",
|
|
"path": "${dir:state}/influxdb-api.secret",
|
|
"mode": "0400",
|
|
"owner": "472:472",
|
|
"content": "${secret:influxdb-api}"
|
|
},
|
|
{
|
|
"id": "influxdb-datasource",
|
|
"type": "file",
|
|
"path": "${dir:state}/datasource-influxdb.yaml",
|
|
"mode": "0644",
|
|
"content": "apiVersion: 1\n# Written by the mesh from grafana's influxdb-api binding; grafana reads it at start. Its own name and\n# uid, so a data source somebody made in the UI is never overwritten, and read-only in the UI because\n# the mesh resets it. The password is read from the file the mesh delivers, never written here.\ndatasources:\n - name: InfluxDB (mesh)\n uid: mesh-influxdb-api\n type: influxdb\n access: proxy\n url: ${bound:influxdb-api:scheme}://${bound:influxdb-api:at}:${bound:influxdb-api:port}\n user: ${bound:influxdb-api:as}\n isDefault: false\n editable: false\n jsonData:\n dbName: ${bound:influxdb-api:bucket}\n httpMode: POST\n secureJsonData:\n password: $__file{/run/secrets/influxdb-api}\n"
|
|
},
|
|
{
|
|
"id": "server",
|
|
"type": "container",
|
|
"name": "grafana",
|
|
"image": "grafana/grafana@sha256:ac461fb352abc50da10a51c7d02462e9c05488f11f53f14b3ad79a8145f638a0",
|
|
"ports": [
|
|
"3000"
|
|
],
|
|
"volumes": [
|
|
"${dir:data}:/var/lib/grafana",
|
|
"${dir:state}/admin.secret:/run/secrets/admin:ro",
|
|
"${dir:state}/oidc-client.secret:/run/secrets/oidc-client:ro",
|
|
"${dir:state}/influxdb-api.secret:/run/secrets/influxdb-api:ro",
|
|
"${dir:state}/datasource-influxdb.yaml:/etc/grafana/provisioning/datasources/mesh-influxdb.yaml:ro"
|
|
],
|
|
"env": {
|
|
"GF_SECURITY_ADMIN_PASSWORD__FILE": "/run/secrets/admin"
|
|
},
|
|
"env-file": [
|
|
"${dir:state}/oidc.env"
|
|
],
|
|
"restart-on": [
|
|
"oidc-env",
|
|
"oidc-secret",
|
|
"influxdb-datasource",
|
|
"influxdb-secret"
|
|
]
|
|
},
|
|
{
|
|
"id": "runtime-config",
|
|
"type": "file",
|
|
"path": "/var/lib/mesh/grafana/config.json",
|
|
"mode": "0600",
|
|
"content": "{\n \"user\": \"admin\",\n \"password\": \"${secret:admin}\"\n}\n",
|
|
"merge": "json"
|
|
},
|
|
{
|
|
"id": "runtime",
|
|
"type": "container",
|
|
"name": "mesh-grafana",
|
|
"network": "host",
|
|
"volumes": [
|
|
"/var/lib/mesh/grafana/broker:/run/secrets/broker:ro",
|
|
"/var/lib/mesh/grafana/config.json:/run/config/config.json:ro"
|
|
],
|
|
"env": {
|
|
"MESH_BROKER_FILE": "/run/secrets/broker",
|
|
"MESH_GRAFANA_URL": "http://127.0.0.1:${port:3000}",
|
|
"MESH_GRAFANA_CONFIG_FILE": "/run/config/config.json"
|
|
},
|
|
"restart-on": [
|
|
"runtime-config"
|
|
],
|
|
"artifact": "runtime"
|
|
}
|
|
],
|
|
"requires": [
|
|
"route",
|
|
"oidc-client",
|
|
"influxdb-api"
|
|
],
|
|
"contributes": {
|
|
"route": {
|
|
"label": "grafana",
|
|
"endpoint": "web"
|
|
},
|
|
"oidc-client": {
|
|
"label": "grafana",
|
|
"endpoint": "web",
|
|
"callback": "/login/generic_oauth"
|
|
},
|
|
"influxdb-api": {
|
|
"access": "read"
|
|
}
|
|
},
|
|
"binds": {
|
|
"route": "${dir:state}/route.json",
|
|
"oidc-client": "${dir:state}/oidc.json",
|
|
"influxdb-api": "${dir:state}/influxdb.json"
|
|
},
|
|
"secrets": {
|
|
"oidc-client": "/var/lib/mesh/grafana/oidc-client",
|
|
"influxdb-api": "/var/lib/mesh/grafana/influxdb-api"
|
|
},
|
|
"build": {
|
|
"on": [
|
|
{
|
|
"arg": "BUILD_BASE",
|
|
"module": "mesh-tools",
|
|
"artifact": "build"
|
|
},
|
|
{
|
|
"arg": "RUNTIME_BASE",
|
|
"module": "mesh-tools",
|
|
"artifact": "runtime"
|
|
}
|
|
],
|
|
"artifacts": [
|
|
{
|
|
"name": "runtime",
|
|
"kind": "image",
|
|
"from": "Dockerfile"
|
|
}
|
|
]
|
|
}
|
|
}
|