def __init__(self, redis_options: RedisOptions): labels = ValueOrchestrator() super().__init__( AirflowMeta("redis-pod", labels=labels.redis_labels), PodSpec([ Container( "redis", image="redis", image_pull_policy="IfNotPresent", ports=[ContainerPort(redis_options.port)], ) ], ), )
def __init__( self, sql_options: SqlOptions, redis_options: RedisOptions, airflow_options: AirflowOptions, ): super().__init__( "scheduler", sql_options, redis_options, airflow_options, [ContainerPort(8125, host_port=8125)], )
def __init__( self, sql_options: SqlOptions, redis_options: RedisOptions, airflow_options: AirflowOptions, ): super().__init__( "webserver", sql_options, redis_options, airflow_options, ports=[ContainerPort(8080, host_port=8080)], readiness_probe=AvionixAirflowProbe("/airflow", 8080, "0.0.0.0"), )
def get_test_container(number: int, env_var: Optional[EnvVar] = None, ephemeral: bool = False): container_class: type = Container if ephemeral: container_class = EphemeralContainer if env_var is None: env_var = EnvVar("test", "test-value") return container_class( name=f"test-container-{number}", image="k8s.gcr.io/echoserver:1.4", env=[env_var], ports=[ContainerPort(8080, name="port")], )
def __init__(self, sql_options: SqlOptions): super().__init__( AirflowMeta(name="postgres-database-pod", labels=ValueOrchestrator().database_labels), spec=PodSpec([ Container( name="postgres-database", image="postgres", env=sql_options.get_postgres_envioronment(), ports=[ContainerPort(5432, name="postgres")], image_pull_policy="IfNotPresent", ) ]), )
def __init__(self, cloud_options: CloudOptions, elastic_search_uri: str): values = ValueOrchestrator() probe = Probe( http_get=HTTPGetAction(path="/_cluster/health", port="https")) super().__init__( AirflowMeta("aws-es-proxy", ), DeploymentSpec( replicas=1, selector=LabelSelector(values.elasticsearch_proxy_labels), template=PodTemplateSpec( AirflowMeta( "es-proxy", labels=values.elasticsearch_proxy_labels, annotations=cloud_options. elasticsearch_connection_annotations, ), spec=PodSpec([ Container( "es-proxy", image="abutaha/aws-es-proxy:latest", image_pull_policy="IfNotPresent", args=[ "-listen", "0.0.0.0:9200", "-endpoint", elastic_search_uri, "-verbose", ], ports=[ ContainerPort(9200, protocol="TCP", name="https") ], liveness_probe=probe, readiness_probe=probe, ) ]), ), ), )
from avionix import ChartBuilder, ChartInfo, ObjectMeta from avionix.kube.apps import Deployment, DeploymentSpec, PodTemplateSpec from avionix.kube.core import Container, ContainerPort, EnvVar, LabelSelector, PodSpec container = Container( name="test-container", image="k8s.gcr.io/echoserver:1.4", env=[EnvVar("test", "test-value")], ports=[ContainerPort(8080)], ) deployment = Deployment( metadata=ObjectMeta(name="test-deployment", labels={"app": "my_app"}), spec=DeploymentSpec( replicas=1, template=PodTemplateSpec( ObjectMeta(labels={"app": "my_app"}), spec=PodSpec(containers=[container]), ), selector=LabelSelector(match_labels={"app": "my_app"}), ), ) builder = ChartBuilder( ChartInfo(api_version="3.2.4", name="test", version="0.1.0", app_version="v1"), [deployment], )