Kubernetes discovery using patterns
The ServiceNow ITOM Visibility finds Kubernetes and OpenShift components using patterns and creates application services containing them. Discovery also finds Kubernetes events and frequently updates the CMDB to reflect the dynamic Kubernetes environment.
Discovery uses the Kubernetes pattern and its extension sections to discover Kubernetes components:
- The Collect OpenShift info extension section of the Kubernetes pattern discovers the OpenShift components of the Kubernetes deployment. The OpenShift Build Config extension section is available from Store version 1.0.53.
- The Service Mesh extension discovers service mesh details. This information enables the pattern to create service-to-service relations, shown as Connects to::Connected. Service mesh discovery requires deploying Istio on your K8s (Kubernetes) cluster. The Service Mesh extension section is available from Kubernetes extension classes. It’s supported on the ServiceNow AI Platform using the Madrid release or later.
- The Collect Container Repository and extension section finds container registries and images in these registries.
In addition, Discovery uses the Kubernetes Event pattern to discover events for Kubernetes components.
From the 1.0.68 release on ServiceNow Store, Service Mapping can use CI relationships to add the Kubernetes components to application services during tag-based discovery.
Discovery uses the following patterns to discover the entire Kubernetes infrastructure deployed on GCP, AWS, and Azure:
- Google Cloud Platform (GCP) – Get Kubernetes Clusters.
- Amazon AWS Cloud - Get Kubernetes Clusters.
- Microsoft Azure - Get Kubernetes Clusters.
These patterns query the Cloud, collect data on all Kubernetes clusters, and create a serverless schedule for each cluster. When the cluster is deleted, the schedule is marked as inactive. This feature eliminates the overhead of creating and managing multiple credentials and serverless discovery schedules per cluster. The Cloud infrastructure patterns are triggered through standard Cloud discovery.
Starting with Discovery and Service Mapping Patterns version 1.31.0, you can choose to discover Docker image CIs only, without discovering Docker container CIs. Check your entitlements to determine whether you have access to 2026 Container Packaging. For more information, see Disable Docker container CI discovery.
Supported versions
The patterns have been validated with the following Kubernetes and Red Hat OpenShift versions:
| Platform/pattern | Validated version |
|---|---|
| On-Premises Kubernetes | 1.34 |
| Google Kubernetes Engine (GKE) | 1.34 |
| Azure Kubernetes Engine (AKS) | 1.34 |
| Amazon Elastic Kubernetes Service (EKS) | 1.34 |
| Kubernetes Event patterns | 1.34 |
| OpenShift | 4.19.20 |
Request apps on the Store
Visit the ServiceNow Store to view all the available apps, and for information about submitting requests to the store. For cumulative release notes information for all released apps, see the ServiceNow Store version history release notes.
Prerequisites
Note: For prerequisites for Kubernetes Cloud infrastructure discovery, see below.
Note: Running automatic serverless Kubernetes schedules fetches the Bearer token. Adding credentials is unnecessary.
Perform the following steps so that Discovery can use the pattern to successfully find Kubernetes.
- Deploy the latest Discovery and Service Mapping Patterns application from ServiceNow Store.
On the Kubernetes platform, find the parameters to set up Kubernetes discovery:
Find the URL of the kubeapi server:
On the Kubernetes platform, run the following command:
kubectl cluster-infoIn the output, find the line that states the URL of the kubeapi server. For example, Kubernetes control plane is running at
https://10.154.144.146:443
Find the namespaces of the kubeapi server:
On the Kubernetes platform, run this command:
kubectl get namespacesIn the output, find the line that states the namespaces. For example,
kube-system.- Find the Kubernetes username and password:
On the Kubernetes platform, run this command:
kubectl config viewIn the output, find the username and password.
Locate the lines that contain information on password and username.
**Note:** If in a certain environment, `kubectl config view` command is not showing the expected details, use the `supported` command from the Kubernetes admin to fetch the user name and password details.
- Find the valid Bearer token with the proper permissions:
- If you know the default token name, use the command in the following format: `kubectl describe secret <default-token-token name>`.
For example: `kubectl describe secret default-token-g6pwc`.
- If you don't know the default token name, use the command: `kubectl describe secret`.
- Verify that the API Server is reachable from the MID Server for successful Kubernetes discovery.
- Verify that the user configured on the Kubernetes platform has GET permissions to run the following /api/v1 elements:
- https://<url>/api/v1/namespaces/
- https://<url>/api/v1/namespaces/<namespace>
- https://<url>/api/v1/namespaces/kube-system/endpoints/kube-controller-manager
- https://<url>/api/v1/services
- https://<url>/api/v1/pods
- https://<url>/api/v1/nodes
- https://<url>/api/v1/replicationcontrollers
- https://<url>/apis/networking.k8s.io/v1/ingresses
- https://<url>/apis/apps/v1/deployments
- https://<url>/apis/apps/v1/statefulsets
- https://<url>/apis/apps/v1/daemonsets
- https://<url>/apis/apps/v1/replicasets
- https://<url>/apis/batch/v1/cronjobs
- https://<url>/apis/batch/v1/jobs
To discover the OpenShift components of the Kubernetes deployment, verify that the user configured on the Kubernetes platform has GET permissions to run the following /api/v1 elements:
- /apis/apps.openshift.io/v1/deploymentconfigs
- /apis/build.openshift.io/v1/buildconfigs
- /apis/route.openshift.io/v1/routes
- /apis/user.openshift.io/v1/groups
- /apis/user.openshift.io/v1/users
- /apis/project.openshift.io/v1/projects
- /apis/image.openshift.io/v1/images
/apis/image.openshift.io/v1/imagestreams To discover service mesh information:
Deploy Istio on your K8s cluster.
- Provide the Prometheus URL.
- Configure Prometheus to scrape metrics from Istio.
Activate Get Kubernetes Config Files extension to:
Discover configuration files.
- Create tracked configuration files.
- Map the configuration files workloads and services with a relationship. Note: Tracked files content is in the JSON format from version 1.0.92. Tracked files content is in YAML format in version 1.0.91 and earlier.
Create the Kubernetes credentials on the ServiceNow platform:
- On the ServiceNow AI Platform, navigate to All > Discovery > Credentials.
- Select New.
- Select Kubernetes Credentials.
- On the form, fill in the fields.
| Field | Description |
|---|---|
| Name | Unique and descriptive name for this credential. |
| User name | User name associated with this credential. Leading or trailing spaces should be avoided; if any are detected, a warning will appear. Only one authentication method should be used: either a user name and password or a Bearer token. Don't use both. |
| Password | Password associated with this credential. Only one authentication method should be used: either a user name and password or a Bearer token. Don't use both. |
| Bearer Token Authentication | This option enables advanced authentication using a Bearer token. When the check box is selected, the Bearer Token field is displayed. |
| Bearer Token | Discovery uses the Bearer token for advanced authentication when accessing Kubernetes. The Bearer token should be in BASE64 encoded format, using the character sequence as the token. For example: 31ada4fd-adec-460c-809a-9e56ceb75269. Only one authentication method should be used: either a user name and password or a Bearer token. Don't use both. |
| Credential alias | An alias is configured to use the Kubernetes credential for devices and applications other than Kubernetes. This alias is also used when defining a serverless discovery schedule for discovering the Kubernetes deployment.1. Select the padlock icon, and then select the search icon. 2. On the Connection & Credential Aliases form, select New. 3. Specify a name for the credential alias record. 4. Define attributes for the alias. Set the Type to The alias appears in the Credential alias field. |
5. On the Kubernetes credentials form, select **Update**.
Create a serverless discovery schedule for the Kubernetes pattern.
Create and define the serverless execution pattern as described in the product documentation. Configure the parameters required by the Kubernetes pattern as follows:
| Field | Description |
|---|---|
| url | The identifier for the hostname, IP, or FQDN and the port of the Kubernetes apiserver. Use the following format: example\_hostname:example\_port or xample\_ip:example\_port. Provide the correct protocol \(HTTP or HTTPS\) in the URL. |
| namespace | The namespaces that the system passes in the Kubernetes Discovery Configuration. Enter one of the following values:- Individual namespace: enter the namespace and then "kube-system". For example: `dev,kube-system` - The default value: enter `default, kube-system` - Multipile namespaces: enter the namespaces, use a comma \(,\) to separate the values, and then enter "kube-system". For example: `automation,application,test,kube-system` - All namespaces: Use an asterisk \(\*\) to enter all namespaces |
| credentials alias | The alias associated with the previously created Kubernetes credentials. |
| cluster name | The name of the Kubernetes cluster, in the following format: <serviceaccountid><space><clustername>. |
| provider | The cloud provider: GCP or AWS or Azure. |
| cluster\_resource\_id | Cluster resource ID example:- Azure Kubernetes clusters- Resource ID. - AWS- cluster ARN. - GCP- cluster global name. |
Create a serverless discovery schedule for the Kubernetes Event pattern. Configure the schedule to run every 5 or 10 minutes.
Note: When the pattern is run for the first time, it stores an event_timestamp. Later on it collects only the delta events based on the timestamp. The more often the pattern is run, the fewer updates to the CMDB IRE are needed.
Create a serverless execution pattern for the discovery schedule and assign it to the Kubernetes Events pattern. Configure the parameters required by the Kubernetes pattern as described in Configuring execution pattern attributes.
To include discovered components into service instances, enable CI relationships used in tag-based discovery by Service Mapping. These CI relationships are available from the 1.0.68 release on the ServiceNow Store. For operational steps, see Tag-based discovery configuration.
Prerequisites for Kubernetes Cloud infrastructure discovery
For the Google Cloud Platform (GCP) – Get Kubernetes Clusters pattern, perform the following:
- In the ServiceNow instance, set up a Google Cloud Platform (GCP) service account with valid credentials and permissions.
- On the GCP infrastructure, set up the MID Server with full access to all Cloud APIs: Set Cloud API access scopes to "Allow full access to all Cloud APIs". The MID Server instance can access only the Clusters specific to the project.
Navigate to
sys_properties.listand configure the following properties:- sn_itom_pattern.k8s_midserver: Specify a valid MID Server name.
sn_itom_pattern.k8s_create_schedule_enabled: Set the value to true.
Note: Enabling the sn_itom_pattern.k8s_create_schedule_enabled property automatically creates a serverless schedule for your cloud clusters, eliminating the need for manual scheduling. If you have an existing manual schedule and want to convert it to an automatic one, enable the property. Your manual schedule will be updated; no additional schedule will be created.
Create and run Google Cloud Discovery
Note:
To fetch the Bearer token, while running GKE Kubernetes schedule, use the gcloud command:
gcloud config config-helper --format="value(credential.access_token)"Configuring gcloud in the MID Server instance grants access to the GKE cluster to fetch the token.
For the Amazon Elastic Kubernetes Service (EKS) cluster discovery, perform the following:
In the ServiceNow instance, set an AWS service account with valid management account credentials and permissions.
- Verify that the Amazon Elastic Kubernetes Service (EKS) Cluster has a cluster role with the read-only access to all resources.
- Create cluster role binding between the cluster role and a Kubernetes user. For example, read-onlyuser.
- Create an AWS IAM role with the policy EKSReadOnly.
- Associate the IAM role with the Kubernetes user in one of the following ways:
- In the cluster, edit the aws-auth ConfigMap.
Run the command:
eksctl create iamidentitymapping --cluster yourClusterName --arnarn:aws:iam::yourAccountID:role/yourIAMRoleName --username read-only-user
Run Amazon Elastic Kubernetes Service (EKS) cluster discovery in one of two ways: Using the AWS Command Line Interface (CLI) or without using the AWS CLI. First, set the system property sn_itom_pattern.k8s_aws_cli_to_generate_token to use the model you choose. This system property is set to true by default.
Set this system property to true to use AWS CLI to generate a token.
Set this system property to false to use Assume Roles to generate a token.
Run Amazon Elastic Kubernetes Service (EKS) cluster discovery using AWS CLI:
Set up the MID Server with the AWS CLI configured. Configuring AWS CLI credentials grants access to the Amazon Elastic Kubernetes Service (EKS) cluster.
Note: The user logged in to the system must be the same as the MID Server user.
To generate the Bearer token, While running the Amazon Elastic Kubernetes Service (EKS) schedule, use the AWS CLI command:
aws eks get-token --cluster-name <cluster_name>.Configuring the AWS CLI user/role in the MID Server instance grants access to the Amazon Elastic Kubernetes Service (EKS) cluster to generate the token.
Run Amazon Elastic Kubernetes Service (EKS) cluster discovery without using AWS CLI:
Note:
This feature is supported from Discovery and Service Mapping Patterns version 1.0.96 - December 2022.
Refer to the following KB for detailed instructions: KB1182188: EKS cluster discovery using STS AssumeRoles (Without AWS CLI)
Navigate to
sys_properties.listand configure the following properties:- sn_itom_pattern.k8s_midserver: Specify a valid MID Server name.
sn_itom_pattern.k8s_create_schedule_enabled: Set the value to true.
Note: Enabling the sn_itom_pattern.k8s_create_schedule_enabled property automatically creates a serverless schedule for your cloud clusters, eliminating the need for manual scheduling. If you have an existing manual schedule and want to convert it to an automatic one, enable the property. Your manual schedule will be updated; no additional schedule will be created.
Create and run an AWS Cloud Discovery schedule.
For Microsoft Azure Kubernetes Services (AKS)- Kubernetes cluster discovery, perform the following:
- Update to the latest Discovery and Service Mapping Patterns version.
- In the ServiceNow instance, configure the Azure Service Account with valid Azure credentials and permission.
Navigate to
sys_properties.listand configure the following properties:- sn_itom_pattern.k8s_midserver: Specify a valid MID Server name.
sn_itom_pattern.k8s_create_schedule_enabled: Set the value to true.
Note: Enabling the sn_itom_pattern.k8s_create_schedule_enabled property automatically creates a serverless schedule for your cloud clusters, eliminating the need for manual scheduling. If you have an existing manual schedule and want to convert it to an automatic one, enable the property. Your manual schedule will be updated; no additional schedule will be created.
.
If you don't have local accounts with Kubernetes RBAC and want to improve pattern efficiency, navigate to MID Server > Properties and set the sn_itom_pattern.aks_fetch_local_ad_token property to false.
- Run an Azure cloud discovery schedule.
- Configure the MID Server in the Discovery schedules according to the cluster account type. If you don't have Local accounts with RBAC, you can ignore this step.
| Cluster account type | Discovery schedule MID Server | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| MS Entra ID auth with Kubernetes RBAC. | Any MID Server. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MS Entra ID authentication with Azure RBAC. | Any MID Server. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Local accounts with Kubernetes RBAC. | Select the MID Server with the Azure Command Line Interface \(CLI\) configured. Configuring the Azure CLI credentials grants access to the AKS cluster. To fetch the Bearer token while running the AKS Kubernetes schedule, use the Azure CLI command: `az aks get-credentials --name
Note: Kubernetes Credential-less or mid-in-cluster discoveryPrerequisites for Kubernetes Credentials-less discovery: Deploy the containerized MID Server to the Kubernetes cluster. Configuring Kubernetes credentials is unnecessary since the MID Server in Kubernetes cluster automatically discovers the API server and authenticate.
Data collected by Discovery during horizontal discovery
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||