Skip to content

Commit

Permalink
Merge pull request #38 from zbrookle/fix_installation
Browse files Browse the repository at this point in the history
BUG: Fix installation
  • Loading branch information
zbrookle authored Sep 16, 2020
2 parents 88c8aa6 + 3f8a091 commit 19dd8db
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 20 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ include avionix_airflow/docker/airflow/Dockerfile
include avionix_airflow/docker/airflow/script/entrypoint.sh
include avionix_airflow/kubernetes/monitoring/dashboards/grafana_dashboard.json
include avionix_airflow/kubernetes/monitoring/event_js/event.js
include requirements.txt


5 changes: 4 additions & 1 deletion avionix_airflow/kubernetes/airflow/dag_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ def __init__(self, airflow_options: AirflowOptions, cloud_options: CloudOptions)
JobTemplateSpec(
JobSpec(
PodTemplateSpec(
AirflowMeta("sync-dags-pod",),
AirflowMeta(
"sync-dags-pod",
annotations=cloud_options.dag_retrieval_annotations,
),
PodSpec(
[
Container(
Expand Down
12 changes: 8 additions & 4 deletions avionix_airflow/kubernetes/cloud/aws/aws_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AwsOptions(CloudOptions):
:param external_dns_role_arn: The IAM role for setting the domain name
:param autoscaling_role_arn: The IAM role for controlling the cluster scaling
:param domain: The AWS domain name to use
:param dag_sync_role_arn: The IAM role use for controlling retrieval of dags
:param domain_filters: A list used to filter out route53 domain names
:param use_ssl: Whether or not to use SSL encryption, (Recommended to be True)
"""
Expand All @@ -48,6 +49,7 @@ def __init__(
alb_role_arn: str,
external_dns_role_arn: str,
autoscaling_role_arn: str,
dag_sync_role_arn: str,
domain: str,
domain_filters: Optional[List[str]] = None,
use_ssl: bool = False,
Expand All @@ -63,11 +65,9 @@ def __init__(
self.__values = ValueOrchestrator()
self.__use_ssl = use_ssl
self.__autoscaling_role_arn = autoscaling_role_arn
self.__dag_sync_role_arn = dag_sync_role_arn
super().__init__(
StorageClass(
ObjectMeta(name="efs-sc"), None, None, None, "efs.csi.aws.com", None
),
"Filesystem",
StorageClass(ObjectMeta(name="efs-sc"), "efs.csi.aws.com"), "Filesystem",
)

def get_csi_persistent_volume_source(self, name: str):
Expand Down Expand Up @@ -238,3 +238,7 @@ def webserver_service_annotations(self) -> Dict[str, str]:
"alb.ingress.kubernetes.io/healthcheck-path": "/airflow",
"alb.ingress.kubernetes.io/successCodes": "200,308",
}

@property
def dag_retrieval_annotations(self) -> Dict[str, str]:
return {"iam.amazonaws.com/role": self.__dag_sync_role_arn}
Empty file.
5 changes: 5 additions & 0 deletions avionix_airflow/kubernetes/cloud/cloud_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ def get_elastic_search_proxy_elements(
@abstractmethod
def webserver_service_annotations(self) -> Dict[str, str]:
return {}

@property
@abstractmethod
def dag_retrieval_annotations(self) -> Dict[str, str]:
return {}
4 changes: 4 additions & 0 deletions avionix_airflow/kubernetes/cloud/local/local_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ def webserver_service_annotations(self) -> Dict[str, str]:
@property
def extra_ingress_paths(self) -> List[AirflowIngressPath]:
return []

@property
def dag_retrieval_annotations(self) -> Dict[str, str]:
return {}
16 changes: 11 additions & 5 deletions avionix_airflow/kubernetes/monitoring/elasticsearch_dependency.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from avionix import ChartDependency
from avionix.kube.core import PersistentVolumeClaimSpec, ResourceRequirements


class ElasticSearchDependency(ChartDependency):

_labels = {"storage-type": "elasticsearch"}
_storage = {"storage": "100Mi"}
_access_modes = ["ReadWriteOnce"]

def __init__(self):
super().__init__(
"elasticsearch",
Expand All @@ -17,11 +23,11 @@ def __init__(self):
"requests": {"cpu": "100m", "memory": "512M"},
"limits": {"cpu": "1000m", "memory": "512M"},
},
"volumeClaimTemplate": {
"accessModes": ["ReadWriteOnce"],
"storageClassName": "standard",
"resources": {"requests": {"storage": "100M"}},
},
"volumeClaimTemplate": PersistentVolumeClaimSpec(
access_modes=self._access_modes,
resources=ResourceRequirements(requests=self._storage),
storage_class_name="standard",
).to_dict(),
"service": {"type": "NodePort", "nodePort": 30012},
},
)
6 changes: 6 additions & 0 deletions avionix_airflow/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from subprocess import check_call

from avionix.testing.installation_context import ChartInstallationContext
import pytest

Expand Down Expand Up @@ -81,6 +83,10 @@ def build_chart(airflow_options, sql_options, redis_options, monitoring_options)
builder = get_chart_builder(
airflow_options, sql_options, redis_options, monitoring_options
)
if kubectl_name_dict("persistentvolume"):
# Stateful Sets do not automatically clean up their pvc templates so this
# must be done manually
check_call("kubectl delete pvc -n airflow --all".split(" "))
while True:
if not filter_out_pvc(kubectl_name_dict("persistentvolume")):
break
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ dependencies:
- pytest-rerunfailures
- pip:
# Main requirements
- avionix==0.3.1
- avionix==0.4.0
- python-hosts==1.0.0
- cryptography==3.0
17 changes: 9 additions & 8 deletions examples/aws_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
create_database_in_cluster=False,
),
cloud_options=AwsOptions(
"fs-12345",
"my-cluster",
"arn:aws:iam::123456789012:role/es-role",
"arn:aws:iam::123456789012:role/default-role",
"arn:aws:iam::123456789012:role/alb-role",
"arn:aws:iam::123456789012:role/external-dns-role",
"arn:aws:iam::123456789012:role/autoscaling-role:",
"my.airflow.domain.com",
efs_id="fs-12345",
cluster_name="my-cluster",
elastic_search_access_role_arn="arn:aws:iam::123456789012:role/es-role",
default_role_arn="arn:aws:iam::123456789012:role/default-role",
alb_role_arn="arn:aws:iam::123456789012:role/alb-role",
external_dns_role_arn="arn:aws:iam::123456789012:role/external-dns-role",
autoscaling_role_arn="arn:aws:iam::123456789012:role/autoscaling-role",
domain="my.airflow.domain.com",
dag_sync_role_arn="arn:aws:iam::123456789012:role/dag_sync_role",
use_ssl=True,
),
)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
avionix>=0.3.1
avionix>=0.4.0
python-hosts==1.0.0
cryptography==3.0

0 comments on commit 19dd8db

Please sign in to comment.