Grafana로 RBAC 프로비저닝하기
Grafana로 RBAC 프로비저닝하기 (Provisioning RBAC with Grafana)
커스텀 역할을 만들고 기본 역할 할당을 추가·제거할 수 있어요. provisioning/access-control/ 디렉터리에 YAML 구성 파일을 하나 이상 넣으면 됩니다.
참고: 자체 관리 인스턴스의 Grafana Enterprise에서 사용할 수 있어요. Grafana Cloud에서는 사용할 수 없습니다.
출처: 문서
본문
이 방법은 Grafana가 실행되는 파일 시스템 접근이 필요하므로 자체 관리 인스턴스에서만 가능해요. Grafana Cloud에서 RBAC를 프로비저닝하려면 Terraform이나 HTTP API를 사용하세요.
Grafana는 시작 시 프로비저닝을 수행하며, 구성 파일 변경 후 런타임 중에 다시 로드할 수 있어요. 변경 사항 적용에 Grafana 서버 재시작은 필요 없습니다.
시작 전: Grafana가 실행되는 서버의 파일 접근 권한이 있는지 확인하세요.
프로비저닝으로 RBAC 역할 관리·할당:
- Grafana 서버에 로그인
- Grafana 프로비저닝 폴더 찾기
provisioning/access-control폴더에 새 YAML 생성 (예:provisioning/access-control/custom-roles.yml)- 구성 파일에 RBAC 프로비저닝 상세 추가. RBAC 역할 관리, RBAC 역할 할당 및 아래 예시 파일을 참고하세요.
- 프로비저닝 구성 파일 다시 로드. 런타임 재로드 방법은 재로드 프로비저닝 구성 참고.
Grafana 프로비저닝을 사용한 예제 역할 구성 파일
다음을 수행하는 완전한 YAML 구성 파일 예시입니다: 커스텀 역할 생성, 커스텀 역할 삭제, 기본 역할 권한 업데이트, 팀에 역할 할당, 팀의 역할 할당 회수.
---
# config file version
apiVersion: 2
# <list> list of roles to insert/update/delete
roles:
# <string, required> name of the role you want to create or update. Required.
- name: 'custom:users:writer'
# <string> uid of the role. Has to be unique for all orgs.
uid: customuserswriter1
# <string> description of the role, informative purpose only.
description: 'Create, read, write users'
# <int> version of the role. Has to be greater than the stored role version to apply updates. Increase by 1 when you change the role.
version: 2
# <int> org id. Defaults to Grafana's default if not specified.
orgId: 1
# <list> list of the permissions granted by this role.
permissions:
# <string, required> action allowed.
- action: 'users:read'
#<string> scope it applies to.
scope: 'users:*'
- action: 'users:write'
scope: 'users:*'
- action: 'users:create'
# NOTE: the `datasources:query` action implies `datasources:read`
# Optional `datasourceType` for scopes `datasources:uid:<DATASOURCE_UID>`.
# If you omit it, Grafana resolves the plugin type from the data source when this file is provisioned.
# It is required if there are two datasources with the same uid.
- action: 'datasources:query'
scope: 'datasources:uid:loki-uid-here'
datasourceType: loki
- name: 'custom:global:users:reader'
# <bool> overwrite org id and creates a global role.
global: true
# <string> state of the role. Defaults to 'present'. If 'absent', role will be deleted.
state: 'absent'
# <bool> force deletion revoking all grants of the role.
force: true
- uid: 'basic_editor'
# <bool> always apply the specified changes to the role, regardless of the role version in the database
overrideRole: true
global: true
# <list> list of roles to copy permissions from.
from:
- uid: 'basic_editor'
global: true
- name: 'fixed:users:writer'
global: true
# <list> list of the permissions to add/remove on top of the copied ones.
permissions:
- action: 'users:read'
scope: 'users:*'
- action: 'users:write'
scope: 'users:*'
# <string> state of the permission. Defaults to 'present'. If 'absent', the permission will be removed.
state: absent
# <list> list role assignments to teams to create or remove.
teams:
# <string, required> name of the team you want to assign roles to. Required.
- name: 'Users writers'
# <int> org id. Will default to Grafana's default if not specified.
orgId: 1
# <list> list of roles to assign to the team
roles:
# <string> uid of the role you want to assign to the team.
- uid: 'customuserswriter1'
# <int> org id. Will default to Grafana's default if not specified.
orgId: 1
# <string> name of the role you want to assign to the team.
- name: 'fixed:users:writer'
# <bool> overwrite org id to specify the role is global.
global: true
# <string> state of the assignment. Defaults to 'present'. If 'absent', the assignment will be revoked.
state: absent