diff --git a/astraSDK/k8s.py b/astraSDK/k8s.py index 6969e18..24a055c 100644 --- a/astraSDK/k8s.py +++ b/astraSDK/k8s.py @@ -24,7 +24,7 @@ import yaml from datetime import datetime, timedelta, timezone -from .common import BaseCommon, KubeCommon, SDKCommon +from .common import KubeCommon, SDKCommon class getResources(KubeCommon): @@ -1055,58 +1055,3 @@ def main( version=body["apiVersion"].split("/")[1], group=body["apiVersion"].split("/")[0], ) - - -class createHeadlessConnector(BaseCommon): - """Creates an AstraConnector custom resource without registering to Astra Control""" - - def __init__( - self, quiet=True, dry_run=False, verbose=False, config_context=None, skip_tls_verify=False - ): - """quiet: Will there be CLI output or just return (datastructure) - dry-run: False (default): submit and persist the resource - True or non-empty str: submit request without persisting the resource - verbose: Print all of the rest call info: URL, Method, Headers, Request Body - config_context: the kubeconfig:context mapping to execute against - None: use system defaults - str "None:": use default kubeconfig w/ specified context - str ":": use specified file and context - skip_tls_verify: Whether to skip TLS/SSL verification""" - self.quiet = quiet - self.dry_run = dry_run - self.verbose = verbose - self.config_context = config_context - self.skip_tls_verify = skip_tls_verify - super().__init__() - - def main( - self, clusterName, regCred, registry, name="astra-connector", namespace="astra-connector" - ): - body = { - "apiVersion": "astra.netapp.io/v1", - "kind": "AstraConnector", - "metadata": {"name": name, "namespace": namespace}, - "spec": { - "astra": { - "clusterName": clusterName, - "clusterId": "123", - "cloudId": "123", - "accountId": "123", - }, - "natsSyncClient": {"cloudBridgeURL": "127.0.0.1"}, - "imageRegistry": {"name": registry, "secret": regCred}, - }, - } - return createResource( - quiet=self.quiet, - dry_run=self.dry_run, - verbose=self.verbose, - config_context=self.config_context, - skip_tls_verify=self.skip_tls_verify, - ).main( - body["kind"].lower() + "s", - namespace, - body, - version=body["apiVersion"].split("/")[1], - group=body["apiVersion"].split("/")[0], - ) diff --git a/tkSrc/manage.py b/tkSrc/manage.py index 066ba2f..3919611 100644 --- a/tkSrc/manage.py +++ b/tkSrc/manage.py @@ -152,75 +152,66 @@ def manageV3Cluster( regCred, registry, cloudID, - headless, ard, label=None, config=None, ): helpers.isRFC1123(clusterName) + # Create the Astra Connector Operator and Astra API token secret create.createV3ConnectorOperator(v3, dry_run, skip_tls_verify, verbose, operator_version) - # Create the astra API token secret - if not headless: - apiToken = astraSDK.k8s.createAstraApiToken( - quiet=quiet, - dry_run=dry_run, - verbose=verbose, - config_context=v3, - skip_tls_verify=skip_tls_verify, - config=config, - ).main() - # Handle the registry secret - if not regCred: - cred = astraSDK.k8s.createRegCred( - quiet=quiet, - dry_run=dry_run, - verbose=verbose, - config_context=v3, - skip_tls_verify=skip_tls_verify, - config=config, - ).main(registry=registry, namespace="astra-connector") - if not cred: - raise SystemExit("astraSDK.k8s.createRegCred() failed") - regCred = cred["metadata"]["name"] - else: + apiToken = astraSDK.k8s.createAstraApiToken( + quiet=quiet, + dry_run=dry_run, + verbose=verbose, + config_context=v3, + skip_tls_verify=skip_tls_verify, + config=config, + ).main() + # Verify / create the registry secret depending on user input + if regCred: if ard.needsattr("credentials"): ard.credentials = astraSDK.k8s.getSecrets( config_context=v3, skip_tls_verify=skip_tls_verify ).main() cred = ard.getSingleDict("credentials", "metadata.name", regCred) - # Create the AstraConnector CR - if headless: - connector = astraSDK.k8s.createHeadlessConnector( - quiet=quiet, - dry_run=dry_run, - verbose=verbose, - config_context=v3, - skip_tls_verify=skip_tls_verify, - ).main(clusterName, regCred, registry) else: - rc = astraSDK.clusters.addCluster(quiet=quiet, verbose=verbose, config=config).main( - cloudID, name=clusterName, connectorInstall=True - ) - if not rc: - raise SystemExit("astraSDK.clusters.addCluster() failed") - connector = astraSDK.k8s.createAstraConnector( + cred = astraSDK.k8s.createRegCred( quiet=quiet, dry_run=dry_run, verbose=verbose, config_context=v3, skip_tls_verify=skip_tls_verify, config=config, - ).main( - clusterName, - rc["id"], - cloudID, - apiToken["metadata"]["name"], - regCred, - registry=registry, - label=label, - ) + ).main(registry=registry, namespace="astra-connector") + if not cred: + raise SystemExit("astraSDK.k8s.createRegCred() failed") + regCred = cred["metadata"]["name"] + # Create the cluster + cluster = astraSDK.clusters.addCluster(quiet=quiet, verbose=verbose, config=config).main( + cloudID, name=clusterName, connectorInstall=True + ) + if not cluster: + raise SystemExit("astraSDK.clusters.addCluster() failed") + # Create the AstraConnector CR + connector = astraSDK.k8s.createAstraConnector( + quiet=quiet, + dry_run=dry_run, + verbose=verbose, + config_context=v3, + skip_tls_verify=skip_tls_verify, + config=config, + ).main( + clusterName, + cluster["id"], + cloudID, + apiToken["metadata"]["name"], + regCred, + registry=registry, + label=label, + ) if not connector: raise SystemExit("astraSDK.k8s.createAstraConnector() failed") + return connector def validateBucketArgs(args): @@ -444,7 +435,6 @@ def main(args, ard, config=None): args.regCred, args.registry, args.cloudID, - args.headless, ard, label=args.label, config=config, diff --git a/tkSrc/parser.py b/tkSrc/parser.py index 4b0384b..58df05a 100644 --- a/tkSrc/parser.py +++ b/tkSrc/parser.py @@ -1862,9 +1862,6 @@ def manage_cluster_args(self): help="optionally specify a label to be added to the AstraConnector CR, for " "example: 'acs.example.com/policy=allowed'", ) - self.subparserManageCluster.add_argument( - "--headless", action="store_true", default=False, help=argparse.SUPPRESS - ) versionGroup = self.subparserManageCluster.add_argument_group( "operatorGroup", "Astra Connector Operator Version to install" )