You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/04/28 12:20:16 UTC
[GitHub] [airflow] potiuk opened a new issue #8606: Deal with initial username/passwords in the production docker image
potiuk opened a new issue #8606:
URL: https://github.com/apache/airflow/issues/8606
**Description**
The Bitnami Airflow Image (https://github.com/bitnami/bitnami-docker-airflow) deals nicely with initial usernames/passwords - this is when you run it through docker-compose and you want to do database initialization. It is likely we should do something similar.
**Use case / motivation**
In some environments, you would like to create an initial username/password when you start the image (after you reset the DB). It would be great to control it via environment variables.
**Related Issues**
Adding Docker Compose example - #8548
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk closed issue #8606: Deal with initial username/passwords in the production docker image
Posted by GitBox <gi...@apache.org>.
potiuk closed issue #8606:
URL: https://github.com/apache/airflow/issues/8606
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] resdevd commented on issue #8606: Deal with initial username/passwords in the production docker image
Posted by GitBox <gi...@apache.org>.
resdevd commented on issue #8606:
URL: https://github.com/apache/airflow/issues/8606#issuecomment-620973087
I think the default username, password should be declared in env variables, Airflow Image's entrypoint checks for these variables and creates a user. If the user already exist, the current default behavior is a graceful "User already exist" message.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] dinigo commented on issue #8606: Deal with initial username/passwords in the production docker image
Posted by GitBox <gi...@apache.org>.
dinigo commented on issue #8606:
URL: https://github.com/apache/airflow/issues/8606#issuecomment-620873030
Well you can simply add a new service in the docker stack/compose to initialize it:
```
version: '3.6'
services:
init:
image: apache/airflow:1.10.10
environment:
AIRFLOW__CORE__SQL_ALCHEMY_CONN: mysql://airflow:airflow@mysql:3306/airflow
entrypoint: "airflow upgradedb && airflow create_user -f none -l none -u $USER -p $PASSWORD -e $EMAIL"
mysql:
image: mysql
environment:
DB_USER: airflow
DB_PASSWORD: airflow
DB_NAME: airflow
```
I think something like this will do. It can be added to the entrypoint script also, but you can initialize any database with a matching version airflow installation. To initialize my airflow db for the docker stack deployments I:
1. Spin up the db
2. Setup the env variables to connect to the DB in local (fernet key and sql_alchemy_conn)
3. Init the db and create user from local environment
4 Deploy the stack with everything initialized
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] resdevd removed a comment on issue #8606: Deal with initial username/passwords in the production docker image
Posted by GitBox <gi...@apache.org>.
resdevd removed a comment on issue #8606:
URL: https://github.com/apache/airflow/issues/8606#issuecomment-620973087
I think the default username, password should be declared in env variables, Airflow Image's entrypoint checks for these variables and creates a user. If the user already exist, the current default behavior is a graceful "User already exist" message.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] dinigo commented on issue #8606: Deal with initial username/passwords in the production docker image
Posted by GitBox <gi...@apache.org>.
dinigo commented on issue #8606:
URL: https://github.com/apache/airflow/issues/8606#issuecomment-735492915
Yes. But I had to split the script from the template for the same reason
Here the service inside the Docker-Compose.yml
```yml
init:
<<: *airflow-template
volumes:
- ./init-airflow.sh:/entrypoint
depends_on:
- database
```
And the simple script that locks like so
```bash
airflow db upgrade
if [ $(users list | grep \"${INIT_EMAIL}\") ]
then
echo \"User ${INIT_EMAIL} already exists\"
else
airflow users create \
--firstname Admin \
--lastname None \
--email \"${INIT_EMAIL}\" \
--password \"${INIT_PASSWORD}\" \
--username \"${INIT_USER}\" \
--role Admin
fi
```
I reuse the users, password and email for several config variables that I define in the"Airflow-template" environment.
This is working
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] dinigo edited a comment on issue #8606: Deal with initial username/passwords in the production docker image
Posted by GitBox <gi...@apache.org>.
dinigo edited a comment on issue #8606:
URL: https://github.com/apache/airflow/issues/8606#issuecomment-620873030
Well you can simply add a new service in the docker stack/compose to initialize it:
```
version: '3.6'
services:
init:
image: apache/airflow:1.10.10
environment:
AIRFLOW__CORE__SQL_ALCHEMY_CONN: mysql://airflow:airflow@mysql:3306/airflow
entrypoint: "airflow upgradedb && airflow create_user -f none -l none -u $USER -p $PASSWORD -e $EMAIL"
mysql:
image: mysql
environment:
DB_USER: airflow
DB_PASSWORD: airflow
DB_NAME: airflow
```
I think something like this will do. It can be added to the entrypoint script also.
But you can initialize any database with a matching version airflow installation. To initialize my airflow db for the docker stack deployments I do the following
1. Spin up the db
2. Setup the env variables to connect to the DB in local (fernet key and sql_alchemy_conn)
3. Init the db and create user from local environment
4 Deploy the stack with everything initialized
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] gontcharovd commented on issue #8606: Deal with initial username/passwords in the production docker image
Posted by GitBox <gi...@apache.org>.
gontcharovd commented on issue #8606:
URL: https://github.com/apache/airflow/issues/8606#issuecomment-732272749
> Well you can simply add a new service in the docker stack/compose to initialize it:
>
> ```
> version: '3.6'
> services:
> init:
> image: apache/airflow:1.10.10
> environment:
> AIRFLOW__CORE__SQL_ALCHEMY_CONN: mysql://airflow:airflow@mysql:3306/airflow
> entrypoint: "airflow upgradedb && airflow create_user -f none -l none -u $USER -p $PASSWORD -e $EMAIL"
> mysql:
> image: mysql
> environment:
> DB_USER: airflow
> DB_PASSWORD: airflow
> DB_NAME: airflow
> ```
>
> I think something like this will do. It can be added to the entrypoint script also.
>
> But you can initialize any database with a matching version airflow installation. To initialize my airflow db for the docker stack deployments I do the following
>
> 1. Spin up the db
> 2. Setup the env variables to connect to the DB in local (fernet key and sql_alchemy_conn)
> 3. Init the db and create user from local environment
> 4 Deploy the stack with everything initialized
I have an issue with the `&&` in this line when I tried adding this init service to my docker-compose:
```entrypoint: "airflow upgradedb && airflow create_user -f none -l none -u $USER -p $PASSWORD -e $EMAIL"```
Did you manage to get it working in your case?
I'm still not clear on the recommended way to initialize usernames/passwords when running the containers the first time.
Are there any new recommendations about this topic?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on issue #8606: Deal with initial username/passwords in the production docker image
Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #8606:
URL: https://github.com/apache/airflow/issues/8606#issuecomment-761850647
Hey @dinigo #13728 should address this one :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org