Skip to content

Commit

Permalink
feat: remove hello-world service (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasiva committed Jun 30, 2023
1 parent 0ef3d5f commit d7b8c1f
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 117 deletions.
4 changes: 0 additions & 4 deletions pre_install_report/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ 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_.
Other ingress controllers are not evaluated. Select _openshift_ if you are deploying on Red Hat OpenShift.

## Report Output

The tool generates the pre-install check report, viya_pre_install_report_<timestamp>.html. The report is in a
Expand Down
7 changes: 0 additions & 7 deletions pre_install_report/library/pre_install_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def __init__(self, sas_logger: ViyaARKLogger, viya_k8s_version_min,
self._calculated_aggregate_memory = None
self._workers = 0
self._aggregate_nodeStatus_failures = 0
self._ingress_controller = None
self._k8s_server_version = None

def _parse_release_info(self, release_info):
Expand Down Expand Up @@ -161,9 +160,7 @@ def _k8s_server_version_min(self):
sys.exit(viya_messages.RUNTIME_ERROR_RC_)

def check_details(self, kubectl,
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))
Expand Down Expand Up @@ -198,7 +195,6 @@ def check_details(self, kubectl,
global_data = self.evaluate_nodes(nodes_data, global_data, cluster_info, quantity_)

params = {}
params[viya_constants.INGRESS_CONTROLLER] = ingress_controller
params[viya_constants.PERM_CLASS] = utils
params[viya_constants.SERVER_K8S_VERSION] = self._k8s_server_version
params['logger'] = self.sas_logger
Expand All @@ -223,7 +219,6 @@ def check_details(self, kubectl,
self.generate_report(global_data, master_data, configs_data, storage_data, namespace_data,
permissions_check.get_cluster_admin_permission_data(),
permissions_check.get_namespace_admin_permission_data(),
permissions_check.get_ingress_data(),
permissions_check.get_namespace_admin_permission_aggregate(),
permissions_check.get_cluster_admin_permission_aggregate(),
output_dir)
Expand Down Expand Up @@ -1066,7 +1061,6 @@ def generate_report(self,
namespace_data,
cluster_admin_permission_data,
namespace_admin_permission_data,
ingress_data,
ns_admin_permission_aggregate,
cluster_admin_permission_aggregate,
output_directory=""):
Expand All @@ -1093,7 +1087,6 @@ def generate_report(self,
namespace_data=namespace_data,
cluster_admin_permission_data=cluster_admin_permission_data.items(),
namespace_admin_permission_data=namespace_admin_permission_data.items(),
ingress_data=ingress_data.items(),
namespace_admin_permission_aggregate=ns_admin_permission_aggregate['Permissions'],
cluster_admin_permission_aggregate=cluster_admin_permission_aggregate['Permissions'],
cluster_creation_info=viya_messages.CLUSTER_CREATION_INFO,
Expand Down
37 changes: 1 addition & 36 deletions pre_install_report/library/pre_install_check_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ def __init__(self, params):

# the constructor initializes the following variables in the constructor #
# variables are not used outside of the constructor #
self.ingress_controller = params.get(viya_constants.INGRESS_CONTROLLER)

self.utils: PreCheckUtils = params.get(viya_constants.PERM_CLASS)
self.sas_logger: ViyaARKLogger = params.get("logger")
self.logger = self.sas_logger.get_logger()
Expand All @@ -68,11 +66,9 @@ def __init__(self, params):
self.cluster_admin_permission_aggregate = {}
self.namespace_admin_permission_aggregate[viya_constants.PERM_PERMISSIONS] = viya_constants.ADEQUATE_PERMS
self.cluster_admin_permission_aggregate[viya_constants.PERM_PERMISSIONS] = viya_constants.ADEQUATE_PERMS
self.ingress_data = {}
self.ingress_data[viya_constants.INGRESS_CONTROLLER] = self.ingress_controller

self._storage_class_sc: List[KubernetesResource] = None
self._k8s_git_version = params.get(viya_constants.SERVER_K8S_VERSION)
self._route_k8s_resource: KubernetesResource = None

def _set_results_cluster_admin(self, resource_key, rc):
"""
Expand Down Expand Up @@ -315,20 +311,6 @@ def _set_results_namespace_admin_crd(self, resource_key, rc):
else:
self.namespace_admin_permission_data[resource_key] = viya_constants.ADEQUATE_PERMS

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_ingress_controller(self):
"""
Get the current ingress_controller
"""
return str(self.ingress_controller)

def check_create_custom_resource(self):
"""
Create the custome resource in specified namespace. Set the
Expand All @@ -339,8 +321,6 @@ def check_create_custom_resource(self):
'crviya.yaml')
self._set_results_namespace_admin_crd(viya_constants.PERM_CREATE + viya_constants.PERM_CR, rc)

# TBD test_cmd = "kubectl get customresourcedefinition viyas.company.com -o name"

def check_deploy_crd(self):
"""
Deploy the namespaced Custom Resource definition. Set the
Expand Down Expand Up @@ -447,14 +427,6 @@ def get_namespace_admin_permission_data(self):
"""
return self.namespace_admin_permission_data

def get_ingress_data(self):
"""
Return ingress data
return: dict object with ingress data
"""
return self.ingress_data

def get_namespace_admin_permission_aggregate(self):
"""
Return namespace_admin_permission_aggregate
Expand Down Expand Up @@ -483,10 +455,3 @@ def get_k8s_git_version(self):
return: string object
"""
return self._k8s_git_version

def get_ingress_file_name(self):
"""
Get the ingress manifest to be deployed
return: string object
"""
return self._ingress_file
10 changes: 1 addition & 9 deletions pre_install_report/library/utils/viya_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
DISK_PRESSURE = 'False'
MEMORY_PRESSURE = 'False'
PID_PRESSURE = 'False'
# WORKER_MEMORY = '32779828Ki'
OS_IMAGE = 'CentOS Linux 7 (Core)'
NUMBER_OF_MASTER_NODES = 1
NUMBER_OF_WORKER_NODES = 1
Expand All @@ -23,13 +22,7 @@
KEY_NOT_FOUND = 'Not Found'
INSUFFICIENT_PERMS = "Insufficient"
ADEQUATE_PERMS = "Adequate"
INGRESS_NGINX = "nginx"
INGRESS_ISTIO = "istio"
OPENSHIFT_INGRESS = "openshift"
NO_HOST_FOUND = "No_host_found"
INGRESS_CONTROLLER = "ingress_controller"
INGRESS_HOST = "ingress_host"
INGRESS_PORT = "ingress_port"

KUBECTL = "kubectl "
PERM_PERMISSIONS = "Permissions"
PERM_DEPLOYMENT = "Deployment"
Expand All @@ -40,7 +33,6 @@
PERM_AZ_DISK = "AzureDisk Storage"
PERM_AZ_DISK_STANDARD = "AzureDisk Standard Storage"
PERM_AWS_EBS = "AWS EBS Storage"
PERM_INGRESS = "Ingress"
PERM_CRD = "Custom Resource Definition"
PERM_CR = "Custom Resource"
PERM_STORAGE_CLASS = "Storage Class"
Expand Down
2 changes: 0 additions & 2 deletions pre_install_report/library/utils/viya_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
KUBELET_VERSION_ERROR = 'ERROR: Check the VIYA_K8S_VERSION_MIN value ' \
'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 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. " \
Expand Down
24 changes: 3 additions & 21 deletions pre_install_report/pre_install_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import getopt
import configparser

from pre_install_report.library.utils import viya_constants
from pre_install_report.library.utils import viya_messages
from pre_install_report.library.pre_install_check import ViyaPreInstallCheck
from viya_ark_library.command import Command
Expand Down Expand Up @@ -133,11 +132,9 @@ 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> [<options>]")
print("Usage: viya-ark.py pre_install_report [<options>]")
print()
print("Options:")
print(" -i --ingress (Required)Kubernetes ingress controller: "
"{} or {}".format(viya_constants.INGRESS_NGINX, viya_constants.OPENSHIFT_INGRESS))
print(" -h --help (Optional)Show this usage message")
print(" -n --namespace (Optional)Kubernetes namespace used for Viya deployment")
print(" -o, --output-dir=\"<dir>\" (Optional)Write the report and log files to the provided directory")
Expand All @@ -159,12 +156,11 @@ def main(argv):
"""
try:
opts, args = getopt.getopt(argv, "i:H:p:hn:o:d",
["ingress=", "help", "namespace=", "output-dir=", "debug"])
["help", "namespace=", "output-dir=", "debug"])
except getopt.GetoptError as opt_error:
print(viya_messages.EXCEPTION_MESSAGE.format(opt_error))
usage(viya_messages.BAD_OPT_RC_)

found_ingress_controller: bool = False
output_dir: Optional[Text] = ""
name_space: Optional[Text] = None
logging_level: int = logging.INFO
Expand All @@ -176,9 +172,6 @@ def main(argv):
logging_level = logging.DEBUG
elif opt in ('-n', '--namespace'):
name_space = arg
elif opt in ('-i', '--ingress'):
ingress_controller = arg
found_ingress_controller = True

elif opt in ('-o', '--output-dir'):
output_dir = arg
Expand Down Expand Up @@ -207,17 +200,6 @@ def main(argv):
logger = sas_logger.get_logger()
read_environment_var('KUBECONFIG')

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) 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_)

try:
kubectl = Kubectl(namespace=name_space)
except ConnectionError as e:
Expand Down Expand Up @@ -252,7 +234,7 @@ def main(argv):
try:
print()
sas_pre_check_report.check_details(kubectl,
ingress_controller, output_dir)
output_dir)
except RuntimeError as e:
print()
print(viya_messages.EXCEPTION_MESSAGE.format(e))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,31 +327,6 @@

<!-- Storage Class Check End -->

<!-- Ingress Setting -->

<div class="jq-accordion">
<h2>Ingress Controller </h2>
<div>

{% for key, value in ingress_data %}
<table class="mytable">
<TR>
<TH> Ingress Controller </TH>
</TR>
<TR>
<TD> {{value}}</TD>
</TR>
</table>
<style>
.mytable td, .mytable th { width:30%; }
.mytable td + td, .mytable th + th { width:70%; }
</style>
{% endfor %}
</div>
</div>
<!-- Ingress Setting End -->


<!-- Cluster Admin Permissions -->
<div class="jq-accordion">
<h2>Cluster Admin Permissions - {{ cluster_admin_permission_aggregate}} </h2>
Expand Down
15 changes: 2 additions & 13 deletions pre_install_report/test/test_pre_install_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,16 +616,13 @@ def test_get_k8s_version():
version_string2 = "1.19.0"

params = {}
params[viya_constants.INGRESS_CONTROLLER] = 'nginx'
params[viya_constants.INGRESS_HOST] = '10.240.9.8'
params[viya_constants.INGRESS_PORT] = '80'
params['logger'] = sas_logger

# initialize the PreCheckPermissions object
perms = PreCheckPermissions(params)
perms.set_k8s_git_version(version_string)

# check curren version less than 1.20
# check current version less than 1.20
curr_version = semantic_version.Version(str(version_string2))
assert (curr_version in semantic_version.SimpleSpec('<1.20'))
assert (curr_version in semantic_version.SimpleSpec('==1.19'))
Expand All @@ -639,9 +636,6 @@ def test_get_k8s_version():
def test_check_permissions():
# namespace = 'default'
params = {}
params[viya_constants.INGRESS_CONTROLLER] = 'nginx'
params[viya_constants.INGRESS_HOST] = '10.240.9.8'
params[viya_constants.INGRESS_PORT] = '80'
params['logger'] = sas_logger

# initialize the PreCheckPermissions object
Expand All @@ -650,23 +644,18 @@ def test_check_permissions():
assert len(cluster_permission_data) == 0
namespace_admin_permission_data = perms.get_namespace_admin_permission_data()
assert len(namespace_admin_permission_data) == 0
ingress_data = perms.get_ingress_data()
assert ingress_data[viya_constants.INGRESS_CONTROLLER] in 'nginx'

namespace_admin_permission_aggregate = perms.get_namespace_admin_permission_aggregate()
assert namespace_admin_permission_aggregate[viya_constants.PERM_PERMISSIONS] in viya_constants.ADEQUATE_PERMS
cluster_admin_permission_aggregate = perms.get_cluster_admin_permission_aggregate()
assert cluster_admin_permission_aggregate[viya_constants.PERM_PERMISSIONS] in viya_constants.ADEQUATE_PERMS

# Pytest not implemented currently. Scaffolding TBD. Currently requires live cluster
# perms.check_sample_application(namespace, debug)
# perms.check_sample_ingress(namespace, debug)
# perms.check_deploy_crd(namespace, debug)
# perms.check_rbac_role(namespace, debug)
# perms.check_create_custom_resource(namespace, debug)
# perms.check_get_custom_resource(namespace, debug)
# perms.check_delete_custom_resource(namespace, debug)
# perms.check_rbac_delete_role(namespace, debug)
# perms.check_sample_response(debug)
# perms.check_delete_crd(namespace, debug)
# perms.check_delete_sample_application(namespace, debug)
# perms.check_delete_sample_ingress(namespace, debug)

0 comments on commit d7b8c1f

Please sign in to comment.