def __init__(self, redis_options: RedisOptions): labels = ValueOrchestrator() super().__init__( AirflowMeta("redis-deployment"), DeploymentSpec(RedisPodTemplate(redis_options), LabelSelector(labels.redis_labels)), )
def test_deployment( chart_info, test_labels, pod_template_spec, selector, deployment_strategy: Optional[DeploymentStrategy], ): builder = ChartBuilder( chart_info, [ Deployment( metadata=ObjectMeta(name="test-deployment", labels=test_labels), spec=DeploymentSpec( replicas=1, template=pod_template_spec, selector=selector, strategy=deployment_strategy, ), ) ], ) with ChartInstallationContext(builder): deployment_info = kubectl_get("deployments") assert deployment_info["NAME"][0] == "test-deployment" assert deployment_info["READY"][0] == "1/1"
def __init__(self, sql_options: SqlOptions): super().__init__( AirflowMeta(name="postgres-database-deployment"), DeploymentSpec( PostgresPodTemplate(sql_options), LabelSelector(ValueOrchestrator().database_labels), ), )
def get_test_deployment(number: int): return Deployment( metadata=ObjectMeta(name=f"test-deployment-{number}", labels={"type": "master"}), spec=DeploymentSpec( replicas=1, template=PodTemplateSpec( ObjectMeta(labels={"container_type": "master"}), spec=PodSpec(containers=[get_test_container(number)]), ), selector=LabelSelector(match_labels={"container_type": "master"}), ), )
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, ) ]), ), ), )
def __init__( self, sql_options: SqlOptions, redis_options: RedisOptions, airflow_options: AirflowOptions, monitoring_options: MonitoringOptions, cloud_options: CloudOptions, ): super().__init__( AirflowMeta(name="airflow-master-deployment"), DeploymentSpec( AirflowMasterPodTemplate( sql_options, redis_options, airflow_options, monitoring_options, cloud_options, ), LabelSelector(ValueOrchestrator().master_node_labels), strategy=DeploymentStrategy( RollingUpdateDeployment(max_surge=1, max_unavailable=1)), ), )
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], )