GitHub user RickyLeeeee edited a discussion: How to create custom roles when
deploying airflow with helm chart
Hello,
I want to create multiple custom roles while deploying Airflow using a Helm
Chart. However, after searching extensively on Google, I couldn't find a
relevant solution. I have tried adding the following Airflow CLI commands under
webserver.extraInitContainers, but it did not work:
```
extraInitContainers:
- name: setup-roles-and-permissions
image: apache/airflow:2.10.0
command:
- /bin/bash
- -c
args:
- |
airflow db migrate
airflow roles create Test &&
airflow roles add-perms Test --resource "DAG Runs" --action "can_edit"
&&
airflow roles add-perms Test --resource "DAG Runs" --action
"can_create" &&
airflow roles add-perms Test --resource "DAG Runs" --action "can_edit"
```
Logs for the extraContainer:
```
/home/airflow/.local/lib/python3.12/site-packages/airflow/plugins_manager.py:30
DeprecationWarning: 'cgitb' is deprecated and slated for removal in Python 3.13
DB: sqlite:////opt/airflow/airflow.db
Performing upgrade to the metadata database sqlite:////opt/airflow/airflow.db
[2025-01-10T09:54:24.474+0000] {migration.py:215} INFO - Context impl
SQLiteImpl.
[2025-01-10T09:54:24.479+0000] {migration.py:218} INFO - Will assume
non-transactional DDL.
[2025-01-10T09:54:24.481+0000] {migration.py:215} INFO - Context impl
SQLiteImpl.
[2025-01-10T09:54:24.482+0000] {migration.py:218} INFO - Will assume
non-transactional DDL.
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running stamp_revision -> 22ed7efa9da2
Database migrating done!
/home/airflow/.local/lib/python3.12/site-packages/airflow/plugins_manager.py:30
DeprecationWarning: 'cgitb' is deprecated and slated for removal in Python 3.13
Added 1 role(s)
/home/airflow/.local/lib/python3.12/site-packages/airflow/plugins_manager.py:30
DeprecationWarning: 'cgitb' is deprecated and slated for removal in Python 3.13
Resource named 'DAG Runs' does not exist
```
Based on the logs, it shows that the metadata database being used is sqlite
instead of postgresql. It seems that it hasn’t connected to the correct
database.
May I ask how to create custom roles during deployment?
The Helm Chart version I am using is 1.15.0, and the Airflow version is 2.10.0.
GitHub link: https://github.com/apache/airflow/discussions/45543
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]