grafana-ocp-oauth.yml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. ---
  2. kind: Template
  3. apiVersion: v1
  4. metadata:
  5. name: grafana-ocp
  6. annotations:
  7. "openshift.io/display-name": Grafana ocp
  8. description: |
  9. Grafana server with patched Prometheus datasource.
  10. iconClass: icon-cogs
  11. tags: "metrics,monitoring,grafana,prometheus"
  12. parameters:
  13. - description: The location of the proxy image
  14. name: IMAGE_GF
  15. value: mrsiano/grafana-ocp:latest
  16. - description: The location of the proxy image
  17. name: IMAGE_PROXY
  18. value: openshift/oauth-proxy:v1.0.0
  19. - description: External URL for the grafana route
  20. name: ROUTE_URL
  21. value: ""
  22. - description: The namespace to instantiate heapster under. Defaults to 'grafana'.
  23. name: NAMESPACE
  24. value: grafana
  25. - description: The session secret for the proxy
  26. name: SESSION_SECRET
  27. generate: expression
  28. from: "[a-zA-Z0-9]{43}"
  29. objects:
  30. - apiVersion: v1
  31. kind: ServiceAccount
  32. metadata:
  33. name: grafana-ocp
  34. namespace: "${NAMESPACE}"
  35. annotations:
  36. serviceaccounts.openshift.io/oauth-redirectreference.primary: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"grafana-ocp"}}'
  37. - apiVersion: authorization.openshift.io/v1
  38. kind: ClusterRoleBinding
  39. metadata:
  40. name: gf-cluster-reader
  41. roleRef:
  42. name: cluster-reader
  43. subjects:
  44. - kind: ServiceAccount
  45. name: grafana-ocp
  46. namespace: "${NAMESPACE}"
  47. - apiVersion: route.openshift.io/v1
  48. kind: Route
  49. metadata:
  50. name: grafana-ocp
  51. namespace: "${NAMESPACE}"
  52. spec:
  53. host: "${ROUTE_URL}"
  54. to:
  55. name: grafana-ocp
  56. tls:
  57. termination: Reencrypt
  58. - apiVersion: v1
  59. kind: Service
  60. metadata:
  61. name: grafana-ocp
  62. annotations:
  63. prometheus.io/scrape: "true"
  64. prometheus.io/scheme: https
  65. service.alpha.openshift.io/serving-cert-secret-name: gf-tls
  66. namespace: "${NAMESPACE}"
  67. labels:
  68. metrics-infra: grafana-ocp
  69. name: grafana-ocp
  70. spec:
  71. ports:
  72. - name: grafana-ocp
  73. port: 443
  74. protocol: TCP
  75. targetPort: 8443
  76. selector:
  77. app: grafana-ocp
  78. - apiVersion: v1
  79. kind: Secret
  80. metadata:
  81. name: gf-proxy
  82. namespace: "${NAMESPACE}"
  83. stringData:
  84. session_secret: "${SESSION_SECRET}="
  85. # Deploy Prometheus behind an oauth proxy
  86. - apiVersion: extensions/v1beta1
  87. kind: Deployment
  88. metadata:
  89. labels:
  90. app: grafana-ocp
  91. name: grafana-ocp
  92. namespace: "${NAMESPACE}"
  93. spec:
  94. replicas: 1
  95. selector:
  96. matchLabels:
  97. app: grafana-ocp
  98. template:
  99. metadata:
  100. labels:
  101. app: grafana-ocp
  102. name: grafana-ocp-app
  103. spec:
  104. serviceAccountName: grafana-ocp
  105. containers:
  106. - name: oauth-proxy
  107. image: ${IMAGE_PROXY}
  108. imagePullPolicy: IfNotPresent
  109. ports:
  110. - containerPort: 8443
  111. name: web
  112. args:
  113. - -https-address=:8443
  114. - -http-address=
  115. - -email-domain=*
  116. - -client-id=system:serviceaccount:${NAMESPACE}:grafana-ocp
  117. - -upstream=http://localhost:3000
  118. - -provider=openshift
  119. # - '-openshift-delegate-urls={"/api/datasources": {"resource": "namespace", "verb": "get", "resourceName": "grafana-ocp", "namespace": "${NAMESPACE}"}}'
  120. - '-openshift-sar={"namespace": "${NAMESPACE}", "verb": "list", "resource": "services"}'
  121. - -tls-cert=/etc/tls/private/tls.crt
  122. - -tls-key=/etc/tls/private/tls.key
  123. - -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
  124. - -cookie-secret-file=/etc/proxy/secrets/session_secret
  125. - -skip-auth-regex=^/metrics,/api/datasources,/api/dashboards
  126. volumeMounts:
  127. - mountPath: /etc/tls/private
  128. name: gf-tls
  129. - mountPath: /etc/proxy/secrets
  130. name: secrets
  131. - name: grafana-ocp
  132. image: ${IMAGE_GF}
  133. ports:
  134. - name: grafana-http
  135. containerPort: 3000
  136. volumeMounts:
  137. - mountPath: "/root/go/src/github.com/grafana/grafana/data"
  138. name: gf-data
  139. - mountPath: "/root/go/src/github.com/grafana/grafana/conf"
  140. name: gfconfig
  141. - mountPath: /etc/tls/private
  142. name: gf-tls
  143. - mountPath: /etc/proxy/secrets
  144. name: secrets
  145. command:
  146. - "./bin/grafana-server"
  147. volumes:
  148. - name: gfconfig
  149. configMap:
  150. name: gf-config
  151. - name: secrets
  152. secret:
  153. secretName: gf-proxy
  154. - name: gf-tls
  155. secret:
  156. secretName: gf-tls
  157. - emptyDir: {}
  158. name: gf-data
  159. - apiVersion: v1
  160. kind: ConfigMap
  161. metadata:
  162. name: gf-config
  163. namespace: "${NAMESPACE}"
  164. data:
  165. defaults.ini: |-
  166. ##################### Grafana Configuration Defaults #####################
  167. #
  168. # Do not modify this file in grafana installs
  169. #
  170. # possible values : production, development
  171. app_mode = production
  172. # instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty
  173. instance_name = ${HOSTNAME}
  174. #################################### Paths ###############################
  175. [paths]
  176. # Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
  177. #
  178. data = data
  179. #
  180. # Directory where grafana can store logs
  181. #
  182. logs = data/log
  183. #
  184. # Directory where grafana will automatically scan and look for plugins
  185. #
  186. plugins = data/plugins
  187. #################################### Server ##############################
  188. [server]
  189. # Protocol (http, https, socket)
  190. protocol = http
  191. # The ip address to bind to, empty will bind to all interfaces
  192. http_addr =
  193. # The http port to use
  194. http_port = 3000
  195. # The public facing domain name used to access grafana from a browser
  196. domain = localhost
  197. # Redirect to correct domain if host header does not match domain
  198. # Prevents DNS rebinding attacks
  199. enforce_domain = false
  200. # The full public facing url
  201. root_url = %(protocol)s://%(domain)s:%(http_port)s/
  202. # Log web requests
  203. router_logging = false
  204. # the path relative working path
  205. static_root_path = public
  206. # enable gzip
  207. enable_gzip = false
  208. # https certs & key file
  209. cert_file = /etc/tls/private/tls.crt
  210. cert_key = /etc/tls/private/tls.key
  211. # Unix socket path
  212. socket = /tmp/grafana.sock
  213. #################################### Database ############################
  214. [database]
  215. # You can configure the database connection by specifying type, host, name, user and password
  216. # as separate properties or as on string using the url property.
  217. # Either "mysql", "postgres" or "sqlite3", it's your choice
  218. type = sqlite3
  219. host = 127.0.0.1:3306
  220. name = grafana
  221. user = root
  222. # If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
  223. password =
  224. # Use either URL or the previous fields to configure the database
  225. # Example: mysql://user:secret@host:port/database
  226. url =
  227. # Max idle conn setting default is 2
  228. max_idle_conn = 2
  229. # Max conn setting default is 0 (mean not set)
  230. max_open_conn =
  231. # For "postgres", use either "disable", "require" or "verify-full"
  232. # For "mysql", use either "true", "false", or "skip-verify".
  233. ssl_mode = disable
  234. ca_cert_path =
  235. client_key_path =
  236. client_cert_path =
  237. server_cert_name =
  238. # For "sqlite3" only, path relative to data_path setting
  239. path = grafana.db
  240. #################################### Session #############################
  241. [session]
  242. # Either "memory", "file", "redis", "mysql", "postgres", "memcache", default is "file"
  243. provider = file
  244. # Provider config options
  245. # memory: not have any config yet
  246. # file: session dir path, is relative to grafana data_path
  247. # redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana`
  248. # postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable
  249. # mysql: go-sql-driver/mysql dsn config string, examples:
  250. # `user:password@tcp(127.0.0.1:3306)/database_name`
  251. # `user:password@unix(/var/run/mysqld/mysqld.sock)/database_name`
  252. # memcache: 127.0.0.1:11211
  253. provider_config = sessions
  254. # Session cookie name
  255. cookie_name = grafana_sess
  256. # If you use session in https only, default is false
  257. cookie_secure = false
  258. # Session life time, default is 86400
  259. session_life_time = 86400
  260. gc_interval_time = 86400
  261. #################################### Data proxy ###########################
  262. [dataproxy]
  263. # This enables data proxy logging, default is false
  264. logging = false
  265. #################################### Analytics ###########################
  266. [analytics]
  267. # Server reporting, sends usage counters to stats.grafana.org every 24 hours.
  268. # No ip addresses are being tracked, only simple counters to track
  269. # running instances, dashboard and error counts. It is very helpful to us.
  270. # Change this option to false to disable reporting.
  271. reporting_enabled = true
  272. # Set to false to disable all checks to https://grafana.com
  273. # for new versions (grafana itself and plugins), check is used
  274. # in some UI views to notify that grafana or plugin update exists
  275. # This option does not cause any auto updates, nor send any information
  276. # only a GET request to https://grafana.com to get latest versions
  277. check_for_updates = true
  278. # Google Analytics universal tracking code, only enabled if you specify an id here
  279. google_analytics_ua_id =
  280. # Google Tag Manager ID, only enabled if you specify an id here
  281. google_tag_manager_id =
  282. #################################### Security ############################
  283. [security]
  284. # default admin user, created on startup
  285. admin_user = admin
  286. # default admin password, can be changed before first start of grafana, or in profile settings
  287. admin_password = admin
  288. # used for signing
  289. secret_key = SW2YcwTIb9zpOOhoPsMm
  290. # Auto-login remember days
  291. login_remember_days = 7
  292. cookie_username = grafana_user
  293. cookie_remember_name = grafana_remember
  294. # disable gravatar profile images
  295. disable_gravatar = false
  296. # data source proxy whitelist (ip_or_domain:port separated by spaces)
  297. data_source_proxy_whitelist =
  298. [snapshots]
  299. # snapshot sharing options
  300. external_enabled = true
  301. external_snapshot_url = https://snapshots-origin.raintank.io
  302. external_snapshot_name = Publish to snapshot.raintank.io
  303. # remove expired snapshot
  304. snapshot_remove_expired = true
  305. # remove snapshots after 90 days
  306. snapshot_TTL_days = 90
  307. #################################### Users ####################################
  308. [users]
  309. # disable user signup / registration
  310. allow_sign_up = true
  311. # Allow non admin users to create organizations
  312. allow_org_create = true
  313. # Set to true to automatically assign new users to the default organization (id 1)
  314. auto_assign_org = true
  315. # Default role new users will be automatically assigned (if auto_assign_org above is set to true)
  316. auto_assign_org_role = Admin
  317. # Require email validation before sign up completes
  318. verify_email_enabled = false
  319. # Background text for the user field on the login page
  320. login_hint = email or username
  321. # Default UI theme ("dark" or "light")
  322. default_theme = dark
  323. # External user management
  324. external_manage_link_url =
  325. external_manage_link_name =
  326. external_manage_info =
  327. [auth]
  328. # Set to true to disable (hide) the login form, useful if you use OAuth
  329. disable_login_form = true
  330. # Set to true to disable the signout link in the side menu. useful if you use auth.proxy
  331. disable_signout_menu = true
  332. #################################### Anonymous Auth ######################
  333. [auth.anonymous]
  334. # enable anonymous access
  335. enabled = true
  336. # specify organization name that should be used for unauthenticated users
  337. org_name = Main Org.
  338. # specify role for unauthenticated users
  339. org_role = Admin
  340. #################################### Github Auth #########################
  341. [auth.github]
  342. enabled = false
  343. allow_sign_up = true
  344. client_id = some_id
  345. client_secret = some_secret
  346. scopes = user:email
  347. auth_url = https://github.com/login/oauth/authorize
  348. token_url = https://github.com/login/oauth/access_token
  349. api_url = https://api.github.com/user
  350. team_ids =
  351. allowed_organizations =
  352. #################################### Google Auth #########################
  353. [auth.google]
  354. enabled = false
  355. allow_sign_up = true
  356. client_id = some_client_id
  357. client_secret = some_client_secret
  358. scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
  359. auth_url = https://accounts.google.com/o/oauth2/auth
  360. token_url = https://accounts.google.com/o/oauth2/token
  361. api_url = https://www.googleapis.com/oauth2/v1/userinfo
  362. allowed_domains =
  363. hosted_domain =
  364. #################################### Grafana.com Auth ####################
  365. # legacy key names (so they work in env variables)
  366. [auth.grafananet]
  367. enabled = false
  368. allow_sign_up = true
  369. client_id = some_id
  370. client_secret = some_secret
  371. scopes = user:email
  372. allowed_organizations =
  373. [auth.grafana_com]
  374. enabled = false
  375. allow_sign_up = true
  376. client_id = some_id
  377. client_secret = some_secret
  378. scopes = user:email
  379. allowed_organizations =
  380. #################################### Generic OAuth #######################
  381. [auth.generic_oauth]
  382. name = OAuth
  383. enabled = false
  384. allow_sign_up = true
  385. client_id = some_id
  386. client_secret = some_secret
  387. scopes = user:email
  388. auth_url =
  389. token_url =
  390. api_url =
  391. team_ids =
  392. allowed_organizations =
  393. #################################### Basic Auth ##########################
  394. [auth.basic]
  395. enabled = false
  396. #################################### Auth Proxy ##########################
  397. [auth.proxy]
  398. enabled = true
  399. header_name = X-WEBAUTH-USER
  400. header_property = username
  401. auto_sign_up = true
  402. ldap_sync_ttl = 60
  403. whitelist =
  404. #################################### Auth LDAP ###########################
  405. [auth.ldap]
  406. enabled = false
  407. config_file = /etc/grafana/ldap.toml
  408. allow_sign_up = true
  409. #################################### SMTP / Emailing #####################
  410. [smtp]
  411. enabled = false
  412. host = localhost:25
  413. user =
  414. # If the password contains # or ; you have to wrap it with trippel quotes. Ex """#password;"""
  415. password =
  416. cert_file =
  417. key_file =
  418. skip_verify = false
  419. from_address = admin@grafana.localhost
  420. from_name = Grafana
  421. ehlo_identity =
  422. [emails]
  423. welcome_email_on_sign_up = false
  424. templates_pattern = emails/*.html
  425. #################################### Logging ##########################
  426. [log]
  427. # Either "console", "file", "syslog". Default is console and file
  428. # Use space to separate multiple modes, e.g. "console file"
  429. mode = console file
  430. # Either "debug", "info", "warn", "error", "critical", default is "info"
  431. level = error
  432. # optional settings to set different levels for specific loggers. Ex filters = sqlstore:debug
  433. filters =
  434. # For "console" mode only
  435. [log.console]
  436. level =
  437. # log line format, valid options are text, console and json
  438. format = console
  439. # For "file" mode only
  440. [log.file]
  441. level =
  442. # log line format, valid options are text, console and json
  443. format = text
  444. # This enables automated log rotate(switch of following options), default is true
  445. log_rotate = true
  446. # Max line number of single file, default is 1000000
  447. max_lines = 1000000
  448. # Max size shift of single file, default is 28 means 1 << 28, 256MB
  449. max_size_shift = 28
  450. # Segment log daily, default is true
  451. daily_rotate = true
  452. # Expired days of log file(delete after max days), default is 7
  453. max_days = 7
  454. [log.syslog]
  455. level =
  456. # log line format, valid options are text, console and json
  457. format = text
  458. # Syslog network type and address. This can be udp, tcp, or unix. If left blank, the default unix endpoints will be used.
  459. network =
  460. address =
  461. # Syslog facility. user, daemon and local0 through local7 are valid.
  462. facility =
  463. # Syslog tag. By default, the process' argv[0] is used.
  464. tag =
  465. #################################### AMQP Event Publisher ################
  466. [event_publisher]
  467. enabled = false
  468. rabbitmq_url = amqp://localhost/
  469. exchange = grafana_events
  470. #################################### Dashboard JSON files ################
  471. [dashboards.json]
  472. enabled = false
  473. path = /var/lib/grafana/dashboards
  474. #################################### Usage Quotas ########################
  475. [quota]
  476. enabled = false
  477. #### set quotas to -1 to make unlimited. ####
  478. # limit number of users per Org.
  479. org_user = 10
  480. # limit number of dashboards per Org.
  481. org_dashboard = 100
  482. # limit number of data_sources per Org.
  483. org_data_source = 10
  484. # limit number of api_keys per Org.
  485. org_api_key = 10
  486. # limit number of orgs a user can create.
  487. user_org = 10
  488. # Global limit of users.
  489. global_user = -1
  490. # global limit of orgs.
  491. global_org = -1
  492. # global limit of dashboards
  493. global_dashboard = -1
  494. # global limit of api_keys
  495. global_api_key = -1
  496. # global limit on number of logged in users.
  497. global_session = -1
  498. #################################### Alerting ############################
  499. [alerting]
  500. # Disable alerting engine & UI features
  501. enabled = true
  502. # Makes it possible to turn off alert rule execution but alerting UI is visible
  503. execute_alerts = true
  504. #################################### Internal Grafana Metrics ############
  505. # Metrics available at HTTP API Url /api/metrics
  506. [metrics]
  507. enabled = true
  508. interval_seconds = 10
  509. # Send internal Grafana metrics to graphite
  510. [metrics.graphite]
  511. # Enable by setting the address setting (ex localhost:2003)
  512. address =
  513. prefix = prod.grafana.%(instance_name)s.
  514. [grafana_net]
  515. url = https://grafana.com
  516. [grafana_com]
  517. url = https://grafana.com
  518. #################################### Distributed tracing ############
  519. [tracing.jaeger]
  520. # jaeger destination (ex localhost:6831)
  521. address =
  522. # tag that will always be included in when creating new spans. ex (tag1:value1,tag2:value2)
  523. always_included_tag =
  524. # Type specifies the type of the sampler: const, probabilistic, rateLimiting, or remote
  525. sampler_type = const
  526. # jaeger samplerconfig param
  527. # for "const" sampler, 0 or 1 for always false/true respectively
  528. # for "probabilistic" sampler, a probability between 0 and 1
  529. # for "rateLimiting" sampler, the number of spans per second
  530. # for "remote" sampler, param is the same as for "probabilistic"
  531. # and indicates the initial sampling rate before the actual one
  532. # is received from the mothership
  533. sampler_param = 1
  534. #################################### External Image Storage ##############
  535. [external_image_storage]
  536. # You can choose between (s3, webdav, gcs)
  537. provider =
  538. [external_image_storage.s3]
  539. bucket_url =
  540. bucket =
  541. region =
  542. path =
  543. access_key =
  544. secret_key =
  545. [external_image_storage.webdav]
  546. url =
  547. username =
  548. password =
  549. public_url =
  550. [external_image_storage.gcs]
  551. key_file =
  552. bucket =