Alikutty A
Tera Sage

 

While exploring ServiceNow product documentations, you may not find much information related to the discovery of Open shift infrastructure but they are available and grouped along with Kubernetes discovery patterns. This is because Open shift components are partly built on top of Kubernetes and it forms the kernel for the containerized platform. This blog would cover details on setting up an Open shift discovery within ServiceNow. The following steps are required to be followed for enabling its discovery:

 

Configuration Steps

  1. Install/Update to the latest version of "Discovery and Service Mapping Patterns" (sn_itom_pattern) plugin

  2. Setup a Mid server in one of the virtual machine connected with the open shift infrastructure

  3. Identify all Open shift clusters and related details required for discovery. You will need to access the open shift container platform and execute certain commands to fetch the details. The OC CLI should be installed and you should reach out to your open shift admin who should be aware of these commands

a. OC Cluster URL and port - This command will provide you an https URL where the cluster process is hosted and a port where it listens for incoming messages.

 

oc cluster-info

eg: https://openshift.example.com:6443

 

b. Namespaces - Generally all namespaces are discovered using a * keyword. In case you need to discover specific namespaces of your project, run this command to retrieve list of all namespaces and select the ones required for discovery.

 

oc get namespaces

eg: default, kube_system or any other specific to your project deployments

 

c. Credentials - Run the following command to view the config details of your cluster. This will contain the required username and password to connect with Open Shift Rest APIs

 

oc config view

 

d. Token - Fetch the bearer token for calling OC Rest API. Execute the OC command or related Oauth API to fetch the token (API listed in the docs

 

oc describe secret

 

  1. Ensure firewall connectivity from mid server to the OC cluster URL/port number
  2. Create a new Kubernetes credential and credential alias with the user name, password and Bearer token obtained from above steps. 
  3. Create a Serverless discovery schedule with Kubernetes as the required pattern and the installed mid server
  4. Add all required parameters for the pattern to execute: namespace (* or comma separated list), credentialAlias name and url with port are minimum required for discovery to execute

AlikuttyA_0-1672422733611.png

8. Create new schedules for each clusters and discover them separately

 

Node Relationships Discovered

 

kuberel.jpg

 

Common Issues & Possible Resolutions

  1. Discovery not working due to credential issue - User may not have the right permissions to execute API or token has expired. 
  2. Discovery not working due to missing SSL certificate - Import the open shift cluster self signed certificate into the mid server and restart server
  3. APIs or clusters are not accessible from mid server - Execute a CURL command and connect with any one of open shift Rest API from mid server to validate connectivity eg Test the following API to get namespaces from mid server - Namespace [core/v1] - Metadata APIs | API reference | OpenShift Container Platform 4.8
  4. Pattern fails between execution of discovery - Debug the Kubernetes pattern and validate the step

 

Additional References

Getting started with the CLI - OpenShift CLI (oc) | CLI tools | OpenShift Container Platform 4.2

API list | API reference | OpenShift Container Platform 4.8

Kubernetes discovery (servicenow.com)

  

 

 

3 Comments
kashif_ansari
Tera Contributor

hello @Alikutty A 

Thank you for sharing the above steps, however i am currently facing issues with the openshift discovery and getting below error:

 

Openshift discovery log error.PNG

 

Also, for defining the credential alias, i just created a credential alias as below and added this credential alias ID in the pattern 

Credential alias.PNG

kashif_ansari_1-1686229356958.png

Can you please guide me if i am missing something here.

Alikutty A
Tera Sage

Error message says you are having permission issues in accessing the URL, try to login to the mid server and do an API connect on the URL specified.

Logappradeep
Tera Contributor

Hi @Alikutty A 
I am attempting to perform an OpenShift Discovery, but I am currently encountering the following error:"Kubernetes Namespace API call failed or there are no Namespaces in the query. Please verify the configuration data and/or user permissions. "

Logappradeep_0-1756136571714.png

Here are my configurations, which might help identify the issue:
1. Credentials

Logappradeep_2-1756137249747.png

2. Discovery Schedule

Logappradeep_3-1756137389695.png

3. Serverless Execution Pattern

Logappradeep_0-1756139145122.png

4. Discovery Status

Logappradeep_2-1756139317432.png