From d31cda4277743bcd85303807ef7f2cd341299354 Mon Sep 17 00:00:00 2001 From: vitali-federau-fivestars <98967835+vitali-federau-fivestars@users.noreply.github.com> Date: Wed, 6 Dec 2023 15:52:04 +0300 Subject: [PATCH] [INFRA-2155] Removing aladdin dns-sync (#162) * [INFRA-2155] Removing aladdin dns-sync * [INFRA-2155] Updating aladdin version * [INFRA-2155] Removing function to create HZ * [INFRA-2155] Bringing back functionality to create HZ * [INFRA-2155] Removing function to create HZ * [INFRA-2155] Bringing back functionality to create HZ * [INFRA-2479] Removing from container values --- aladdin/bash/container/cluster/cluster | 3 +- .../container/test-remote/test-deploy.bats | 2 - aladdin/commands/deploy.py | 3 +- aladdin/commands/rollback.py | 3 +- aladdin/commands/start.py | 3 +- aladdin/commands/stop.py | 3 +- aladdin/commands/sync_dns.py | 52 ------------------- aladdin/commands/undeploy.py | 3 +- aladdin/main.py | 2 - docs/sync_dns_cmd.md | 13 ----- pyproject.toml | 2 +- 11 files changed, 7 insertions(+), 82 deletions(-) delete mode 100644 aladdin/commands/sync_dns.py delete mode 100755 docs/sync_dns_cmd.md diff --git a/aladdin/bash/container/cluster/cluster b/aladdin/bash/container/cluster/cluster index 998cd35..8f80a0d 100755 --- a/aladdin/bash/container/cluster/cluster +++ b/aladdin/bash/container/cluster/cluster @@ -141,7 +141,7 @@ function populate { # This script pulls from your backup folder in your $CLUSTER_CODE directory in your config directory # It reads the namespaces.txt file and creates all those namepsaces, and then populates those # namespaces with each namespace's yaml files to create all the k8s resources. - # We then call sync-ingress and sync-dns to update the route 53 records and ingress resource if necessary. + # We then call sync-ingress to update ingress resource if necessary. if ! "$SKIP_PROMPTS"; then echo "Is the cluster you wish to populate $CLUSTER_CODE? [y/N] " @@ -171,7 +171,6 @@ function populate { for ns in $(cat "$path_to_resources/namespaces.txt") do $PY_MAIN sync-ingress --namespace "$ns" - $PY_MAIN sync-dns --namespace "$ns" done } diff --git a/aladdin/bash/container/test-remote/test-deploy.bats b/aladdin/bash/container/test-remote/test-deploy.bats index 1684467..ef305a3 100644 --- a/aladdin/bash/container/test-remote/test-deploy.bats +++ b/aladdin/bash/container/test-remote/test-deploy.bats @@ -18,8 +18,6 @@ load test_helper kubectl get hpa | grep "aladdin-test-hpa\s" # Let elb become ready by sleeping for a minute sleep 60 - # Sync the dns after this in case it wasn't immediately ready - $PY_MAIN sync-dns # Verify sync-dns by checking if cname value equals service elb service_elb=$(get_elb aladdin-test-server) [[ $service_elb == $(get_cname_value aladdin-test-server "default.$DNS_ZONE") ]] diff --git a/aladdin/commands/deploy.py b/aladdin/commands/deploy.py index 6194694..9424bfb 100644 --- a/aladdin/commands/deploy.py +++ b/aladdin/commands/deploy.py @@ -8,7 +8,7 @@ COMMON_OPTION_PARSER, HELM_OPTION_PARSER, CHART_OPTION_PARSER, container_command ) from aladdin.lib.cluster_rules import ClusterRules -from aladdin.commands import sync_ingress, sync_dns +from aladdin.commands import sync_ingress from aladdin.config import load_git_configs from aladdin.lib.helm_rules import HelmRules from aladdin.lib.git import Git @@ -111,4 +111,3 @@ def deploy( ) if not dry_run: sync_ingress.sync_ingress(namespace) - sync_dns.sync_dns(namespace) diff --git a/aladdin/commands/rollback.py b/aladdin/commands/rollback.py index b7c8d5d..460708e 100644 --- a/aladdin/commands/rollback.py +++ b/aladdin/commands/rollback.py @@ -1,5 +1,5 @@ from aladdin.lib.arg_tools import add_namespace_argument, container_command -from aladdin.commands import sync_ingress, sync_dns +from aladdin.commands import sync_ingress from aladdin.lib.helm_rules import HelmRules from aladdin.lib.k8s.helm import Helm @@ -28,4 +28,3 @@ def rollback(project, num_versions, namespace, chart=None): helm.rollback_relative(HelmRules.get_release_name(chart or project), num_versions, namespace) sync_ingress.sync_ingress(namespace) - sync_dns.sync_dns(namespace) diff --git a/aladdin/commands/start.py b/aladdin/commands/start.py index de1a0d0..098009f 100644 --- a/aladdin/commands/start.py +++ b/aladdin/commands/start.py @@ -5,7 +5,7 @@ COMMON_OPTION_PARSER, HELM_OPTION_PARSER, CHARTS_OPTION_PARSER, container_command ) from aladdin.lib.cluster_rules import ClusterRules -from aladdin.commands import sync_ingress, sync_dns +from aladdin.commands import sync_ingress from aladdin.lib.helm_rules import HelmRules from aladdin.lib.k8s.helm import Helm from aladdin.lib.project_conf import ProjectConf @@ -76,4 +76,3 @@ def start( # Sync if any helm.start() call succeeded, even if a subsequent one failed if not dry_run: sync_ingress.sync_ingress(namespace) - sync_dns.sync_dns(namespace) diff --git a/aladdin/commands/stop.py b/aladdin/commands/stop.py index c60cb7b..a4f9a69 100644 --- a/aladdin/commands/stop.py +++ b/aladdin/commands/stop.py @@ -3,7 +3,7 @@ from aladdin.lib.arg_tools import CHARTS_OPTION_PARSER, COMMON_OPTION_PARSER, container_command from aladdin.lib.cluster_rules import ClusterRules -from aladdin.commands import sync_ingress, sync_dns +from aladdin.commands import sync_ingress from aladdin.lib.helm_rules import HelmRules from aladdin.lib.k8s.helm import Helm from aladdin.lib.project_conf import ProjectConf @@ -43,4 +43,3 @@ def stop(namespace, charts): # Sync if any helm.stop() call succeeded, even if a subsequent one failed if sync_required: sync_ingress.sync_ingress(namespace) - sync_dns.sync_dns(namespace) diff --git a/aladdin/commands/sync_dns.py b/aladdin/commands/sync_dns.py deleted file mode 100644 index ca216d2..0000000 --- a/aladdin/commands/sync_dns.py +++ /dev/null @@ -1,52 +0,0 @@ -import logging - -from aladdin.lib.arg_tools import add_namespace_argument, container_command -from aladdin.lib.cluster_rules import ClusterRules -from aladdin.lib.aws.dns_mapping import fill_hostedzone -from aladdin.lib.k8s.kubernetes import Kubernetes -from aladdin.lib.k8s.kubernetes_utils import KubernetesUtils - - -def parse_args(sub_parser): - subparser = sub_parser.add_parser( - "sync-dns", help="Synchronize the dns from the kubernetes services" - ) - add_namespace_argument(subparser) - subparser.add_argument( - "--force", - "-f", - action="store_true", - default=False, - ) - subparser.set_defaults( - func=lambda args: sync_dns(args.namespace, force=args.force) - ) - - -@container_command -def sync_dns(namespace: str, force: bool = False): - cr = ClusterRules(namespace=namespace) - if not cr.dns_sync and not force: - logging.info("Not syncing DNS because it's disabled for this cluster") - return - - k_utils = KubernetesUtils(Kubernetes(namespace=namespace)) - - service_loadbalancers = k_utils.get_services_to_load_balancers_map( - cr.dual_dns_prefix_annotation_name, cr.ingress_info - ) - - # Apply our dns to the service names - service_hostnames_to_loadbalancers = { - f"{service_name}.{cr.namespace_domain_name}": loadbalancer_hostname - for service_name, loadbalancer_hostname in service_loadbalancers.items() - } - - nb_updated = fill_hostedzone( - cr.boto, - service_hostnames_to_loadbalancers, - cr.cluster_domain_name, - cr.namespace_domain_name, - ) - - logging.info("%s DNS mapping updated" % (nb_updated or "No",)) diff --git a/aladdin/commands/undeploy.py b/aladdin/commands/undeploy.py index 498a8e1..db39eb3 100644 --- a/aladdin/commands/undeploy.py +++ b/aladdin/commands/undeploy.py @@ -1,6 +1,6 @@ from aladdin.lib.arg_tools import add_namespace_argument, container_command from aladdin.lib.cluster_rules import ClusterRules -from aladdin.commands import sync_ingress, sync_dns +from aladdin.commands import sync_ingress from aladdin.lib.helm_rules import HelmRules from aladdin.lib.k8s.helm import Helm @@ -30,4 +30,3 @@ def undeploy(project, namespace, chart=None): helm.stop(HelmRules.get_release_name(chart or project), namespace) sync_ingress.sync_ingress(namespace) - sync_dns.sync_dns(namespace) diff --git a/aladdin/main.py b/aladdin/main.py index 03f006b..edfa17d 100755 --- a/aladdin/main.py +++ b/aladdin/main.py @@ -25,7 +25,6 @@ scale, start, stop, - sync_dns, sync_ingress, tail, undeploy, @@ -62,7 +61,6 @@ def cli(): scale, start, stop, - sync_dns, sync_ingress, tail, undeploy, diff --git a/docs/sync_dns_cmd.md b/docs/sync_dns_cmd.md deleted file mode 100755 index aafdb17..0000000 --- a/docs/sync_dns_cmd.md +++ /dev/null @@ -1,13 +0,0 @@ -# Aladdin Sync-Dns -Sync-dns is one of aladdin's commands used to map consistent naming endpoints to service LoadBalancers. It does this by creating a cname from {service name}.{namespace}.{cluster dns} to your service ELB. The command will do this for all services in a namespace. -``` -usage: aladdin sync-dns [-h] [--namespace NAMESPACE] - -optional arguments: - -h, --help show this help message and exit - --namespace NAMESPACE, -n NAMESPACE - namespace name, defaults to default current : - [default] -``` - -More info [here](./doc/dns_and_certificate.md) diff --git a/pyproject.toml b/pyproject.toml index ddd0461..c90f1eb 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "aladdin" -version = "1.25.15.1" +version = "1.25.15.2" description = "" authors = ["Fivestars "] include = [