Docker-airflow: RBAC

Created on 24 Jul 2020  路  3Comments  路  Source: puckel/docker-airflow

im trying to create airfllow RBAC user as below through docker. and, config as follows

Dockerfile config

CMD ["airflow create_user -r Admin -u admin -f xx -l pamula -p xx -e [email protected]"]

ENTRYPOINT ["/usr/local/airflow/entrypoint.sh"]

CMD ["webserver"]

airflow.cfg

Use FAB-based webserver with RBAC feature

rbac = True

https://airflow.apache.org/security.html#web-authentication

authenticate = True
auth_backend = airflow.contrib.auth.backends.password_auth

Docker container is up however if i see the logs i see below error and web UI is not coming, please do the needful.

docker logs -f 2ad74479183b
[2020-07-23 22:14:46,885] {settings.py:253} INFO - settings.configure_orm(): Using pool settings. pool_size=5, max_overflow=10, pool_recycle=1800, pid=1
____________ _____________
____ |__( )_________ __/__ /________ __
____ /| |_ /__ ___/_ /_ __ /_ __ _ | /| / /
___ ___ | / _ / _ __/ _ / / /_/ /_ |/ |/ /
_/_/ |_/_/ /_/ /_/ /_/ ____/____/|__/
[2020-07-23 22:14:59,683] {manager.py:710} WARNING - No user yet created, use flask fab command to do it.
[2020-07-23 22:15:48,179] {__init__.py:51} INFO - Using executor LocalExecutor
[2020-07-23 22:15:48,179] {dagbag.py:403} INFO - Filling up the DagBag from /dev/null
[2020-07-23 22:16:58,982] {security.py:461} INFO - Start syncing user roles.
[2020-07-23 22:19:25,248] {security.py:370} INFO - Fetching a set of all permission, view_menu from FAB meta-table
[2020-07-23 22:22:58,193] {security.py:313} INFO - Cleaning faulty perms
Running the Gunicorn Server with:
Workers: 4 sync
Host: 0.0.0.0:8080
Timeout: 120

Logfiles: - -

[2020-07-23 22:23:00,757] {settings.py:253} INFO - settings.configure_orm(): Using pool settings. pool_size=5, max_overflow=10, pool_recycle=1800, pid=9
[2020-07-23 22:23:00 +0000] [9] [INFO] Starting gunicorn 19.10.0
[2020-07-23 22:23:00 +0000] [9] [INFO] Listening at: http://0.0.0.0:8080 (9)
[2020-07-23 22:23:00 +0000] [9] [INFO] Using worker: sync
[2020-07-23 22:23:00 +0000] [12] [INFO] Booting worker with pid: 12
[2020-07-23 22:23:00 +0000] [13] [INFO] Booting worker with pid: 13
[2020-07-23 22:23:00 +0000] [14] [INFO] Booting worker with pid: 14
[2020-07-23 22:23:01 +0000] [15] [INFO] Booting worker with pid: 15
[2020-07-23 22:23:08,197] {manager.py:710} WARNING - No user yet created, use flask fab command to do it.
[2020-07-23 22:23:08,222] {manager.py:710} WARNING - No user yet created, use flask fab command to do it.
[2020-07-23 22:23:08,264] {manager.py:710} WARNING - No user yet created, use flask fab command to do it.
[2020-07-23 22:23:08,322] {manager.py:710} WARNING - No user yet created, use flask fab command to do it.

Most helpful comment

The trick for me was to modify the airflow.cfg as above but then place the airflow create_user call not in the Dockerfile, but in the entrypoint.

That is, add a line like
airflow create_user -r Admin -u admin -f xx -l pamula -p xx -e [email protected]

after airflow initdb in https://github.com/puckel/docker-airflow/blob/a1d70c66f7a4009c5381ac10049632ece4274147/script/entrypoint.sh#L112

If you watch the logs via docker logs [webserver container id], you will see Admin user admin created. printed just before the webserver starts.

All 3 comments

@prasanthbangs2016 did you ever figure this out?

@mkwatson yes, i had reset the db and re initialized the db with airflow cli commnads

The trick for me was to modify the airflow.cfg as above but then place the airflow create_user call not in the Dockerfile, but in the entrypoint.

That is, add a line like
airflow create_user -r Admin -u admin -f xx -l pamula -p xx -e [email protected]

after airflow initdb in https://github.com/puckel/docker-airflow/blob/a1d70c66f7a4009c5381ac10049632ece4274147/script/entrypoint.sh#L112

If you watch the logs via docker logs [webserver container id], you will see Admin user admin created. printed just before the webserver starts.

Was this page helpful?
0 / 5 - 0 ratings