Skip to content

Commit

Permalink
Add config option to disable dns syncing (#151)
Browse files Browse the repository at this point in the history
- Added config option to disable dns syncing
- Added option to force dns syncing
  • Loading branch information
jarojasm95 authored Jan 18, 2023
1 parent 8fd6d34 commit 82a2c25
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
20 changes: 12 additions & 8 deletions aladdin/commands/sync_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@ def parse_args(sub_parser):
"sync-dns", help="Synchronize the dns from the kubernetes services"
)
add_namespace_argument(subparser)
subparser.set_defaults(func=sync_dns_args)


def sync_dns_args(args):
sync_dns(args.namespace)
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):
def sync_dns(namespace: str, force: bool = False):
cr = ClusterRules(namespace=namespace)
if cr.is_local:
logging.info("Not syncing DNS because you are on local")
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))
Expand Down
8 changes: 8 additions & 0 deletions aladdin/lib/cluster_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ def certificate_lookup(self):
return False
return self.rules.get("certificate_lookup", True)

@property
def dns_sync(self):
if strtobool(os.getenv("IS_LOCAL", "false")) or self.is_local:
return False
if strtobool(os.getenv("ALADDIN_DISABLE_DNS_SYNC", "false")):
return False
return self.rules.get("dns_sync", True)

@cached_property
def boto(self):
return boto3.Session(profile_name=self.aws_profile)
Expand Down

0 comments on commit 82a2c25

Please sign in to comment.