本文整理汇总了Python中airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration.init_volumes_and_mounts方法的典型用法代码示例。如果您正苦于以下问题:Python WorkerConfiguration.init_volumes_and_mounts方法的具体用法?Python WorkerConfiguration.init_volumes_and_mounts怎么用?Python WorkerConfiguration.init_volumes_and_mounts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration
的用法示例。
在下文中一共展示了WorkerConfiguration.init_volumes_and_mounts方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_worker_git_dags
# 需要导入模块: from airflow.contrib.kubernetes.worker_configuration import WorkerConfiguration [as 别名]
# 或者: from airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration import init_volumes_and_mounts [as 别名]
def test_worker_git_dags(self):
# Tests persistence volume config created when `git_repo` is set
self.kube_config.dags_volume_claim = None
self.kube_config.dags_volume_host = None
self.kube_config.dags_folder = '/usr/local/airflow/dags'
self.kube_config.worker_dags_folder = '/usr/local/airflow/dags'
self.kube_config.git_sync_container_repository = 'gcr.io/google-containers/git-sync-amd64'
self.kube_config.git_sync_container_tag = 'v2.0.5'
self.kube_config.git_sync_container = 'gcr.io/google-containers/git-sync-amd64:v2.0.5'
self.kube_config.git_sync_init_container_name = 'git-sync-clone'
self.kube_config.git_subpath = 'dags_folder'
self.kube_config.git_sync_root = '/git'
self.kube_config.git_dags_folder_mount_point = '/usr/local/airflow/dags/repo/dags_folder'
worker_config = WorkerConfiguration(self.kube_config)
volumes, volume_mounts = worker_config.init_volumes_and_mounts()
dag_volume = [volume for volume in volumes.values() if volume['name'] == 'airflow-dags']
dag_volume_mount = [mount for mount in volume_mounts.values() if mount['name'] == 'airflow-dags']
self.assertTrue('emptyDir' in dag_volume[0])
self.assertEqual(self.kube_config.git_dags_folder_mount_point, dag_volume_mount[0]['mountPath'])
self.assertTrue(dag_volume_mount[0]['readOnly'])
init_container = worker_config._get_init_containers(volume_mounts)[0]
init_container_volume_mount = [mount for mount in init_container['volumeMounts']
if mount['name'] == 'airflow-dags']
self.assertEqual('git-sync-clone', init_container['name'])
self.assertEqual('gcr.io/google-containers/git-sync-amd64:v2.0.5', init_container['image'])
self.assertEqual(1, len(init_container_volume_mount))
self.assertFalse(init_container_volume_mount[0]['readOnly'])
示例2: test_worker_configuration_no_subpaths
# 需要导入模块: from airflow.contrib.kubernetes.worker_configuration import WorkerConfiguration [as 别名]
# 或者: from airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration import init_volumes_and_mounts [as 别名]
def test_worker_configuration_no_subpaths(self):
worker_config = WorkerConfiguration(self.kube_config)
volumes, volume_mounts = worker_config.init_volumes_and_mounts()
for volume_or_mount in volumes + volume_mounts:
if volume_or_mount['name'] != 'airflow-config':
self.assertNotIn(
'subPath', volume_or_mount,
"subPath shouldn't be defined"
)
示例3: test_worker_pvc_dags
# 需要导入模块: from airflow.contrib.kubernetes.worker_configuration import WorkerConfiguration [as 别名]
# 或者: from airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration import init_volumes_and_mounts [as 别名]
def test_worker_pvc_dags(self):
# Tests persistence volume config created when `dags_volume_claim` is set
self.kube_config.dags_volume_claim = 'airflow-dags'
worker_config = WorkerConfiguration(self.kube_config)
volumes, volume_mounts = worker_config.init_volumes_and_mounts()
dag_volume = [volume for volume in volumes if volume['name'] == 'airflow-dags']
dag_volume_mount = [mount for mount in volume_mounts if mount['name'] == 'airflow-dags']
self.assertEqual('airflow-dags', dag_volume[0]['persistentVolumeClaim']['claimName'])
self.assertEqual(1, len(dag_volume_mount))
示例4: test_worker_container_dags
# 需要导入模块: from airflow.contrib.kubernetes.worker_configuration import WorkerConfiguration [as 别名]
# 或者: from airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration import init_volumes_and_mounts [as 别名]
def test_worker_container_dags(self):
# Tests that the 'airflow-dags' persistence volume is NOT created when `dags_in_image` is set
self.kube_config.dags_in_image = True
worker_config = WorkerConfiguration(self.kube_config)
volumes, volume_mounts = worker_config.init_volumes_and_mounts()
dag_volume = [volume for volume in volumes.values() if volume['name'] == 'airflow-dags']
dag_volume_mount = [mount for mount in volume_mounts.values() if mount['name'] == 'airflow-dags']
init_containers = worker_config._get_init_containers(volume_mounts)
self.assertEqual(0, len(dag_volume))
self.assertEqual(0, len(dag_volume_mount))
self.assertEqual(0, len(init_containers))
示例5: test_worker_with_subpaths
# 需要导入模块: from airflow.contrib.kubernetes.worker_configuration import WorkerConfiguration [as 别名]
# 或者: from airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration import init_volumes_and_mounts [as 别名]
def test_worker_with_subpaths(self):
self.kube_config.dags_volume_subpath = 'dags'
self.kube_config.logs_volume_subpath = 'logs'
worker_config = WorkerConfiguration(self.kube_config)
volumes, volume_mounts = worker_config.init_volumes_and_mounts()
for volume in volumes:
self.assertNotIn(
'subPath', volume,
"subPath isn't valid configuration for a volume"
)
for volume_mount in volume_mounts:
if volume_mount['name'] != 'airflow-config':
self.assertIn(
'subPath', volume_mount,
"subPath should've been passed to volumeMount configuration"
)