add k8s_dashboard_access part_6 setup done
setup steps for the dashboard are done: -setup files are copied to lab -the yaml files are applied and the HTTPS certificate is created for the dashboard URL -URL is working and it's reachable Change-Id: Id249786c31d46348c2160ec8d627bb22320aa9cf Signed-off-by: Gabriel Calixto de Paula <gabrielcalixto9@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
{
|
||||
// KUBECONFIG environment variable on the cloud_platform system.
|
||||
"kubeconfig": "/etc/kubernetes/admin.conf",
|
||||
"dashboard_port": "8443"
|
||||
}
|
@@ -15,10 +15,17 @@ class K8sConfig:
|
||||
raise
|
||||
|
||||
k8s_dict = json5.load(json_data)
|
||||
self.kubeconfig = k8s_dict['kubeconfig']
|
||||
self.kubeconfig = k8s_dict["kubeconfig"]
|
||||
self.dashboard_port = k8s_dict["dashboard_port"]
|
||||
|
||||
def get_kubeconfig(self) -> str:
|
||||
"""
|
||||
Getter for the KUBECONFIG environment variable on the lab where we want to run.
|
||||
"""
|
||||
return self.kubeconfig
|
||||
|
||||
def get_dashboard_port(self) -> str:
|
||||
"""
|
||||
Getter for the port on which the K8s dashboard is running.
|
||||
"""
|
||||
return self.dashboard_port
|
||||
|
@@ -1,3 +1,4 @@
|
||||
from config.configuration_manager import ConfigurationManager
|
||||
from framework.ssh.ssh_connection import SSHConnection
|
||||
from keywords.base_keyword import BaseKeyword
|
||||
from keywords.cloud_platform.command_wrappers import source_openrc
|
||||
@@ -15,11 +16,21 @@ class OpenStackEndpointListKeywords(BaseKeyword):
|
||||
def endpoint_list(self):
|
||||
"""
|
||||
Keyword for openstack endpoint list
|
||||
Returns:
|
||||
|
||||
Returns:
|
||||
OpenStackEndpointListOutput object
|
||||
"""
|
||||
output = self.ssh_connection.send(source_openrc('openstack endpoint list'))
|
||||
output = self.ssh_connection.send(source_openrc("openstack endpoint list"))
|
||||
self.validate_success_return_code(self.ssh_connection)
|
||||
openstack_endpoint_list_output = OpenStackEndpointListOutput(output)
|
||||
|
||||
return openstack_endpoint_list_output
|
||||
|
||||
def get_k8s_dashboard_url(self) -> str:
|
||||
"""
|
||||
Getter for the URL of the K8s dashboard.
|
||||
"""
|
||||
endpoint_output = self.endpoint_list()
|
||||
url = endpoint_output.get_endpoint("keystone", "public").get_url().rsplit(":", 1)[0]
|
||||
end_point = f"{url}:{ConfigurationManager.get_k8s_config().get_dashboard_port()}"
|
||||
return end_point
|
||||
|
@@ -1,3 +1,5 @@
|
||||
from framework.logging.automation_logger import get_logger
|
||||
from framework.ssh.ssh_connection import SSHConnection
|
||||
from keywords.base_keyword import BaseKeyword
|
||||
from keywords.k8s.k8s_command_wrapper import export_k8s_config
|
||||
|
||||
@@ -7,24 +9,44 @@ class KubectlDeleteSecretsKeywords(BaseKeyword):
|
||||
Keywords for delete secrets
|
||||
"""
|
||||
|
||||
def __init__(self, ssh_connection):
|
||||
def __init__(self, ssh_connection: SSHConnection):
|
||||
"""
|
||||
Constructor
|
||||
|
||||
Args:
|
||||
ssh_connection:
|
||||
ssh_connection (SSHConnection): The SSH connection object
|
||||
"""
|
||||
self.ssh_connection = ssh_connection
|
||||
|
||||
def delete_secret(self, secret_name: str, namespace: str) -> str:
|
||||
"""
|
||||
Deletes the secret
|
||||
Deletes the specified Kubernetes secret in the given namespace.
|
||||
|
||||
Args:
|
||||
secret_name (): the secret
|
||||
|
||||
Returns: the output
|
||||
secret_name (str): The name of the secret to delete.
|
||||
namespace (str): The namespace where the secret is located.
|
||||
|
||||
Returns:
|
||||
str: The output from the kubectl delete command.
|
||||
"""
|
||||
output = self.ssh_connection.send(export_k8s_config(f"kubectl delete -n {namespace} secret {secret_name}"))
|
||||
self.validate_success_return_code(self.ssh_connection)
|
||||
|
||||
return output
|
||||
|
||||
def cleanup_secret(self, secret_name: str, namespace: str) -> str:
|
||||
"""
|
||||
This method is intended for use in cleanup operations as it doesn't automatically fail the test.
|
||||
|
||||
Args:
|
||||
secret_name (str): The name of the secret to delete.
|
||||
namespace (str): The namespace where the secret is located.
|
||||
|
||||
Returns:
|
||||
str: The output of the delete operation.
|
||||
"""
|
||||
self.ssh_connection.send(export_k8s_config(f"kubectl delete -n {namespace} secret {secret_name}"))
|
||||
rc = self.ssh_connection.get_return_code()
|
||||
if rc != 0:
|
||||
get_logger().log_error(f"Secret {secret_name} failed to delete")
|
||||
return rc
|
||||
|
@@ -9,26 +9,17 @@ from framework.logging.automation_logger import get_logger
|
||||
from framework.resources.resource_finder import get_stx_resource_path
|
||||
from framework.rest.rest_client import RestClient
|
||||
from framework.ssh.ssh_connection import SSHConnection
|
||||
from keywords.cloud_platform.openstack.endpoint.openstack_endpoint_list_keywords import OpenStackEndpointListKeywords
|
||||
from keywords.cloud_platform.ssh.lab_connection_keywords import LabConnectionKeywords
|
||||
from keywords.files.file_keywords import FileKeywords
|
||||
from keywords.k8s.files.kubectl_file_apply_keywords import KubectlFileApplyKeywords
|
||||
from keywords.k8s.files.kubectl_file_delete_keywords import KubectlFileDeleteKeywords
|
||||
from keywords.k8s.namespace.kubectl_create_namespace_keywords import (
|
||||
KubectlCreateNamespacesKeywords,
|
||||
)
|
||||
from keywords.k8s.namespace.kubectl_delete_namespace_keywords import (
|
||||
KubectlDeleteNamespaceKeywords,
|
||||
)
|
||||
from keywords.k8s.namespace.kubectl_get_namespaces_keywords import (
|
||||
KubectlGetNamespacesKeywords,
|
||||
)
|
||||
from keywords.k8s.namespace.kubectl_create_namespace_keywords import KubectlCreateNamespacesKeywords
|
||||
from keywords.k8s.namespace.kubectl_delete_namespace_keywords import KubectlDeleteNamespaceKeywords
|
||||
from keywords.k8s.namespace.kubectl_get_namespaces_keywords import KubectlGetNamespacesKeywords
|
||||
from keywords.k8s.patch.kubectl_apply_patch_keywords import KubectlApplyPatchKeywords
|
||||
from keywords.k8s.secret.kubectl_create_secret_keywords import (
|
||||
KubectlCreateSecretsKeywords,
|
||||
)
|
||||
from keywords.k8s.secret.kubectl_delete_secret_keywords import (
|
||||
KubectlDeleteSecretsKeywords,
|
||||
)
|
||||
from keywords.k8s.secret.kubectl_create_secret_keywords import KubectlCreateSecretsKeywords
|
||||
from keywords.k8s.secret.kubectl_delete_secret_keywords import KubectlDeleteSecretsKeywords
|
||||
from keywords.openssl.openssl_keywords import OpenSSLKeywords
|
||||
|
||||
|
||||
@@ -105,7 +96,7 @@ def create_k8s_dashboard(request: fixture, namespace: str, con_ssh: SSHConnectio
|
||||
def teardown():
|
||||
KubectlFileDeleteKeywords(ssh_connection=con_ssh).delete_resources(k8s_dashboard_file_path)
|
||||
# delete created dashboard secret
|
||||
KubectlDeleteSecretsKeywords(con_ssh).delete_secret(namespace=namespace, secret_name=secrets_name)
|
||||
KubectlDeleteSecretsKeywords(con_ssh).cleanup_secret(namespace=namespace, secret_name=secrets_name)
|
||||
get_logger().log_info("Deleting k8s_dashboard directory")
|
||||
con_ssh.send(f"rm -rf {home_k8s}")
|
||||
|
||||
@@ -118,8 +109,7 @@ def create_k8s_dashboard(request: fixture, namespace: str, con_ssh: SSHConnectio
|
||||
time.sleep(30)
|
||||
|
||||
get_logger().log_info(f"Verify that {name} is working")
|
||||
end_point = "https://{}:{}".format(sys_domain_name, port)
|
||||
|
||||
end_point = OpenStackEndpointListKeywords(ssh_connection=con_ssh).get_k8s_dashboard_url()
|
||||
status_code, _ = check_url_access(end_point)
|
||||
if not status_code == 200:
|
||||
raise KeywordException(detailed_message=f"Kubernetes dashboard returned status code {status_code}")
|
||||
|
Reference in New Issue
Block a user