diff --git a/deployment_report/model/static/viya_deployment_report_keys.py b/deployment_report/model/static/viya_deployment_report_keys.py
index 17a9388..af24efb 100644
--- a/deployment_report/model/static/viya_deployment_report_keys.py
+++ b/deployment_report/model/static/viya_deployment_report_keys.py
@@ -45,11 +45,13 @@ class Kubernetes(object):
API_RESOURCES_DICT = "apiResources"
API_VERSIONS_LIST = "apiVersions"
CADENCE_INFO = "cadenceInfo"
+ CONFIGMAPS_DICT = "configMaps"
DB_INFO = "dbInfo"
DISCOVERED_RESOURCE_TYPES_DICT = "discoveredResourceTypes"
INGRESS_CTRL = "ingressController"
NAMESPACE = "namespace"
NODES_DICT = "nodes"
+ SECRETS_DICT = "secrets"
VERSIONS_DICT = "versions"
class ResourceDetails(object):
diff --git a/deployment_report/model/test/test_viya_deployment_report.py b/deployment_report/model/test/test_viya_deployment_report.py
index a6f0396..ac973f4 100644
--- a/deployment_report/model/test/test_viya_deployment_report.py
+++ b/deployment_report/model/test/test_viya_deployment_report.py
@@ -89,15 +89,17 @@ def test_get_kubernetes_details(report: ViyaDeploymentReport) -> None:
kube_details: Dict = report.get_kubernetes_details()
# check for all expected entries
- assert len(kube_details) == 9
+ assert len(kube_details) == 11
assert ReportKeys.Kubernetes.API_RESOURCES_DICT in kube_details
assert ReportKeys.Kubernetes.API_VERSIONS_LIST in kube_details
assert ReportKeys.Kubernetes.CADENCE_INFO in kube_details
+ assert ReportKeys.Kubernetes.CONFIGMAPS_DICT in kube_details
assert ReportKeys.Kubernetes.DB_INFO in kube_details
assert ReportKeys.Kubernetes.DISCOVERED_RESOURCE_TYPES_DICT in kube_details
assert ReportKeys.Kubernetes.INGRESS_CTRL in kube_details
assert ReportKeys.Kubernetes.NAMESPACE in kube_details
assert ReportKeys.Kubernetes.NODES_DICT in kube_details
+ assert ReportKeys.Kubernetes.SECRETS_DICT in kube_details
assert ReportKeys.Kubernetes.VERSIONS_DICT in kube_details
@@ -121,7 +123,7 @@ def test_get_api_resources() -> None:
api_resources: Dict = report.get_api_resources()
# check for expected attributes
- assert len(api_resources) == 17
+ assert len(api_resources) == 18
assert ResourceTypeValues.CONTOUR_HTTP_PROXIES in api_resources
assert ResourceTypeValues.ISTIO_VIRTUAL_SERVICES
@@ -133,6 +135,7 @@ def test_get_api_resources() -> None:
assert ResourceTypeValues.K8S_CORE_CONFIG_MAPS in api_resources
assert ResourceTypeValues.K8S_CORE_NODES in api_resources
assert ResourceTypeValues.K8S_CORE_PODS in api_resources
+ assert ResourceTypeValues.K8S_CORE_SECRETS in api_resources
assert ResourceTypeValues.K8S_CORE_SERVICES in api_resources
assert ResourceTypeValues.K8S_EXTENSIONS_INGRESSES in api_resources
assert ResourceTypeValues.K8S_METRICS_NODES in api_resources
@@ -192,7 +195,7 @@ def test_get_discovered_resources(report: ViyaDeploymentReport) -> None:
discovered_resources: Dict = report.get_discovered_resources()
# check for expected attributes
- assert len(discovered_resources) == 15
+ assert len(discovered_resources) == 16
assert ResourceTypeValues.CONTOUR_HTTP_PROXIES in discovered_resources
assert ResourceTypeValues.ISTIO_VIRTUAL_SERVICES in discovered_resources
assert ResourceTypeValues.K8S_APPS_DEPLOYMENTS in discovered_resources
@@ -203,6 +206,7 @@ def test_get_discovered_resources(report: ViyaDeploymentReport) -> None:
assert ResourceTypeValues.K8S_CORE_CONFIG_MAPS in discovered_resources
assert ResourceTypeValues.K8S_CORE_NODES in discovered_resources
assert ResourceTypeValues.K8S_CORE_PODS in discovered_resources
+ assert ResourceTypeValues.K8S_CORE_SECRETS in discovered_resources
assert ResourceTypeValues.K8S_CORE_SERVICES in discovered_resources
assert ResourceTypeValues.K8S_EXTENSIONS_INGRESSES in discovered_resources
assert ResourceTypeValues.K8S_NETWORKING_INGRESSES in discovered_resources
diff --git a/deployment_report/model/utils/config_util.py b/deployment_report/model/utils/config_util.py
index 1b5d7ec..4f50e21 100644
--- a/deployment_report/model/utils/config_util.py
+++ b/deployment_report/model/utils/config_util.py
@@ -46,6 +46,7 @@
_INTERNAL_DB_ = "Internal"
_UNSUPPORTED_DB_ = "Unsupported"
_CRUNCH_DB_ = "crunch"
+_CRUNCHDATA_DB_ = "sas-crunchy-data-"
_ALT_DB_ = "sas.database.alternative.databaseServerName"
_UNAVAIL_DB_ = "not available"
@@ -115,13 +116,10 @@ def get_db_info(resource_cache: Dict) -> Dict:
if not resource_cache:
return None
- try:
+ if ResourceTypeValues.SAS_PGCLUSTERS in resource_cache.keys():
pgclusters: Dict = resource_cache[ResourceTypeValues.SAS_PGCLUSTERS][ITEMS_KEY]
db_dict = _get_db_info_v2(pgclusters)
- except KeyError:
- pass
-
if not db_dict:
try:
config_maps: Dict = resource_cache[ResourceTypeValues.K8S_CORE_CONFIG_MAPS][ITEMS_KEY]
@@ -230,11 +228,84 @@ def _get_db_info_v2(pgclusters: Dict) -> Dict:
Keys.DatabaseDetails.DBCONN: _UNAVAIL_DB_
}
except KeyError:
- dbs = {Keys.DatabaseDetails.DBTYPE: _UNSUPPORTED_DB_}
+ continue
if dbs:
+ # convert db_name to be aligned
+ if _CRUNCHDATA_DB_ in db_name:
+ db_name = db_name.replace(_CRUNCHDATA_DB_, "")
+
db_dict[db_name] = dbs
except KeyError:
continue
return db_dict
+
+
+def get_configmaps_info(resource_cache: Dict) -> Optional[Dict]:
+ """
+ Returns the configmaps of the targeted SAS deployment.
+
+ :param resource_cache: The dictionary of resources gathered from the k8s deployment.
+
+ :return: A dictionary representing the configmaps information of the targeted SAS deployment.
+ """
+ configmaps_dict: Dict = dict()
+ try:
+ if not resource_cache:
+ return configmaps_dict
+
+ configmaps: Dict = resource_cache[ResourceTypeValues.K8S_CORE_CONFIG_MAPS][ITEMS_KEY]
+
+ for configmap_name, configmap_details in configmaps.items():
+
+ configmap: KubernetesResource = configmap_details[Keys.ResourceDetails.RESOURCE_DEFINITION]
+ # get the ConfigMap data
+ data: Optional[Dict] = configmap.get_data()
+
+ if data:
+ configmaps_dict[configmap_name] = data
+
+ return configmaps_dict
+
+ except KeyError:
+ return configmaps_dict
+
+
+def get_secrets_info(resource_cache: Dict, secretsnames_dict: Dict) -> Optional[Dict]:
+ """
+ Returns the secrets of the targeted SAS deployment.
+
+ :param resource_cache: The dictionary of resources gathered from the k8s deployment.
+ :param secretsnames_dict: The dictionary to store the secrets
+
+ :return: A dictionary representing the secrets by kind of the targeted SAS deployment.
+ """
+ secrets_dict: Dict = dict()
+ try:
+ if not resource_cache:
+ return secrets_dict
+
+ secrets: Dict = resource_cache[ResourceTypeValues.K8S_CORE_SECRETS][ITEMS_KEY]
+
+ for name, details in secrets.items():
+ secret: KubernetesResource = details[Keys.ResourceDetails.RESOURCE_DEFINITION]
+ data: Optional[Dict] = secret.get_data()
+
+ if data:
+ type: Optional[Text] = secret.get_type()
+
+ if type in secrets_dict.keys():
+ if name not in secrets_dict[type].keys():
+ secrets_dict[type][name] = {"name": list(data.keys())}
+ else:
+ secrets_dict[type]: Dict = dict()
+ secrets_dict[type][name]: Dict = dict()
+ secrets_dict[type][name] = {"name": list(data.keys())}
+
+ secretsnames_dict[name] = type
+
+ return secrets_dict
+
+ except KeyError:
+ return secrets_dict
diff --git a/deployment_report/model/utils/resource_util.py b/deployment_report/model/utils/resource_util.py
index 0f29848..522a2bf 100644
--- a/deployment_report/model/utils/resource_util.py
+++ b/deployment_report/model/utils/resource_util.py
@@ -114,6 +114,10 @@ def cache_resources(resource_type: Text, kubectl: KubectlInterface, resource_cac
# create a key under which the resource definition will be stored: KubernetesResource
resource_details[Keys.ResourceDetails.RESOURCE_DEFINITION]: KubernetesResource = resource
+ # skip ownerReferences for secret and configmap
+ if resource_type == "configmaps" or resource_type == "secrets":
+ continue
+
# see if this resource defines any 'ownerReferences'
owner_references: Optional[List[Dict]] = resource.get_metadata_value(KubernetesResourceKeys.OWNER_REFERENCES)
diff --git a/deployment_report/model/utils/test/test_config_util.py b/deployment_report/model/utils/test/test_config_util.py
index 625aff4..8021b92 100644
--- a/deployment_report/model/utils/test/test_config_util.py
+++ b/deployment_report/model/utils/test/test_config_util.py
@@ -86,3 +86,28 @@ def test_get_db_info_none():
db_dict: Dict = config_util.get_db_info(None)
assert db_dict is None
+
+
+@pytest.mark.usefixtures(conftest.NO_INGRESS_SIMULATION_FIXTURE)
+def test_get_configmaps_info(no_ingress_simulation_fixture: conftest.DSA):
+ """
+ This test verifies that the provided configmap data is returned when values is passed to get_configmaps_info().
+ """
+ # get the resource cache
+ resource_cache: Dict = no_ingress_simulation_fixture.resource_cache()
+
+ # test the util method
+ assert len(config_util.get_configmaps_info(resource_cache)) == 8
+
+
+@pytest.mark.usefixtures(conftest.NO_INGRESS_SIMULATION_FIXTURE)
+def test_get_secrets_info(no_ingress_simulation_fixture: conftest.DSA):
+ """
+ This test verifies that the provided secrets data is returned when values is passed to get_secrets_info().
+ """
+ # get the resource cache
+ resource_cache: Dict = no_ingress_simulation_fixture.resource_cache()
+
+ # test the util method
+ secretsnames_dict: Dict = dict()
+ assert len(config_util.get_secrets_info(resource_cache, secretsnames_dict)) == 2
diff --git a/deployment_report/model/viya_deployment_report.py b/deployment_report/model/viya_deployment_report.py
index c014255..7793820 100644
--- a/deployment_report/model/viya_deployment_report.py
+++ b/deployment_report/model/viya_deployment_report.py
@@ -27,6 +27,7 @@
resource_util
from viya_ark_library.jinja2.sas_jinja2 import Jinja2TemplateRenderer
+from viya_ark_library.k8s.k8s_resource_keys import KubernetesResourceKeys
from viya_ark_library.k8s.k8s_resource_type_values import KubernetesResourceTypeValues as ResourceTypeValues
from viya_ark_library.k8s.sas_k8s_errors import KubectlRequestForbiddenError
from viya_ark_library.k8s.sas_k8s_ingress import SupportedIngress
@@ -46,6 +47,14 @@
# SAS custom API resource group id
_SAS_API_GROUP_ID_ = "sas.com"
+# Configuration keys
+_ENVFROM_ = "envFrom"
+_PODS_ = "pods"
+_CONFIGMAPREF_ = "configMapRef"
+_SECRETREF_ = "secretRef"
+_REFPC_ = "referenced_pods_containers"
+_REFLINK_ = "ref"
+
class ViyaDeploymentReport(object):
"""
@@ -137,11 +146,13 @@ def _create_resource_cache(kubectl: KubectlInterface, sas_custom_resource_types:
# cache values that are not owned by components but could still be included in the report, if present
for resource_type in [ResourceTypeValues.K8S_CORE_NODES,
- ResourceTypeValues.K8S_CORE_CONFIG_MAPS]:
+ ResourceTypeValues.K8S_CORE_CONFIG_MAPS,
+ ResourceTypeValues.K8S_CORE_SECRETS]:
try:
################
# Nodes
# ConfigMaps
+ # Secrets
################
resource_util.cache_resources(resource_type=resource_type,
kubectl=kubectl,
@@ -243,12 +254,18 @@ def gather_details(self, kubectl: KubectlInterface,
sas_custom_resource_types=sas_custom_resource_types)
#######################################################################
- # Create a cadence/db information #
+ # Create a cadence/db/configmaps/secrets information #
#######################################################################
cadence_info: Text = config_util.get_cadence_version(resource_cache=resource_cache)
db_dict: Dict = config_util.get_db_info(resource_cache=resource_cache)
+ configmaps_dict: Dict = config_util.get_configmaps_info(resource_cache=resource_cache)
+
+ secretsnames_dict: Dict = dict()
+ secrets_dict: Dict = config_util.get_secrets_info(resource_cache=resource_cache,
+ secretsnames_dict=secretsnames_dict)
+
#######################################################################
# Check whether pod resources were found (resources exist) #
#######################################################################
@@ -362,6 +379,12 @@ def gather_details(self, kubectl: KubectlInterface,
# create a key to hold the Viya db information: dict
k8s_details_dict[Keys.Kubernetes.DB_INFO]: Dict = db_dict
+ # create a key to hold the Viya configmaps information: dict
+ k8s_details_dict[Keys.Kubernetes.CONFIGMAPS_DICT]: Dict = configmaps_dict
+
+ # create a key to hold the Viya secrets information: dict
+ k8s_details_dict[Keys.Kubernetes.SECRETS_DICT]: Dict = secrets_dict
+
# add the availability and count of all discovered resources
for resource_type, resource_type_details in resource_cache.items():
# create an entry for the resource
@@ -411,6 +434,10 @@ def gather_details(self, kubectl: KubectlInterface,
is_sas_component = \
(is_sas_component or
resource_details[Keys.ResourceDetails.RESOURCE_DEFINITION].is_sas_resource())
+ if is_sas_component:
+ break
+ if is_sas_component:
+ break
# add the component to its appropriate dictionary
if is_sas_component:
@@ -432,6 +459,45 @@ def gather_details(self, kubectl: KubectlInterface,
# add this to the misc dict, it could not be treated as a SAS component
misc_dict[component_name]: Dict = component[ITEMS_KEY]
+ # build relationship configmaps to pod containers
+ refcfgmaps_dict: Dict = dict()
+ refsecrets_dict: Dict = dict()
+
+ for s in sas_dict.keys():
+ for mypod in sas_dict[s][_PODS_].keys():
+ myres = sas_dict[s][_PODS_][mypod][Keys.ResourceDetails.RESOURCE_DEFINITION]
+ mypodname = myres[KubernetesResourceKeys.METADATA][NAME_KEY]
+ myspec = myres.get_spec()
+ for c in myspec[KubernetesResourceKeys.CONTAINERS]:
+ if _ENVFROM_ in c.keys():
+ for e in c[_ENVFROM_]:
+ if _CONFIGMAPREF_ in e.keys():
+ try:
+ refcfgmaps_dict[e[_CONFIGMAPREF_][NAME_KEY]].append(
+ mypodname + "_" + c[NAME_KEY])
+ except KeyError:
+ refcfgmaps_dict[e[_CONFIGMAPREF_][NAME_KEY]] = [mypodname + "_" + c[NAME_KEY]]
+
+ elif _SECRETREF_ in e.keys():
+ try:
+ refsecrets_dict[e[_SECRETREF_][NAME_KEY]].append(mypodname + "_" + c[NAME_KEY])
+ except KeyError:
+ refsecrets_dict[e[_SECRETREF_][NAME_KEY]] = [mypodname + "_" + c[NAME_KEY]]
+
+ for k in refcfgmaps_dict.keys():
+ try:
+ configmaps_dict[k][_REFPC_] = refcfgmaps_dict[k]
+ except KeyError:
+ continue
+
+ # assign ref secrets
+ for r in refsecrets_dict.keys():
+ try:
+ k = secretsnames_dict[r]
+ secrets_dict[k][r][_REFLINK_] = refsecrets_dict[r]
+ except KeyError:
+ continue
+
def get_kubernetes_details(self) -> Optional[Dict]:
"""
Returns the details gathered about the target Kubernetes cluster.
diff --git a/deployment_report/templates/pods.html.j2 b/deployment_report/templates/pods.html.j2
index 2c844d0..6fcefa9 100644
--- a/deployment_report/templates/pods.html.j2
+++ b/deployment_report/templates/pods.html.j2
@@ -44,6 +44,54 @@
value=resource_details.resourceDefinition.status.podIP) }}
{% endblock %}
+{% macro container_config_accordion(container) %}
+ {% if container.envFrom is defined %}
+ {#
+ {% set configmapstr = '' %}
+ {% set secretstr = '' %}
+ #}
+ {# {% set ns = namespace(configmapstr='') %}
+ {% set ns = namespace(secretstr='') %}
+ #}
+ {% set ns = namespace() %}
+ {% set ns.configmapstr = '' %}
+ {% set ns.secretstr = '' %}
+
+ {% for item in container.envFrom %}
+ {% if "configMapRef" in item.keys() %}
+ {% if item["configMapRef"]["name"] in report_data.kubernetes.configMaps.keys() %}
+ {% set astr = '' %}
+ {% set astr = astr ~ item["configMapRef"]["name"] ~ '' %}
+ {% set ns.configmapstr = ns.configmapstr ~ astr ~ ',' %}
+ {% else %}
+ {% set astr = item["configMapRef"]["name"] %}
+ {% set ns.configmapstr = ns.configmapstr ~ astr ~ ',' %}
+ {% endif %}
+ {% elif "secretRef" in item.keys() %}
+ {% set astr = '' %}
+ {% set astr = astr ~ item["secretRef"]["name"] ~ '' %}
+ {% set ns.secretstr = ns.secretstr ~ astr ~ ',' %}
+ {% endif %}
+ {% endfor %}
+ {% if ns.configmapstr != '' %}
+ {% set idstr = 'id="pod-configmaps_' ~ resource_details.resourceDefinition.metadata.name ~ '_' ~ container.name ~ '"' %}
+
+ ConfigMapRef |
+ {{ ns.configmapstr[:-1] }} |
+
+ {% endif %}
+ {% if ns.secretstr != '' %}
+ {% set idstr = 'id="pod-secrets_' ~ resource_details.resourceDefinition.metadata.name ~ '_' ~ container.name ~ '"' %}
+
+ SecretRef |
+ {{ ns.secretstr[:-1] }} |
+
+ {% endif %}
+ {% endif %}
+{% endmacro %}
+
{% macro container_status_accordion(container) %}
{{ container.name }}
@@ -98,6 +146,20 @@
{{ add_vert_header_table_row(label="Restart Count",
desc="The number of times this container has restarted",
value=container.restartCount) }}
+
+ {# configMapRef/secretRef #}
+ {% if resource_details.resourceDefinition.spec.containers is defined %}
+ {#
+ {% set ns = namespace(secretstr='') %}
+ {% set ns = namespace(configmapstr='') %}
+ #}
+ {% for config_container in resource_details.resourceDefinition.spec.containers %}
+ {% if config_container.name == container.name %}
+ {{ container_config_accordion(config_container) }}
+ {% endif %}
+ {% endfor %}
+ {% endif %}
+
@@ -164,4 +226,4 @@
{% endif %}
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/deployment_report/templates/viya_deployment_report.html.j2 b/deployment_report/templates/viya_deployment_report.html.j2
index 82e1e9b..57f995d 100644
--- a/deployment_report/templates/viya_deployment_report.html.j2
+++ b/deployment_report/templates/viya_deployment_report.html.j2
@@ -135,6 +135,7 @@
Storage
+ {% if report_data.kubernetes.dbInfo|length > 0 %}
{% for db, info in report_data.kubernetes.dbInfo.items() %}
Database ({{ db }})
@@ -150,6 +151,14 @@
{% endfor %}
{% endfor %}
+ {% else %}
+
+
+
+ No databases were found in namespace [{{ report_data.kubernetes.namespace }}].
+
+
+ {% endif %}
{# Cluster Overview: Storage Accordion #}
@@ -295,5 +304,126 @@
{# API: Versions Accordion #}
{# API: Content #}
+
+ Configurations
+ {# Configurations: Content #}
+
+
+ {# Configurations: ConfigMaps Accordion #}
+
ConfigMaps
+
+ {# {% set kind_name = "Configmaps" %} #}
+ {% if report_data.kubernetes.configMaps|length == 0 %}
+
+
+
+ No ConfigMaps were found in namespace [{{ report_data.kubernetes.namespace }}].
+
+
+ {% else %}
+ {% for name, info in report_data.kubernetes.configMaps.items() %}
+
+
{{ name }}
+
+
+
+ Key |
+ Value |
+
+ {% set ns = namespace() %}
+ {% set ns.configmapvalue = '' %}
+
+ {% for key, value in info.items() %}
+ {% if key != "referenced_pods_containers" %}
+
+ {{ key }} |
+ {{ value }} |
+
+ {% else %}
+ {% set mybr = '' %}
+ {% for i in value %}
+ {% set ns.configmapvalue = ns.configmapvalue ~ '' ~ mybr ~ '• ' ~ i ~ '' %}
+ {% endfor %}
+ {% endif %}
+ {% endfor %}
+
+ {% if ns.configmapvalue != '' %}
+
Referenced pods containers: {{ ns.configmapvalue }}
+ {% endif %}
+
+
+ {% endfor %}
+ {% endif %}
+
+
+ {# Configurations: ConfigMaps Accordion #}
+
+ {# Configurations: Secrets Accordion #}
+
+
Secrets
+ {# {% set kind_name = "Secrets" %} #}
+
+ {% if report_data.kubernetes.secrets|length == 0 %}
+
+
+
+
+ No Secrets were found in namespace [{{ report_data.kubernetes.namespace }}].
+
+
+
+ {% else %}
+
+ {% for type, info in report_data.kubernetes.secrets.items() %}
+
+
{{ type }}
+
+ {% set ns = namespace() %}
+ {% for key, value in info.items() %}
+ {% set ns.keyrefurl = '' %}
+ {% set ns.keylist = '' %}
+ {% for key2, value2 in value.items() %}
+ {% if key2 == "name" %}
+ {% set ns.keylist = ns.keylist ~ "
Keys |
---|
" %}
+ {% for i in value2 %}
+ {% set ns.keylist = ns.keylist ~ "
" ~ i ~ " |
" %}
+ {% endfor %}
+ {% else %}
+ {% set mybr = '' %}
+ {% set ns.secretvalue = '' %}
+ {% for i in value2 %}
+ {% set ns.secretvalue = ns.secretvalue ~ '
' ~ mybr ~ '• ' ~ i ~ '' %}
+ {% endfor %}
+ {% if ns.secretvalue != '' %}
+ {% set ns.keyrefurl = ns.keyrefurl ~ mybr ~ "Referenced pods containers:" ~ ns.secretvalue ~ mybr ~ mybr %}
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+
+
{{ key }}
+
+
+ {% if ns.keyrefurl != '' %}
+ {{ ns.keyrefurl }}
+ {% endif %}
+
+
+ {% set ns.keylist = '' %}
+ {% set ns.keyrefurl = '' %}
+ {% endfor %}
+
+
+ {% endfor %}
+
+
+ {% endif %}
+
+
+ {# Configurations: Secrets Accordion #}
+
+ {# Configurations: Content #}
+
{% endblock %}
{# BLOCK DEFINITIONS #}
diff --git a/viya_ark_library/k8s/k8s_resource_keys.py b/viya_ark_library/k8s/k8s_resource_keys.py
index 29482a2..3f166fd 100644
--- a/viya_ark_library/k8s/k8s_resource_keys.py
+++ b/viya_ark_library/k8s/k8s_resource_keys.py
@@ -113,6 +113,7 @@ class KubernetesResourceKeys(object):
TCP = "tcp"
TO = "to"
TEMPLATE = "template"
+ TYPE = "type"
UID = "uid"
URI = "uri"
UPDATED_REPLICAS = "updatedReplicas"
diff --git a/viya_ark_library/k8s/k8s_resource_type_values.py b/viya_ark_library/k8s/k8s_resource_type_values.py
index b9c3ed0..c7f0245 100644
--- a/viya_ark_library/k8s/k8s_resource_type_values.py
+++ b/viya_ark_library/k8s/k8s_resource_type_values.py
@@ -42,6 +42,7 @@ class KubernetesResourceTypeValues(object):
K8S_CORE_NAMESPACES = "namespaces"
K8S_CORE_NODES = "nodes"
K8S_CORE_PODS = "pods"
+ K8S_CORE_SECRETS = "secrets"
K8S_CORE_SERVICES = "services"
# API: extensions
diff --git a/viya_ark_library/k8s/sas_k8s_objects.py b/viya_ark_library/k8s/sas_k8s_objects.py
index a9bea25..8c563bb 100644
--- a/viya_ark_library/k8s/sas_k8s_objects.py
+++ b/viya_ark_library/k8s/sas_k8s_objects.py
@@ -899,6 +899,14 @@ def get_status_value(self, key: Text) -> Optional[Any]:
except KeyError:
return None
+ def get_type(self) -> Optional[AnyStr]:
+ """
+ Returns the 'type' dictionary for this Resource.
+
+ :return: This Resource's 'type' value.
+ """
+ return self._resource.get(KubernetesResourceKeys.TYPE)
+
def as_dict(self) -> Dict:
"""
Returns this KubernetesResource as a native 'dict' object.
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 be772d7..d83de0c 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
@@ -167,6 +167,24 @@
],
"version": "v1"
},
+ "secrets": {
+ "group": "",
+ "kind": "Secret",
+ "name": "secrets",
+ "namespaced": true,
+ "shortname": "",
+ "verbs": [
+ "create",
+ "delete",
+ "deletecollection",
+ "get",
+ "list",
+ "patch",
+ "update",
+ "watch"
+ ],
+ "version": "v1"
+ },
"services": {
"group": "",
"kind": "Service",
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 3c3f7ad..56b970a 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
@@ -167,6 +167,24 @@
],
"version": "v1"
},
+ "secrets": {
+ "group": "",
+ "kind": "Secret",
+ "name": "secrets",
+ "namespaced": true,
+ "shortname": "",
+ "verbs": [
+ "create",
+ "delete",
+ "deletecollection",
+ "get",
+ "list",
+ "patch",
+ "update",
+ "watch"
+ ],
+ "version": "v1"
+ },
"services": {
"group": "",
"kind": "Service",
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 f04f11b..f2121bf 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
@@ -166,6 +166,24 @@
"watch"
],
"version": "v1"
+ },
+ "secrets": {
+ "group": "",
+ "kind": "Secret",
+ "name": "secrets",
+ "namespaced": true,
+ "shortname": "",
+ "verbs": [
+ "create",
+ "delete",
+ "deletecollection",
+ "get",
+ "list",
+ "patch",
+ "update",
+ "watch"
+ ],
+ "version": "v1"
},
"services": {
"group": "",
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 29028ac..a88172f 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
@@ -17,6 +17,24 @@
],
"version": "v1alpha1"
},
+ "secrets": {
+ "group": "",
+ "kind": "Secret",
+ "name": "secrets",
+ "namespaced": true,
+ "shortname": "",
+ "verbs": [
+ "create",
+ "delete",
+ "deletecollection",
+ "get",
+ "list",
+ "patch",
+ "update",
+ "watch"
+ ],
+ "version": "v1"
+ },
"configmaps": {
"group": "",
"kind": "ConfigMap",
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 1e6a3bd..d558f9f 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
@@ -167,6 +167,24 @@
],
"version": "v1"
},
+ "secrets": {
+ "group": "",
+ "kind": "Secret",
+ "name": "secrets",
+ "namespaced": true,
+ "shortname": "",
+ "verbs": [
+ "create",
+ "delete",
+ "deletecollection",
+ "get",
+ "list",
+ "patch",
+ "update",
+ "watch"
+ ],
+ "version": "v1"
+ },
"services": {
"group": "",
"kind": "Service",
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 d769f1d..92109ad 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
@@ -167,6 +167,24 @@
],
"version": "v1"
},
+ "secrets": {
+ "group": "",
+ "kind": "Secret",
+ "name": "secrets",
+ "namespaced": true,
+ "shortname": "",
+ "verbs": [
+ "create",
+ "delete",
+ "deletecollection",
+ "get",
+ "list",
+ "patch",
+ "update",
+ "watch"
+ ],
+ "version": "v1"
+ },
"services": {
"group": "",
"kind": "Service",
diff --git a/viya_ark_library/k8s/test_impl/response_data/resources_configmaps.json b/viya_ark_library/k8s/test_impl/response_data/resources_configmaps.json
index da1f18a..3d1caec 100644
--- a/viya_ark_library/k8s/test_impl/response_data/resources_configmaps.json
+++ b/viya_ark_library/k8s/test_impl/response_data/resources_configmaps.json
@@ -62,5 +62,227 @@
"selfLink": "/api/v1/namespaces/test/configmaps/sas-postgres-config-5dt8fm92c7",
"uid": "9924c601-602f-404a-b113-7b6671f0e88f"
}
- }
+ },
+ {
+ "apiVersion": "v1",
+ "data": {
+ "SAS_CONTEXT_PATH": "backupagent",
+ "SAS_DU_NAME": "sas-backup-agent",
+ "SAS_SERVICE_NAME": "sas-backup-agent",
+ "SAS_TOOL_RETRY_LIMIT": "100",
+ "SAS_TOOL_RETRY_PERIOD": "1m",
+ "SG_PROJECT": "backup-agent",
+ "SG_STATIC": "false"
+ },
+ "kind": "ConfigMap",
+ "metadata": {
+ "annotations": {
+ "kubectl.kubernetes.io/last-applied-configuration": ""
+ },
+ "creationTimestamp": "2021-08-26T16:06:30Z",
+ "labels": {
+ "sas.com/admin": "cluster-local",
+ "sas.com/deployment": "sas-viya"
+ },
+ "managedFields": [],
+ "name": "sas-backup-agent-parameters-gdtd8hktkf",
+ "namespace": "test",
+ "ownerReferences": [
+ {
+ "apiVersion": "orchestration.sas.com/v1alpha1",
+ "blockOwnerDeletion": true,
+ "controller": true,
+ "kind": "SASDeployment",
+ "name": "sas-viya",
+ "uid": "396aebe9-5080-4117-addb-f51ec1c254d5"
+ }
+ ],
+ "resourceVersion": "12975216",
+ "selfLink": "/api/v1/namespaces/test/configmaps/sas-backup-agent-parameters-gdtd8hktkf",
+ "uid": "0312d7cc-0a70-4e48-b031-29b6e34618e2"
+ }
+ },
+ {
+ "apiVersion": "v1",
+ "data": {
+ "CONSUL_HTTP_ADDR": "https://sas-consul-server:8500",
+ "SAS_BOOTSTRAP_HTTP_CLIENT_TIMEOUT_REQUEST": "5m",
+ "SAS_RECONCILER_SERVICES_ENABLED": "true",
+ "SAS_REGISTRY_REGISTER_ENABLED": "false"
+ },
+ "kind": "ConfigMap",
+ "metadata": {
+ "annotations": {
+ "kubectl.kubernetes.io/last-applied-configuration": ""
+ },
+ "creationTimestamp": "2021-08-26T16:06:31Z",
+ "labels": {
+ "sas.com/admin": "cluster-local",
+ "sas.com/deployment": "sas-viya"
+ },
+ "managedFields": [],
+ "name": "sas-go-config-256bgc697g",
+ "namespace": "test",
+ "ownerReferences": [
+ {
+ "apiVersion": "orchestration.sas.com/v1alpha1",
+ "blockOwnerDeletion": true,
+ "controller": true,
+ "kind": "SASDeployment",
+ "name": "sas-viya",
+ "uid": "396aebe9-5080-4117-addb-f51ec1c254d5"
+ }
+ ],
+ "resourceVersion": "12975289",
+ "selfLink": "/api/v1/namespaces/test/configmaps/sas-go-config-256bgc697g",
+ "uid": "950766aa-10b1-4e77-9842-05e0ec81122f"
+ }
+ },
+ {
+ "apiVersion": "v1",
+ "data": {
+ "JOB_TIME_OUT": "600",
+ "RETENTION_PERIOD": "30",
+ "SAS_BACKUP_JOB_DU_NAME": "sas-backup-job"
+ },
+ "kind": "ConfigMap",
+ "metadata": {
+ "annotations": {
+ "kubectl.kubernetes.io/last-applied-configuration": ""
+ },
+ "creationTimestamp": "2021-08-26T16:06:30Z",
+ "labels": {
+ "sas.com/admin": "cluster-local",
+ "sas.com/deployment": "sas-viya"
+ },
+ "managedFields": [],
+ "name": "sas-backup-job-parameters-gb2b7ckggt",
+ "namespace": "test",
+ "ownerReferences": [
+ {
+ "apiVersion": "orchestration.sas.com/v1alpha1",
+ "blockOwnerDeletion": true,
+ "controller": true,
+ "kind": "SASDeployment",
+ "name": "sas-viya",
+ "uid": "396aebe9-5080-4117-addb-f51ec1c254d5"
+ }
+ ],
+ "resourceVersion": "12975217",
+ "selfLink": "/api/v1/namespaces/test/configmaps/sas-backup-job-parameters-gb2b7ckggt",
+ "uid": "101353dd-6337-4ae9-8387-06fcdb1ae0f0"
+ }
+ },
+ {
+ "apiVersion": "v1",
+ "data": {
+ "SAS_ALLOW_ADMIN_SCRIPTS": "false",
+ "SAS_MULTI_TENANCY_ENABLED": "false",
+ "SAS_SERVICES_URL": "https://k8s-master-node.test.sas.com:443",
+ "SAS_URL_SERVICE_SCHEME": "https",
+ "SAS_URL_SERVICE_TEMPLATE": "https://@k8s.service.name@"
+ },
+ "kind": "ConfigMap",
+ "metadata": {
+ "annotations": {
+ "kubectl.kubernetes.io/last-applied-configuration": ""
+ },
+ "creationTimestamp": "2021-08-26T16:06:32Z",
+ "labels": {
+ "sas.com/admin": "cluster-local",
+ "sas.com/deployment": "sas-viya"
+ },
+ "managedFields": [],
+ "name": "sas-shared-config-dh4f2c4mk9",
+ "namespace": "test",
+ "ownerReferences": [
+ {
+ "apiVersion": "orchestration.sas.com/v1alpha1",
+ "blockOwnerDeletion": true,
+ "controller": true,
+ "kind": "SASDeployment",
+ "name": "sas-viya",
+ "uid": "396aebe9-5080-4117-addb-f51ec1c254d5"
+ }
+ ],
+ "resourceVersion": "12975367",
+ "selfLink": "/api/v1/namespaces/test/configmaps/sas-shared-config-dh4f2c4mk9",
+ "uid": "7a894053-f8f4-4bb1-861c-450f9ff09704"
+ }
+ },
+ {
+ "apiVersion": "v1",
+ "data": {
+ "SAS_RESTORE_JOB_DU_NAME": "sas-restore-job"
+ },
+ "kind": "ConfigMap",
+ "metadata": {
+ "annotations": {
+ "kubectl.kubernetes.io/last-applied-configuration": ""
+ },
+ "creationTimestamp": "2021-08-26T16:06:32Z",
+ "labels": {
+ "sas.com/admin": "cluster-local",
+ "sas.com/deployment": "sas-viya"
+ },
+ "managedFields": [],
+ "name": "sas-restore-job-parameters-6dh8htc9fg",
+ "namespace": "test",
+ "ownerReferences": [
+ {
+ "apiVersion": "orchestration.sas.com/v1alpha1",
+ "blockOwnerDeletion": true,
+ "controller": true,
+ "kind": "SASDeployment",
+ "name": "sas-viya",
+ "uid": "396aebe9-5080-4117-addb-f51ec1c254d5"
+ }
+ ],
+ "resourceVersion": "12975359",
+ "selfLink": "/api/v1/namespaces/test/configmaps/sas-restore-job-parameters-6dh8htc9fg",
+ "uid": "518a31b2-a806-49f5-abec-3d785b127fa1"
+ }
+ },
+ {
+ "apiVersion": "v1",
+ "data": {
+ "CONSUL_HTTP_ADDR": "https://sas-consul-server:8500",
+ "JAVA_OPTION_GEODE_LOG": "-Dlogging.level.org.apache.geode.internal.net.SocketCreator=ERROR",
+ "JAVA_OPTION_SERVER_PORT": "-Dserver.port=8080",
+ "SASLOGROOT": "",
+ "SAS_LOG_FORMAT": "json",
+ "SAS_REGISTRY_REGISTER_ENABLED": "false",
+ "SAS_SERVICES_METRICS_SECURED": "false",
+ "SPRING_CLOUD_CONSUL_DISCOVERY_PREFERIPADDRESS": "true",
+ "SPRING_CLOUD_CONSUL_DISCOVERY_REGISTER": "false",
+ "SPRING_CLOUD_CONSUL_ENABLED": "true"
+ },
+ "kind": "ConfigMap",
+ "metadata": {
+ "annotations": {
+ "kubectl.kubernetes.io/last-applied-configuration": ""
+ },
+ "creationTimestamp": "2021-08-26T16:06:31Z",
+ "labels": {
+ "sas.com/admin": "cluster-local",
+ "sas.com/deployment": "sas-viya"
+ },
+ "managedFields": [],
+ "name": "sas-java-config-8bc8mbd5mk",
+ "namespace": "test",
+ "ownerReferences": [
+ {
+ "apiVersion": "orchestration.sas.com/v1alpha1",
+ "blockOwnerDeletion": true,
+ "controller": true,
+ "kind": "SASDeployment",
+ "name": "sas-viya",
+ "uid": "396aebe9-5080-4117-addb-f51ec1c254d5"
+ }
+ ],
+ "resourceVersion": "12975295",
+ "selfLink": "/api/v1/namespaces/test/configmaps/sas-java-config-8bc8mbd5mk",
+ "uid": "94245cd9-9d4a-4a84-939e-aa0c39ee71a5"
+ }
+ }
]
diff --git a/viya_ark_library/k8s/test_impl/response_data/resources_secrets.json b/viya_ark_library/k8s/test_impl/response_data/resources_secrets.json
new file mode 100644
index 0000000..fe6cedd
--- /dev/null
+++ b/viya_ark_library/k8s/test_impl/response_data/resources_secrets.json
@@ -0,0 +1,84 @@
+[
+ {
+ "apiVersion": "v1",
+ "data": {
+ "permissions": "",
+ "rolename": ""
+ },
+ "kind": "Secret",
+ "metadata": {
+ "annotations": {
+ "kubectl.kubernetes.io/last-applied-configuration": "",
+ "sas.com/component-name": "sas-crunchy-data-postgres-operator",
+ "sas.com/component-version": "20.9.7-20210820.1629473400450",
+ "sas.com/tls-enabled-ports": "all",
+ "sas.com/version": "20.9.7"
+ },
+ "creationTimestamp": "2021-08-26T16:06:32Z",
+ "labels": {
+ "pgo-created-by": "bootstrap",
+ "pgo-pgorole": "true",
+ "rolename": "pgoadmin",
+ "sas.com/admin": "cluster-local",
+ "sas.com/deployment": "sas-viya",
+ "vendor": "crunchydata"
+ },
+ "managedFields": [],
+ "name": "pgorole-pgoadmin",
+ "namespace": "test",
+ "ownerReferences": [
+ {
+ "apiVersion": "orchestration.sas.com/v1alpha1",
+ "blockOwnerDeletion": true,
+ "controller": true,
+ "kind": "SASDeployment",
+ "name": "sas-viya",
+ "uid": "396aebe9-5080-4117-addb-f51ec1c254d5"
+ }
+ ],
+ "resourceVersion": "12975387",
+ "selfLink": "/api/v1/namespaces/test/secrets/pgorole-pgoadmin",
+ "uid": "483d145a-3154-4470-8e00-7d2af3b4083c"
+ },
+ "type": "Opaque"
+ },
+ {
+ "apiVersion": "v1",
+ "data": {
+ "ca.crt": "",
+ "tls.crt": "",
+ "tls.key": ""
+ },
+ "kind": "Secret",
+ "metadata": {
+ "annotations": {
+ "cert-manager.io/alt-names": "localhost,sas-web-data-access,sas-web-data-access-78b5f77db6-nr8zv",
+ "cert-manager.io/certificate-name": "sas-web-data-access-78b5f77db6-nr8zv",
+ "cert-manager.io/common-name": "sas-web-data-access-78b5f77db6-nr8zv",
+ "cert-manager.io/ip-sans": "127.0.0.1",
+ "cert-manager.io/issuer-group": "",
+ "cert-manager.io/issuer-kind": "Issuer",
+ "cert-manager.io/issuer-name": "sas-viya-issuer",
+ "cert-manager.io/uri-sans": ""
+ },
+ "creationTimestamp": "2021-08-26T16:12:30Z",
+ "managedFields": [],
+ "name": "sas-web-data-access-78b5f77db6-nr8zv",
+ "namespace": "test",
+ "ownerReferences": [
+ {
+ "apiVersion": "cert-manager.io/v1",
+ "blockOwnerDeletion": true,
+ "controller": true,
+ "kind": "Certificate",
+ "name": "sas-web-data-access-78b5f77db6-nr8zv",
+ "uid": "07245437-ea3c-427d-85c2-afa253999aae"
+ }
+ ],
+ "resourceVersion": "19810118",
+ "selfLink": "/api/v1/namespaces/test/secrets/sas-web-data-access-78b5f77db6-nr8zv",
+ "uid": "0a14ed50-2d33-46a5-8c9d-28725aca0f9b"
+ },
+ "type": "kubernetes.io/tls"
+ }
+]
diff --git a/viya_ark_library/k8s/test_impl/sas_kubectl_test.py b/viya_ark_library/k8s/test_impl/sas_kubectl_test.py
index a8c8a15..6412a2c 100644
--- a/viya_ark_library/k8s/test_impl/sas_kubectl_test.py
+++ b/viya_ark_library/k8s/test_impl/sas_kubectl_test.py
@@ -253,6 +253,7 @@ class Values(object):
KubernetesResourceTypeValues.OPENSHIFT_ROUTES,
KubernetesResourceTypeValues.K8S_CORE_PODS,
KubernetesResourceTypeValues.K8S_APPS_REPLICA_SETS,
+ KubernetesResourceTypeValues.K8S_CORE_SECRETS,
KubernetesResourceTypeValues.K8S_CORE_SERVICES,
KubernetesResourceTypeValues.K8S_APPS_STATEFUL_SETS
]
@@ -269,6 +270,7 @@ class Values(object):
KubernetesResourceTypeValues.K8S_CORE_NODES,
KubernetesResourceTypeValues.K8S_CORE_PODS,
KubernetesResourceTypeValues.K8S_APPS_REPLICA_SETS,
+ KubernetesResourceTypeValues.K8S_CORE_SECRETS,
KubernetesResourceTypeValues.K8S_CORE_SERVICES,
KubernetesResourceTypeValues.K8S_APPS_STATEFUL_SETS
]
@@ -285,6 +287,7 @@ class Values(object):
KubernetesResourceTypeValues.K8S_CORE_NODES,
KubernetesResourceTypeValues.K8S_CORE_PODS,
KubernetesResourceTypeValues.K8S_APPS_REPLICA_SETS,
+ KubernetesResourceTypeValues.K8S_CORE_SECRETS,
KubernetesResourceTypeValues.K8S_CORE_SERVICES,
KubernetesResourceTypeValues.K8S_APPS_STATEFUL_SETS
]
@@ -302,6 +305,7 @@ class Values(object):
KubernetesResourceTypeValues.K8S_CORE_NODES,
KubernetesResourceTypeValues.K8S_CORE_PODS,
KubernetesResourceTypeValues.K8S_APPS_REPLICA_SETS,
+ KubernetesResourceTypeValues.K8S_CORE_SECRETS,
KubernetesResourceTypeValues.K8S_CORE_SERVICES,
KubernetesResourceTypeValues.K8S_APPS_STATEFUL_SETS
]
@@ -318,6 +322,7 @@ class Values(object):
KubernetesResourceTypeValues.OPENSHIFT_ROUTES,
KubernetesResourceTypeValues.K8S_CORE_PODS,
KubernetesResourceTypeValues.K8S_APPS_REPLICA_SETS,
+ KubernetesResourceTypeValues.K8S_CORE_SECRETS,
KubernetesResourceTypeValues.K8S_CORE_SERVICES,
KubernetesResourceTypeValues.K8S_APPS_STATEFUL_SETS
]