From 905b78910708d462ea38e59543f415c33748a2cb Mon Sep 17 00:00:00 2001 From: Latha Sivakumar Date: Thu, 14 Oct 2021 23:29:01 -0400 Subject: [PATCH 01/11] (issue #150) Add support for Red Hat OpenShift --- pre_install_report/README.md | 16 ++- .../library/pre_install_check.py | 11 +- .../library/pre_install_check_permissions.py | 129 +++++++++++++++--- .../utils/hello_ops_route_no_host.yaml | 21 +++ .../library/utils/viya_constants.py | 3 + .../library/utils/viya_messages.py | 2 +- pre_install_report/pre_install_report.py | 20 ++- .../test_data/json_data/openshift_route.json | 78 +++++++++++ .../test/test_pre_install_report.py | 29 ++++ 9 files changed, 271 insertions(+), 38 deletions(-) create mode 100644 pre_install_report/library/utils/hello_ops_route_no_host.yaml create mode 100644 pre_install_report/test/test_data/json_data/openshift_route.json diff --git a/pre_install_report/README.md b/pre_install_report/README.md index 5e1bf4a..f2df5d8 100644 --- a/pre_install_report/README.md +++ b/pre_install_report/README.md @@ -73,8 +73,7 @@ Download the latest version of this tool and update required packages with every **Note:** You must set your `KUBECONFIG` environment variable. `KUBECONFIG` must have administrator rights in the namespace where you intend to deploy your SAS Viya software. -To obtain a complete report use a `KUBECONFIG` -with administrator rights in the cluster. +To obtain a complete report use a `KUBECONFIG` with administrator rights in the cluster. Create the namespace where you plan to deploy SAS Viya. You must specify the namespace when you run the tool. @@ -86,20 +85,23 @@ The following command provides usage details: python3 viya-ark.py pre-install-report -h ``` -**Note:** The tool currently expects an NGINX Ingress controller. Other Ingress controllers are not evaluated. +**Supported Ingress values:** The tool currently supports an nginx or openshift-ingress Ingress controller. +Other Ingress controllers are not evaluated. Select openshift-ingress with if you are deploying on Red Hat OpenShift. ### Hints - +**Note:** The values for the Ingress Host and Port values are not required if you specify an ingress value +of _openshift-ingress_. The Ingress Host and Port values must be specified for if you specify an ingress +value of _nginx_. The values for the Ingress Host and Ingress Port options can be determined with kubectl commands. -The following section provides hints for a NGINX Ingress controller of Type LoadBalancer. -The following commands -may need to be modified to suit your Ingress controller deployment. +The following section provides hints for a _nginx_ Ingress controller of Type LoadBalancer. +The following commands may need to be modified to suit your Ingress controller deployment. You must specify the namespace where the Ingress controller is available as well as the Ingress controller name: ``` kubectl -n get svc ``` + Here is sample output from the command: diff --git a/pre_install_report/library/pre_install_check.py b/pre_install_report/library/pre_install_check.py index ebfbede..47b8201 100644 --- a/pre_install_report/library/pre_install_check.py +++ b/pre_install_report/library/pre_install_check.py @@ -71,6 +71,7 @@ def __init__(self, sas_logger: ViyaARKLogger, viya_kubelet_version_min, self._calculated_aggregate_memory = None self._workers = 0 self._aggregate_nodeStatus_failures = 0 + self._ingress_controller = None def _parse_release_info(self, release_info): """ @@ -92,7 +93,7 @@ def _parse_release_info(self, release_info): def check_details(self, kubectl, ingress_port, ingress_host, ingress_controller, output_dir): - + self._ingress_controller = ingress_controller self._kubectl = kubectl name_space = kubectl.get_namespace() self.logger.info("names_space: {} ".format(name_space)) @@ -395,19 +396,25 @@ def _check_permissions(self, permissions_check: PreCheckPermissions): permissions_check.manage_pvc(viya_constants.KUBECTL_APPLY, False) permissions_check.check_sample_application() permissions_check.check_sample_ingress() + if self._ingress_controller == viya_constants.OPENSHIFT_INGRESS: + permissions_check.check_openshift_route() permissions_check.check_deploy_crd() permissions_check.check_rbac_role() permissions_check.check_create_custom_resource() permissions_check.check_get_custom_resource(namespace) + if self._ingress_controller == viya_constants.OPENSHIFT_INGRESS: + permissions_check.get_openshift_route_details() + permissions_check.check_openshift_route_host_port() permissions_check.check_delete_custom_resource() permissions_check.check_rbac_delete_role() permissions_check.check_sample_response() - permissions_check.check_delete_crd() permissions_check.check_delete_sample_application() permissions_check.check_delete_sample_ingress() + if self._ingress_controller == viya_constants.OPENSHIFT_INGRESS: + permissions_check.check_delete_openshift_route() # Check the status of deployed PVCs permissions_check.manage_pvc(viya_constants.KUBECTL_APPLY, True) # Delete all Deployed PVCs diff --git a/pre_install_report/library/pre_install_check_permissions.py b/pre_install_report/library/pre_install_check_permissions.py index 2b90f6e..9241bad 100644 --- a/pre_install_report/library/pre_install_check_permissions.py +++ b/pre_install_report/library/pre_install_check_permissions.py @@ -49,6 +49,10 @@ INGRESS_V1BETA1_REL_EQ = '==1.18' INGRESS_UNSUPPORTED_REL_LT = '<1.18' +OPS_ROUTE_NAME = "no-route-hello-world" +OPS_ROUTE_KEY = "host" +OPS_ROUTE_KIND = "route" + class PreCheckPermissions(object): """ @@ -84,6 +88,8 @@ def __init__(self, params): self._sample_deployment = 0 self._sample_output = "" self._k8s_git_version = None + self._openshift_host_port = viya_constants.NO_HOST_FOUND + self._route_k8s_resource: KubernetesResource = None def _set_results_cluster_admin(self, resource_key, rc): """ @@ -136,8 +142,6 @@ def _set_results_namespace_admin(self, resource_key, rc, message=""): viya_constants.INSUFFICIENT_PERMS + ". Check Logs." else: self.namespace_admin_permission_data[resource_key] = viya_constants.ADEQUATE_PERMS - # self.namespace_admin_permission_aggregate[viya_constants.PERM_PERMISSIONS] = \ - # viya_constants.ADEQUATE_PERMS def _get_pvc(self, pvc_name, key): """ @@ -363,7 +367,7 @@ def _set_results_namespace_admin_crd(self, resource_key, rc): def check_sample_application(self): """ - Deploy hello-world in specified namespace and set the permissiions status in the + Deploy hello-world in specified namespace and set the permissions status """ @@ -398,6 +402,80 @@ def check_sample_application(self): return 1 + def check_openshift_route(self): + + rc = self.utils.deploy_manifest_file(viya_constants.KUBECTL_APPLY, + 'hello_ops_route_no_host.yaml') + + if rc == 0: + self._set_results_namespace_admin(viya_constants.PERM_DEPLOYMENT, rc) + self._set_results_namespace_admin(viya_constants.PERM_ROUTER, rc) + else: + self._sample_deployment = 1 + self._set_results_namespace_admin(viya_constants.PERM_DEPLOYMENT, rc) + self._set_results_namespace_admin(viya_constants.PERM_ROUTER, rc) + return 1 + + def get_openshift_route_details(self): + """ + Get host/port of deployed route name + + action: issue kubectl command to get host/port value in route + + """ + self._route_k8s_resource: KubernetesResource = self.utils.get_resource(OPS_ROUTE_KIND, OPS_ROUTE_NAME) + self.logger.info("route json{}".format(pprint.pformat(self._route_k8s_resource.as_dict()))) + + def check_delete_openshift_route(self): + """ + Delete hello-world Kubernetes Service in specified namespace. Set the + permissions status in the namespace_admin_permission_data dict object. + + """ + rc = self.utils.deploy_manifest_file(viya_constants.KUBECTL_DELETE, + 'hello_ops_route_no_host.yaml') + self._set_results_namespace_admin(viya_constants.PERM_DELETE + viya_constants.PERM_ROUTER, rc) + + def set_route_k8s_resource(self, route: KubernetesResource): + """ + Set the route information as KubernetesResource + Mainly used for pytest + """ + self._route_k8s_resource: KubernetesResource = route + + def get_route_host(self): + """ + Get the route host/port retrieved from route: KubernetesResource + Mainly used for pytest + """ + return str(self._openshift_host_port) + + def get_ingress_controller(self): + """ + Get the current ingress_controller + + """ + return str(self.ingress_controller) + + def check_openshift_route_host_port(self): + """ + Get host/port of deployed route name = "no-route-hello-world" + + action: issue kubectl command to get host/port value in route + + """ + ingress = self._route_k8s_resource.get_status_value("ingress") + + for dic in ingress: + for ingress_key, val in dic.items(): + # print(f'{ingress_key} is {val}') + if ingress_key == OPS_ROUTE_KEY: + self._openshift_host_port = val + self.logger.info("host_port {}".format(pprint.pformat(self._openshift_host_port))) + + if self._openshift_host_port == viya_constants.NO_HOST_FOUND: + self.logger.error("host_port {}".format(pprint.pformat(self._openshift_host_port))) + def check_sample_service(self): """ Deploy Kubernetes Service for hello-world appliction in specified namespace and set the @@ -468,7 +546,11 @@ def check_sample_response(self): if self.ingress_port is not None: port = ":" + self.ingress_port host_port_app = str(self.ingress_host) + str(port) + "/hello-world" + url_string = "http://" + host_port_app + if self.ingress_controller == viya_constants.OPENSHIFT_INGRESS: + url_string = "http://" + str(self._openshift_host_port) + "/hello-world" + self.logger.info("url {}".format(url_string)) response = self._request_url(url_string, True) if response is not None: @@ -478,26 +560,29 @@ def check_sample_response(self): " " + str(response.text) self.logger.info("url {} response status code {}".format(url_string, str(response.status_code))) else: - # attempt the request again with https and verify=False option, suppress InsecureRequestWarning - url_string = "https://" + host_port_app - response = self._request_url(url_string, False) - if response is not None: - response.encoding = 'utf-8' - if response.status_code == 200: - self.namespace_admin_permission_data[viya_constants.PERM_SAMPLE_STATUS] = \ - str(response.status_code) + " " + str(response.text) - self.logger.info("url {} response status code {}".format(url_string, str(response.status_code))) + if self.ingress_controller != viya_constants.OPENSHIFT_INGRESS: + + # attempt the request again with https and verify=False option, suppress InsecureRequestWarning + url_string = "https://" + host_port_app + response = self._request_url(url_string, False) + if response is not None: + response.encoding = 'utf-8' + if response.status_code == 200: + self.namespace_admin_permission_data[viya_constants.PERM_SAMPLE_STATUS] = \ + str(response.status_code) + " " + str(response.text) + self.logger.info("url {} response status code {}".format(url_string, + str(response.status_code))) + else: + self.namespace_admin_permission_aggregate[viya_constants.PERM_PERMISSIONS] = \ + viya_constants.INSUFFICIENT_PERMS + + self.namespace_admin_permission_data['Sample HTTP Failed'] = "Status Code " + \ + str(response.status_code) + \ + ": " + str(url_string) + self.logger.info("url {} status {} text {}".format(url_string, + response.status_code, response.text)) else: - self.namespace_admin_permission_aggregate[viya_constants.PERM_PERMISSIONS] = \ - viya_constants.INSUFFICIENT_PERMS - - self.namespace_admin_permission_data['Sample HTTP Failed'] = "Status Code " + \ - str(response.status_code) + \ - ": " + str(url_string) - self.logger.info("url {} status {} text {}".format(url_string, - response.status_code, response.text)) - else: - self.logger.error("Retry as https failed url {}".format(url_string)) + self.logger.error("Retry as https failed url {}".format(url_string)) def _request_url(self, url_string, verify_cert=True): """ diff --git a/pre_install_report/library/utils/hello_ops_route_no_host.yaml b/pre_install_report/library/utils/hello_ops_route_no_host.yaml new file mode 100644 index 0000000..28eca83 --- /dev/null +++ b/pre_install_report/library/utils/hello_ops_route_no_host.yaml @@ -0,0 +1,21 @@ +#################################################################### +#### hello_ops_route_no_host.yaml #### +#################################################################### +#################################################################### +#### Author: SAS Institute Inc. #### +#### #### +#################################################################### +#################################################################### +# +# Copyright (c) 2021, SAS Institute Inc., Cary, NC, USA. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# +--- +apiVersion: route.openshift.io/v1 +kind: Route +metadata: + name: no-route-hello-world +spec: + to: + kind: Service + name: hello-world \ No newline at end of file diff --git a/pre_install_report/library/utils/viya_constants.py b/pre_install_report/library/utils/viya_constants.py index e12b084..22b071e 100644 --- a/pre_install_report/library/utils/viya_constants.py +++ b/pre_install_report/library/utils/viya_constants.py @@ -25,6 +25,8 @@ ADEQUATE_PERMS = "Adequate" INGRESS_NGINX = "nginx" INGRESS_ISTIO = "istio" +OPENSHIFT_INGRESS = "openshift-ingress" +NO_HOST_FOUND = "No_host_found" INGRESS_CONTROLLER = "ingress_controller" INGRESS_HOST = "ingress_host" INGRESS_PORT = "ingress_port" @@ -32,6 +34,7 @@ PERM_PERMISSIONS = "Permissions" PERM_DEPLOYMENT = "Deployment" PERM_SERVICE = "Service" +PERM_ROUTER = "Openshift Router" PERM_AZ_FILE = "AzureFile Storage RWX" PERM_AZ_FILE_PR = "AzureFilePremium Storage RWX" PERM_AZ_DISK = "AzureDisk Storage" diff --git a/pre_install_report/library/utils/viya_messages.py b/pre_install_report/library/utils/viya_messages.py index cc1ca38..c507d3f 100644 --- a/pre_install_report/library/utils/viya_messages.py +++ b/pre_install_report/library/utils/viya_messages.py @@ -24,7 +24,7 @@ 'specified in the pre_install_report/viya_deployment_settings.ini file' OPTION_ERROR = "ERROR: option {} not recognized" OPTION_VALUES_ERROR = "ERROR: Provide valid values for all required options. Check options -i, -p and -H." -INGRESS_CONTROLLER_ERROR = "ERROR: Ingress controller specified must be nginx. Check value on option -i " +INGRESS_CONTROLLER_ERROR = "ERROR: Ingress controller specified must be nginx or openshift. Check value on option -i " OUPUT_PATH_ERROR = "ERROR: The report output path is not valid {}. Check value on option -o " EXCEPTION_MESSAGE = "ERROR: {}" KUBECONF_FILE_ERROR = "ERROR: The file specified in the KUBECONFIG environment does not exist. " \ diff --git a/pre_install_report/pre_install_report.py b/pre_install_report/pre_install_report.py index 78ddd7c..ff5c0b3 100644 --- a/pre_install_report/pre_install_report.py +++ b/pre_install_report/pre_install_report.py @@ -133,12 +133,13 @@ def usage(exit_code: int): :param exit_code: The exit code to return when exiting the program. """ print() - print("Usage: viya-ark.py pre_install_report <-i|--ingress> <-H|--host> <-p|--port> []") + print("Usage: viya-ark.py pre_install_report <-i|--ingress> []") print() print("Options:") - print(" -i --ingress=nginx (Required)Kubernetes ingress controller used for Viya deployment") - print(" -H --host (Required)Ingress host used for Viya deployment") - print(" -p --port=xxxxx or \"\" (Required)Ingress port used for Viya deployment") + print(" -i --ingress (Required)Kubernetes ingress controller: " + "select nginx or openshift-ingress") + print(" -H --host (Optional)Ingress host used for Viya deployment") + print(" -p --port=xxxxx or \"\" (Optional)Ingress port used for Viya deployment") print(" -h --help (Optional)Show this usage message") print(" -n --namespace (Optional)Kubernetes namespace used for Viya deployment") print(" -o, --output-dir=\"\" (Optional)Write the report and log files to the provided directory") @@ -170,6 +171,7 @@ def main(argv): found_ingress_port: bool = False output_dir: Optional[Text] = "" ingress_port: Optional[Text] = "" + ingress_host: Optional[Text] = "" name_space: Optional[Text] = None logging_level: int = logging.INFO @@ -216,16 +218,22 @@ def main(argv): logger = sas_logger.get_logger() read_environment_var('KUBECONFIG') - if not found_ingress_controller or not found_ingress_host or not found_ingress_port: + if not found_ingress_controller: logger.error(viya_messages.OPTION_VALUES_ERROR) print(viya_messages.OPTION_VALUES_ERROR) usage(viya_messages.BAD_OPT_RC_) - if not(str(ingress_controller) == viya_constants.INGRESS_NGINX): + if not(str(ingress_controller) == viya_constants.INGRESS_NGINX) and \ + not(str(ingress_controller) == viya_constants.OPENSHIFT_INGRESS): logger.error(viya_messages.INGRESS_CONTROLLER_ERROR) print(viya_messages.INGRESS_CONTROLLER_ERROR) usage(viya_messages.BAD_OPT_RC_) + if (str(ingress_controller) == viya_constants.INGRESS_NGINX) and not found_ingress_host and not found_ingress_port: + logger.error(viya_messages.OPTION_VALUES_ERROR) + print(viya_messages.OPTION_VALUES_ERROR) + usage(viya_messages.BAD_OPT_RC_) + try: kubectl = Kubectl(namespace=name_space) except ConnectionError as e: diff --git a/pre_install_report/test/test_data/json_data/openshift_route.json b/pre_install_report/test/test_data/json_data/openshift_route.json new file mode 100644 index 0000000..c79609b --- /dev/null +++ b/pre_install_report/test/test_data/json_data/openshift_route.json @@ -0,0 +1,78 @@ +{ + "apiVersion": "route.openshift.io/v1", + "kind": "Route", + "metadata": { + "annotations": { + "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"route.openshift.io/v1\",\"kind\":\"Route\",\"metadata\":{\"annotations\":{},\"name\":\"no-route-hostname\",\"namespace\":\"lasiva\"},\"spec\":{\"to\":{\"kind\":\"Service\",\"name\":\"hello-world\"}}}\n", + "openshift.io/host.generated": "true" + }, + "creationTimestamp": "2021-10-08T20:34:00Z", + "managedFields": [ + { + "apiVersion": "route.openshift.io/v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:metadata": { + "f:annotations": { + ".": {}, + "f:kubectl.kubernetes.io/last-applied-configuration": {} + } + }, + "f:spec": { + "f:to": { + "f:kind": {}, + "f:name": {}, + "f:weight": {} + }, + "f:wildcardPolicy": {} + } + }, + "manager": "kubectl-client-side-apply", + "operation": "Update", + "time": "2021-10-08T20:34:00Z" + }, + { + "apiVersion": "route.openshift.io/v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:status": { + "f:ingress": {} + } + }, + "manager": "openshift-router", + "operation": "Update", + "time": "2021-10-08T20:34:01Z" + } + ], + "name": "no-route-hostname", + "namespace": "lasiva", + "resourceVersion": "52971872", + "uid": "95e8870c-0625-47ba-b719-f54620003b38" + }, + "spec": { + "host": "no-route-hostname-lasiva.apps.ocp47vmw02.devops.rnd.sas.com", + "to": { + "kind": "Service", + "name": "hello-world", + "weight": 100 + }, + "wildcardPolicy": "None" + }, + "status": { + "ingress": [ + { + "conditions": [ + { + "lastTransitionTime": "2021-10-08T20:34:01Z", + "status": "True", + "type": "Admitted" + } + ], + "host": "no-route-hostname-lasiva.apps.ocp47vmw02.devops.rnd.sas.com", + "routerCanonicalHostname": "apps.ocp47vmw02.devops.rnd.sas.com", + "routerName": "default", + "wildcardPolicy": "None" + } + ] + } +} \ No newline at end of file diff --git a/pre_install_report/test/test_pre_install_report.py b/pre_install_report/test/test_pre_install_report.py index c64ab92..514fa4a 100644 --- a/pre_install_report/test/test_pre_install_report.py +++ b/pre_install_report/test/test_pre_install_report.py @@ -19,6 +19,8 @@ import semantic_version from pint import UnitRegistry +from pre_install_report.library.pre_install_utils import PreCheckUtils +from viya_ark_library.k8s.sas_k8s_objects import KubernetesResource from pre_install_report.library.utils import viya_constants from pre_install_report.library.pre_install_check import ViyaPreInstallCheck from pre_install_report.library.pre_install_check_permissions import PreCheckPermissions @@ -294,6 +296,33 @@ def test_get_no_config_info(): assert configs_data == [[]] +def test_check_route_host_port(): + current_dir = os.path.dirname(os.path.abspath(__file__)) + datafile = os.path.join(current_dir, 'test_data/json_data/openshift_route.json') + data = None + with open(datafile) as f: + data = json.load(f) + route_k8s: KubernetesResource = KubernetesResource(data) + assert route_k8s.get_kind() == "Route" + + pre_check_utils_params = {} + pre_check_utils_params[viya_constants.KUBECTL] = None + pre_check_utils_params["logger"] = sas_logger + utils = PreCheckUtils(pre_check_utils_params) + params = {} + params[viya_constants.INGRESS_CONTROLLER] = viya_constants.OPENSHIFT_INGRESS + params[viya_constants.INGRESS_HOST] = '' + params[viya_constants.INGRESS_PORT] = '' + params['logger'] = sas_logger + params[viya_constants.PERM_CLASS] = utils + permissions_check = PreCheckPermissions(params) + + permissions_check.set_route_k8s_resource(route_k8s) + permissions_check.check_openshift_route_host_port() + host = permissions_check.get_route_host() + assert host == 'no-route-hostname-lasiva.apps.ocp47vmw02.devops.rnd.sas.com' + + def test_get_config_info(): vpc = createViyaPreInstallCheck(viya_kubelet_version_min, viya_min_aggregate_worker_CPU_cores, From 1b408957acbea350099fe00f147a38eb95ced0e1 Mon Sep 17 00:00:00 2001 From: Latha Sivakumar Date: Fri, 15 Oct 2021 11:14:12 -0400 Subject: [PATCH 02/11] (issue #150) Add support for Red Hat OpenShift - Update README --- pre_install_report/README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pre_install_report/README.md b/pre_install_report/README.md index f2df5d8..4051ed6 100644 --- a/pre_install_report/README.md +++ b/pre_install_report/README.md @@ -85,18 +85,20 @@ The following command provides usage details: python3 viya-ark.py pre-install-report -h ``` -**Supported Ingress values:** The tool currently supports an nginx or openshift-ingress Ingress controller. -Other Ingress controllers are not evaluated. Select openshift-ingress with if you are deploying on Red Hat OpenShift. +**Supported Ingress values:** The tool currently supports an NGINX or openshift-ingress ingress controller. +Other ingress controllers are not evaluated. Select openshift-ingress if you are deploying on Red Hat OpenShift. ### Hints **Note:** The values for the Ingress Host and Port values are not required if you specify an ingress value -of _openshift-ingress_. The Ingress Host and Port values must be specified for if you specify an ingress -value of _nginx_. +of _openshift-ingress_. The Ingress Host and Port values must be specified if you specify an ingress +value of _nginx_. + The values for the Ingress Host and Ingress Port options can be determined with kubectl commands. -The following section provides hints for a _nginx_ Ingress controller of Type LoadBalancer. -The following commands may need to be modified to suit your Ingress controller deployment. -You must specify the namespace where the Ingress controller is available as well as the Ingress controller name: +The following section provides hints for a _nginx_ ingress controller of Type LoadBalancer. +The following commands may need to be modified to suit your ingress controller deployment. + +You must specify the namespace where the ingress controller is available as well as the ingress controller name: ``` kubectl -n get svc From 40057ffa40064a40b3e305e2a85e9b0d052e4c60 Mon Sep 17 00:00:00 2001 From: Latha Sivakumar Date: Mon, 18 Oct 2021 16:26:31 -0400 Subject: [PATCH 03/11] (issue #150) Add support for Red Hat OpenShift - change openshift-ingress to openshift --- pre_install_report/README.md | 6 +++--- pre_install_report/library/utils/viya_constants.py | 2 +- pre_install_report/pre_install_report.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pre_install_report/README.md b/pre_install_report/README.md index 4051ed6..d56658e 100644 --- a/pre_install_report/README.md +++ b/pre_install_report/README.md @@ -85,12 +85,12 @@ The following command provides usage details: python3 viya-ark.py pre-install-report -h ``` -**Supported Ingress values:** The tool currently supports an NGINX or openshift-ingress ingress controller. -Other ingress controllers are not evaluated. Select openshift-ingress if you are deploying on Red Hat OpenShift. +**Supported Ingress values:** The tool currently supports the following ingress controllers: _nginx, openshift_. +Other ingress controllers are not evaluated. Select _openshift_ if you are deploying on Red Hat OpenShift. ### Hints **Note:** The values for the Ingress Host and Port values are not required if you specify an ingress value -of _openshift-ingress_. The Ingress Host and Port values must be specified if you specify an ingress +of _openshift_. The Ingress Host and Port values must be specified if you specify an ingress value of _nginx_. The values for the Ingress Host and Ingress Port options can be determined with kubectl commands. diff --git a/pre_install_report/library/utils/viya_constants.py b/pre_install_report/library/utils/viya_constants.py index 22b071e..ce0f54b 100644 --- a/pre_install_report/library/utils/viya_constants.py +++ b/pre_install_report/library/utils/viya_constants.py @@ -25,7 +25,7 @@ ADEQUATE_PERMS = "Adequate" INGRESS_NGINX = "nginx" INGRESS_ISTIO = "istio" -OPENSHIFT_INGRESS = "openshift-ingress" +OPENSHIFT_INGRESS = "openshift" NO_HOST_FOUND = "No_host_found" INGRESS_CONTROLLER = "ingress_controller" INGRESS_HOST = "ingress_host" diff --git a/pre_install_report/pre_install_report.py b/pre_install_report/pre_install_report.py index ff5c0b3..7f03deb 100644 --- a/pre_install_report/pre_install_report.py +++ b/pre_install_report/pre_install_report.py @@ -137,7 +137,7 @@ def usage(exit_code: int): print() print("Options:") print(" -i --ingress (Required)Kubernetes ingress controller: " - "select nginx or openshift-ingress") + "{} or {}".format(viya_constants.INGRESS_NGINX, viya_constants.OPENSHIFT_INGRESS)) print(" -H --host (Optional)Ingress host used for Viya deployment") print(" -p --port=xxxxx or \"\" (Optional)Ingress port used for Viya deployment") print(" -h --help (Optional)Show this usage message") From 4f3de450ba2bf906fefb07a72c533f381ce207b7 Mon Sep 17 00:00:00 2001 From: Latha Sivakumar Date: Tue, 19 Oct 2021 12:14:03 -0400 Subject: [PATCH 04/11] (issue #150) Add support for Red Hat OpenShift - change openshift-ingress to openshift --- pre_install_report/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pre_install_report/README.md b/pre_install_report/README.md index d56658e..c72c64c 100644 --- a/pre_install_report/README.md +++ b/pre_install_report/README.md @@ -85,7 +85,8 @@ The following command provides usage details: python3 viya-ark.py pre-install-report -h ``` -**Supported Ingress values:** The tool currently supports the following ingress controllers: _nginx, openshift_. +### Supported Ingress values: +The tool currently supports the following ingress controllers: _nginx, openshift_. Other ingress controllers are not evaluated. Select _openshift_ if you are deploying on Red Hat OpenShift. ### Hints From d6fe206351de16b6e10da68b6e62db96e87d4dd8 Mon Sep 17 00:00:00 2001 From: Latha Sivakumar Date: Tue, 19 Oct 2021 12:33:45 -0400 Subject: [PATCH 05/11] (issue #150) Add support for Red Hat OpenShift - change openshift-ingress to openshift --- pre_install_report/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_install_report/README.md b/pre_install_report/README.md index c72c64c..3967b96 100644 --- a/pre_install_report/README.md +++ b/pre_install_report/README.md @@ -85,7 +85,7 @@ The following command provides usage details: python3 viya-ark.py pre-install-report -h ``` -### Supported Ingress values: +### Supported Ingress Values The tool currently supports the following ingress controllers: _nginx, openshift_. Other ingress controllers are not evaluated. Select _openshift_ if you are deploying on Red Hat OpenShift. From e140059bf0f45689e52190b340fac6a882bec9b1 Mon Sep 17 00:00:00 2001 From: Amy Ho <39809594+cuddlehub@users.noreply.github.com> Date: Thu, 21 Oct 2021 13:15:57 -0400 Subject: [PATCH 06/11] (#151) Remove None kind from report (#152) * (#151) Remove None kind from report * (#151) Remove None kind from report --- deployment_report/templates/viya_deployment_report.html.j2 | 2 ++ .../k8s/test_impl/response_data/api_resources_ingress_all.json | 2 +- .../test_impl/response_data/api_resources_ingress_contour.json | 2 +- .../test_impl/response_data/api_resources_ingress_istio.json | 2 +- .../test_impl/response_data/api_resources_ingress_nginx.json | 2 +- .../k8s/test_impl/response_data/api_resources_ingress_none.json | 2 +- .../response_data/api_resources_ingress_openshift.json | 2 +- 7 files changed, 8 insertions(+), 6 deletions(-) diff --git a/deployment_report/templates/viya_deployment_report.html.j2 b/deployment_report/templates/viya_deployment_report.html.j2 index 95f08fb..82e1e9b 100644 --- a/deployment_report/templates/viya_deployment_report.html.j2 +++ b/deployment_report/templates/viya_deployment_report.html.j2 @@ -202,12 +202,14 @@ SAS Custom Resource {% for discovered_type, type_details in report_data.kubernetes.discoveredResourceTypes.items() %} + {% if type_details.kind | lower != "none" %} {{ type_details.kind }} {{ discovered_type }} {{ type_details.count }} {{ type_details.sasCRD }} + {% endif %} {% endfor %} diff --git a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_all.json b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_all.json index 2e87798..be772d7 100644 --- a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_all.json +++ b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_all.json @@ -93,7 +93,7 @@ "group": "", "kind": "Node", "name": "nodes", - "namespaced": true, + "namespaced": false, "shortname": "no", "verbs": [ "create", diff --git a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_contour.json b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_contour.json index 97c5f18..3c3f7ad 100644 --- a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_contour.json +++ b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_contour.json @@ -93,7 +93,7 @@ "group": "", "kind": "Node", "name": "nodes", - "namespaced": true, + "namespaced": false, "shortname": "no", "verbs": [ "create", diff --git a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_istio.json b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_istio.json index c1d3993..f04f11b 100644 --- a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_istio.json +++ b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_istio.json @@ -93,7 +93,7 @@ "group": "", "kind": "Node", "name": "nodes", - "namespaced": true, + "namespaced": false, "shortname": "no", "verbs": [ "create", diff --git a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_nginx.json b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_nginx.json index e199c1b..29028ac 100644 --- a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_nginx.json +++ b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_nginx.json @@ -93,7 +93,7 @@ "group": "", "kind": "Node", "name": "nodes", - "namespaced": true, + "namespaced": false, "shortname": "no", "verbs": [ "create", diff --git a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_none.json b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_none.json index 4faba50..1e6a3bd 100644 --- a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_none.json +++ b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_none.json @@ -93,7 +93,7 @@ "group": "", "kind": "Node", "name": "nodes", - "namespaced": true, + "namespaced": false, "shortname": "no", "verbs": [ "create", diff --git a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_openshift.json b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_openshift.json index 619772d..d769f1d 100644 --- a/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_openshift.json +++ b/viya_ark_library/k8s/test_impl/response_data/api_resources_ingress_openshift.json @@ -93,7 +93,7 @@ "group": "", "kind": "Node", "name": "nodes", - "namespaced": true, + "namespaced": false, "shortname": "no", "verbs": [ "create", From 867c49c06ff069a81a3edc4e9cfb05dcc598a3fa Mon Sep 17 00:00:00 2001 From: Latha Sivakumar Date: Tue, 26 Oct 2021 13:55:46 -0400 Subject: [PATCH 07/11] (issue #150)QA Fixes --- pre_install_report/README.md | 14 +++++++----- .../library/pre_install_check_permissions.py | 22 ++++++++++++------- .../library/utils/viya_constants.py | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/pre_install_report/README.md b/pre_install_report/README.md index 3967b96..b85c07e 100644 --- a/pre_install_report/README.md +++ b/pre_install_report/README.md @@ -35,9 +35,9 @@ VIYA_MIN_AGGREGATE_WORKER_CPU_CORES=56 If calculated aggregate memory is less than a percentage (85%) of VIYA_MIN_AGGREGATE_WORKER_MEMORY then the tool will flag a memory issue. If calculated aggregate vCPUs is less than VIYA_MIN_AGGREGATE_WORKER_CPU_CORES then it the tool will flag a CPU issue. -SAS recommends using the SAS Viya 4 Infrastructure as Code (IaC) tools to create a cluster for [Microsoft Azure](https://github.com/sassoftware/viya4-iac-azure), -[AWS](https://github.com/sassoftware/viya4-iac-aws]), or [GCP](https://github.com/sassoftware/viya4-iac-gcp) - +SAS recommends using the SAS Viya 4 Infrastructure as Code (IaC) tools to create a cluster. +Refer to the following IaC repositories for [Microsoft Azure](https://github.com/sassoftware/viya4-iac-azure), [AWS](https://github.com/sassoftware/viya4-iac-aws]) or [GCP](https://github.com/sassoftware/viya4-iac-gcp). +For OpenShift refer to the documentation in SAS® Viya® Operations [OpenShift](https://go.documentation.sas.com/doc/en/itopscdc/v_019/itopssr/n1ika6zxghgsoqn1mq4bck9dx695.htm#p1c8bxlbu0gzuvn1e75nck1yozcn) **Example**: Setting for aggregate Memory and vCPU for deployment based on documentation in SAS Viya Operations under System Requirements in the Hardware and Resource Requirements section. See Sizing Recommendations for Microsoft Azure. @@ -71,9 +71,11 @@ Download the latest version of this tool and update required packages with every ## Usage -**Note:** You must set your `KUBECONFIG` environment variable. `KUBECONFIG` must have administrator rights in the -namespace where you intend to deploy your SAS Viya software. -To obtain a complete report use a `KUBECONFIG` with administrator rights in the cluster. +**Note:** You must set your `KUBECONFIG` environment variable. `KUBECONFIG` must have administrator rights to the +cluster where you intend to deploy your SAS Viya software. +To obtain a complete report use a `KUBECONFIG` with administrator rights in the cluster. Otherwise, the report will +not be able to evaluate items such as memory, CPU cores, software versions and other node details. It is not useful +for determining if you are ready to deploy your SAS Viya software. Create the namespace where you plan to deploy SAS Viya. You must specify the namespace when you run the tool. diff --git a/pre_install_report/library/pre_install_check_permissions.py b/pre_install_report/library/pre_install_check_permissions.py index 9241bad..a687dc6 100644 --- a/pre_install_report/library/pre_install_check_permissions.py +++ b/pre_install_report/library/pre_install_check_permissions.py @@ -424,7 +424,11 @@ def get_openshift_route_details(self): """ self._route_k8s_resource: KubernetesResource = self.utils.get_resource(OPS_ROUTE_KIND, OPS_ROUTE_NAME) - self.logger.info("route json{}".format(pprint.pformat(self._route_k8s_resource.as_dict()))) + + if self._route_k8s_resource is not None: + self.logger.info("route json{}".format(pprint.pformat(self._route_k8s_resource.as_dict()))) + else: + self.logger.info("route is {}".format(pprint.pformat(str(type(self._route_k8s_resource))))) def check_delete_openshift_route(self): """ @@ -464,14 +468,16 @@ def check_openshift_route_host_port(self): action: issue kubectl command to get host/port value in route """ - ingress = self._route_k8s_resource.get_status_value("ingress") + if self._route_k8s_resource is not None: + + ingress = self._route_k8s_resource.get_status_value("ingress") - for dic in ingress: - for ingress_key, val in dic.items(): - # print(f'{ingress_key} is {val}') - if ingress_key == OPS_ROUTE_KEY: - self._openshift_host_port = val - self.logger.info("host_port {}".format(pprint.pformat(self._openshift_host_port))) + for dic in ingress: + for ingress_key, val in dic.items(): + # print(f'{ingress_key} is {val}') + if ingress_key == OPS_ROUTE_KEY: + self._openshift_host_port = val + self.logger.info("host_port {}".format(pprint.pformat(self._openshift_host_port))) if self._openshift_host_port == viya_constants.NO_HOST_FOUND: self.logger.error("host_port {}".format(pprint.pformat(self._openshift_host_port))) diff --git a/pre_install_report/library/utils/viya_constants.py b/pre_install_report/library/utils/viya_constants.py index ce0f54b..63d82eb 100644 --- a/pre_install_report/library/utils/viya_constants.py +++ b/pre_install_report/library/utils/viya_constants.py @@ -34,7 +34,7 @@ PERM_PERMISSIONS = "Permissions" PERM_DEPLOYMENT = "Deployment" PERM_SERVICE = "Service" -PERM_ROUTER = "Openshift Router" +PERM_ROUTER = "Openshift Route" PERM_AZ_FILE = "AzureFile Storage RWX" PERM_AZ_FILE_PR = "AzureFilePremium Storage RWX" PERM_AZ_DISK = "AzureDisk Storage" From 83ebcbd62c2bdaba474eac8aa7b625d96b26f52b Mon Sep 17 00:00:00 2001 From: Latha Sivakumar Date: Tue, 26 Oct 2021 15:48:02 -0400 Subject: [PATCH 08/11] (issue #150)QA Fixes --- pre_install_report/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_install_report/README.md b/pre_install_report/README.md index b85c07e..f536aa3 100644 --- a/pre_install_report/README.md +++ b/pre_install_report/README.md @@ -136,7 +136,7 @@ python3 viya-ark.py pre-install-report -i nginx -H $INGRESS_HOST -p $INGRESS_HT ## Report Output -The tool generates the pre-install check report,`viya_pre_install_report_.html. The report is in a +The tool generates the pre-install check report, viya_pre_install_report_.html. The report is in a web-viewable, HTML format. ## Modify CPU, Memory, and Version Settings From ad2703a6d9fa55905f2b1f6bf272e315c3122425 Mon Sep 17 00:00:00 2001 From: Latha Sivakumar Date: Wed, 27 Oct 2021 16:07:57 -0400 Subject: [PATCH 09/11] (issue #150)QA Fixes --- pre_install_report/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_install_report/README.md b/pre_install_report/README.md index f536aa3..a3de762 100644 --- a/pre_install_report/README.md +++ b/pre_install_report/README.md @@ -77,7 +77,7 @@ To obtain a complete report use a `KUBECONFIG` with administrator rights in the not be able to evaluate items such as memory, CPU cores, software versions and other node details. It is not useful for determining if you are ready to deploy your SAS Viya software. -Create the namespace where you plan to deploy SAS Viya. You must specify the namespace when you run the tool. +Create the namespace where you plan to deploy SAS Viya. You can specify the namespace option when you run the tool. If a namespace is not provided, the tool will check the current context for a namespace. A namespace must be available when the tools runs. After obtaining the latest version of this tool, cd to `/viya4-ark`. From ad6a608c27199478a30c532c29274efdfa8dddf9 Mon Sep 17 00:00:00 2001 From: Latha Sivakumar Date: Wed, 27 Oct 2021 17:21:45 -0400 Subject: [PATCH 10/11] (issue #150)QA Fixes --- pre_install_report/README.md | 2 +- .../templates/report_template_viya_pre_install_check.j2 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pre_install_report/README.md b/pre_install_report/README.md index a3de762..4fd315f 100644 --- a/pre_install_report/README.md +++ b/pre_install_report/README.md @@ -77,7 +77,7 @@ To obtain a complete report use a `KUBECONFIG` with administrator rights in the not be able to evaluate items such as memory, CPU cores, software versions and other node details. It is not useful for determining if you are ready to deploy your SAS Viya software. -Create the namespace where you plan to deploy SAS Viya. You can specify the namespace option when you run the tool. If a namespace is not provided, the tool will check the current context for a namespace. A namespace must be available when the tools runs. +Create the namespace where you plan to deploy SAS Viya. A namespace is required to run this tool. Specify the namespace where you plan to deploy SAS Viya using the namespace option. If a namespace is not provided, the tool will check the current context for a namespace. Ensure that you are running with the correct namespace. After obtaining the latest version of this tool, cd to `/viya4-ark`. diff --git a/pre_install_report/templates/report_template_viya_pre_install_check.j2 b/pre_install_report/templates/report_template_viya_pre_install_check.j2 index ffbacfd..ddf520c 100644 --- a/pre_install_report/templates/report_template_viya_pre_install_check.j2 +++ b/pre_install_report/templates/report_template_viya_pre_install_check.j2 @@ -154,8 +154,8 @@ -

** SAS recommends using the IaC tools to create the cluster. See SAS Viya 4 Infrastructure as Code (IaC) project for Microsoft Azure, AWS, and GCP -

** Also refer to SAS Viya Documentation for Sizing Recommendations for Microsoft Azure, AWS and GCP

+

** SAS recommends using the IaC tools to create the cluster. See SAS Viya 4 Infrastructure as Code (IaC) project for Microsoft Azure, AWS, and GCP. Refer to SAS Viya Documentation for OpenShift +

** Also refer to SAS Viya Documentation for Sizing Recommendations for Microsoft Azure, AWS, GCP and OpenShift

From 134b32f5624157fb26122d79eb222c8fb87bb355 Mon Sep 17 00:00:00 2001 From: Latha Sivakumar Date: Wed, 27 Oct 2021 17:24:40 -0400 Subject: [PATCH 11/11] (issue #150)QA Fixes --- .../templates/report_template_viya_pre_install_check.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_install_report/templates/report_template_viya_pre_install_check.j2 b/pre_install_report/templates/report_template_viya_pre_install_check.j2 index ddf520c..0645df1 100644 --- a/pre_install_report/templates/report_template_viya_pre_install_check.j2 +++ b/pre_install_report/templates/report_template_viya_pre_install_check.j2 @@ -154,7 +154,7 @@ -

** SAS recommends using the IaC tools to create the cluster. See SAS Viya 4 Infrastructure as Code (IaC) project for Microsoft Azure, AWS, and GCP. Refer to SAS Viya Documentation for OpenShift +

** SAS recommends using the IaC tools to create the cluster. See SAS Viya 4 Infrastructure as Code (IaC) project for Microsoft Azure, AWS, and GCP. Refer to SAS Viya Documentation for OpenShift.

** Also refer to SAS Viya Documentation for Sizing Recommendations for Microsoft Azure, AWS, GCP and OpenShift