Bonjour, Habr! Je m'appelle Sergey, je suis ingénieur logiciel principal / chef d'équipe chez EPAM, ingénieur et architecte certifié Google Cloud. Depuis plus de 10 ans, je fais du développement commercial pour diverses entreprises mondiales, principalement avec un accent sur le backend. J'aime aussi partager mes connaissances. Aujourd'hui, je veux parler d'Apache Airflow, qui, à mon avis, est un bon outil pour construire vos pipelines.
Quel est le plan?
En un mot, je vais vous parler d'Airflow pour ceux qui n'ont pas encore travaillĂ© avec. Tout cela peut ĂȘtre trouvĂ© plus en dĂ©tail sur Internet, je ne passerai donc en revue que les concepts de base.
Voyons ce qu'est Google Cloud Composer , comment il utilise Airflow et simplifie le développement sur de vrais projets.
Jetons un coup d'Ćil aux pratiques de dĂ©veloppement et de dĂ©ploiement dans Google Cloud Composer, ainsi qu'aux difficultĂ©s et limitations qui peuvent ĂȘtre rencontrĂ©es lors du lancement d'Airflow dans Cloud Composer.
Et, bien sûr, je partagerai des outils utiles que vous pouvez utiliser dans votre travail.
Flux d'air en plusieurs paragraphes
Il s'agit donc d'un outil de planification, de construction et de surveillance de pipelines Ă©crits en Python. Il existe d'autres solutions d'orchestration de processus prĂȘtes Ă l'emploi, telles que Luigi. Mais parlons maintenant des avantages d'Airflow:
Vraiment bon pour la construction de pipelines. Au cĆur de tout ce qu'il possĂšde se trouve un graphe acyclique dirigĂ©, qui vous permet d'implĂ©menter une exĂ©cution sĂ©quentielle ou parallĂšle de tĂąches, ainsi que de gĂ©rer leur ordre et leurs dĂ©pendances.
. open-sourse , .
-: , .
REST API, API.
ETL-pipeline ââ . , GCS . , , , . , , .
Airflow. DAG (Directed Acyclic Graph) â , Airflow. , . , .
Tasks DAG . , , . Operators , , . , â DAG-. â DataLoadOperator, GoogleCloudStorageListOperator UpdateStatusOperator â , . , , DAG-, . .
E DAGs Run Tasks Instances. DAGs Run â DAG, . Tasks Instance â , DAG Run. DAG Run Tasks Instances â execution date.
DAG , , pipeline-.
, Airflow:
(Scheduler) DAG-, .
( Executor) â , . : SequentialExecutor, CeleryExecutor . . , CeleryExecutor Queue Broker.
(Workers) ( Celery).
- , , , HTTP-, DAG- . , , Airflow, DAG-, . .
Logs. , Airflow. , - loud-. , Stackdriver GCS bucket .
Admin Panel / DAG-, , , (, ââ).
?
Airflow , DAG-. , . - , . , task execution , Admin Panel. , . , deployment-.
Google Cloud Composer
Google Cloud Composer Composer â fully managed , , cloud.
, . , , storage A storage B. Airflow DAG, Composer . , . - , retry, . , . , cron jobs, 100 , â Airflow Composer , .
Composer:
-, . Composer Airflow Google Console UI â â, , DAG- . , DAG-, , , Composer bucket GCS. .
-, Composer , UI. Airflow, .
-, Composer security- , Google Cloud. , Private IPs, Authorization . .
-, Composer Console .
Composer. â, fully managed ââ?â , , . , :
( , Composer ). Tenant Project â , Identity Access Management. . AppEngine Flexible -, Cloud SQL â Airflow. Cloud SQL , , -, . Cloud Storage Composer bucket, , / DAG-, . , Kubernetes . Core-, , worker- , , Redis, CeleryExecutor, Google Kubernetes Engine. : Kubernetes , , Redis. , Redis Airflow, Kubernetes Engine. , Composer Stackdriver â . , 100 , .
, , â â. , , , , DevOps-, , , , . .
, :
-, Tenant Project, Cloud SQL . â . , , .
Deployment development,
â , . :
, . Airflow DAGS_FOLDER PLUGINS_FOLDER sys.path , . : DAGS_FOLDER DAG-, PLUGINS_FOLDER â Airflow.
, , libs utils. , . plugins Airflow PLUGINS, Airflow. operators, hooks, macros â , Airflow â â.
. pip requirements.txt . Composer, UI, . , CI/CD , gcloud. pip Composer.
Airflow DAGS_FOLDER PLUGINS_FOLDER sys.path, , , DAGS_FOLDER, PLUGINS_FOLDER. , Airflow, , . , Airflow , , DAG-. PLUGINS_FOLDER . plugins â . . , , .
Airflow: . Composer read-only. .
.airflowignore . .gitignore , , Airflow . , . , PLUGINS_FOLDER , . .airflowignore Python , .
Airflow. Airflow , UI-, View. operators, hooks . , Airflow PLUGINS_FOLDER sys.path, , , from vnd.operators.my_operator. , , Airflow. , :
from vnd.operators.my_operator import MyOperator
from vnd.sensors.my_sensor import MySensor
, . , , Airflow plugins AirflowPlugin .
: , , callable- , lazy . , DAG-. , c , . , . , , , - , . : DAG- .
CI/D â . linters, isorts Gitlab CI/CD . CI/D , : Jenkins, Gitlab pipeline, Spinnaker.
, linters, unit , â . Composer, gcloud rsync.
Composer , rsync, Airflow. , gcloud composer, DAG-, - . , , - . rsync, , /.
, Airflow . , , . , , Airflow. . afctl â CLI-, Airflow . , , DAG- . , afctl , , ( ).
, , Airflow. , Google Cloud Platform, AWS, Azure, . providers Airflow.
Airflow Plugins â , CRM , . . GitHub: Airflow , , .
:
, Airflow self-service, Cloud Composer.
Cloud Composer, , ââ (scaling to zero). , , . Composer : , A/B-, . , GKE , .
Composer, , Prod/Dev/Staging. . Composer Airflow, , Google Airflow. Composer : , image, Airflow.
DAG â , . , pip.
, , . , .
AirflowPlugin â UI , Airflow. .
.airflowignore , Airflow. , .airflowignore DAG- , Airflow DAG- DAG-. , DAG- , , , .
DAG- Cloud Composer. DAG- . â ââ.
Airflow. , GoogleCloudStorageListOperator , , . - , .
KubernetesPodOperator , Python. Kubernetes, Airflow Pod-. , Composer-.
Composer, read-only Airflow. .
, , Airflow Composer :)