ServiceNow's Kubernetes integration enables IT operations teams to automatically discover Kubernetes clusters, nodes, and pods as Configuration Items in the CMDB, while creating incidents and alerts from cluster events. This integration solves the visibility gap between containerized applications and traditional ITSM processes, helping platform engineering and DevOps teams maintain comprehensive infrastructure governance. The integration supports bi-directional data flows where ServiceNow can both discover Kubernetes resources via API polling and receive real-time events through webhooks, with the primary automation pattern being scheduled discovery jobs and event-driven alerting. This functionality primarily resides in the Discovery module and Event Management, leveraging the Kubernetes spoke in Integration Hub for automated workflows and kubectl command execution.
Prerequisites
- •ServiceNow Tokyo release or later with Integration Hub Professional license
- •Kubernetes cluster with API server accessible from ServiceNow instance or MID Server
- •Kubernetes service account with cluster-admin or custom RBAC permissions for discovery
- •MID Server 2022.04.03 or later if cluster is not publicly accessible
- •Event Management plugin (com.snc.em) activated in ServiceNow instance
- •Discovery plugin (com.snc.discovery) activated with Kubernetes patterns enabled
- •kubectl binary installed on MID Server if using kubectl-based workflows
Architecture Overview
The ServiceNow Kubernetes integration uses the official Kubernetes spoke in Integration Hub along with Discovery patterns to establish connectivity and data synchronization. Authentication is established using Kubernetes service account tokens or kubeconfig files stored as Basic Auth credentials in Connection & Credential Aliases, with the credential payload containing the bearer token or certificate data. Data flows bi-directionally with Discovery jobs polling the Kubernetes API every 24 hours by default to populate CMDB CIs, while real-time events can be pushed to ServiceNow via scripted REST APIs or the Event API. A MID Server is required when Kubernetes clusters are deployed in private networks or behind firewalls, as it provides the network bridge and runs the discovery probes and kubectl commands. The Kubernetes API has no explicit rate limiting by default, but clusters under heavy load may throttle requests, so Discovery schedules should be tuned accordingly to avoid overwhelming cluster API servers.
Sourdough: ServiceNow Monitoring and Analytics
A Chrome extension for ServiceNow Admins and Developers with essential tools, analytics, graphs and monitoring features.
Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.
Implementation Steps
Create Kubernetes service account and extract bearer token
Create a dedicated ServiceNow service account in your Kubernetes cluster with appropriate RBAC permissions for discovery and monitoring. Run kubectl create serviceaccount servicenow-discovery in the default namespace, then create a ClusterRoleBinding to grant cluster-admin or custom read permissions. Extract the service account token using kubectl create token servicenow-discovery --duration=8760h to generate a long-lived token. Copy this token value as you'll need it for ServiceNow credential configuration.
apiVersion: v1
kind: ServiceAccount
metadata:
name: servicenow-discovery
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: servicenow-discovery-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: servicenow-discovery
namespace: defaultConfigure Kubernetes credential in ServiceNow Connection & Credential Aliases
Navigate to Connections & Credentials > Credentials in ServiceNow and create a new Basic Auth credential record. Set the Name field to 'Kubernetes Cluster Token', leave the User name field empty, and paste the extracted bearer token into the Password field. In the Connection tab, create a new Connection Alias pointing to your Kubernetes API server URL (typically https://your-cluster:6443). Verify the credential by testing the connection using the Test Connection button.
Install and configure the Kubernetes spoke in Integration Hub
Navigate to Integration Hub > Browse Spokes and search for the official Kubernetes spoke published by ServiceNow. Install the spoke and configure a new connection using your previously created Connection Alias and credential. The Kubernetes spoke provides actions like 'Get Pods', 'Get Nodes', 'Execute kubectl Command', and 'Create Namespace' that will be used in discovery and automation workflows. Test the spoke connection by creating a simple flow that calls the 'Get Nodes' action to verify API connectivity.
Configure Kubernetes discovery pattern and credentials
Navigate to Discovery > Discovery Definitions and search for 'Kubernetes' patterns. Enable the 'Kubernetes Cluster Discovery' pattern and associate it with your Kubernetes credential from step 2. Configure the discovery to target your cluster's API endpoint and set the discovery schedule to run daily. In the Credentials tab, ensure the Kubernetes credential is selected and the API endpoint URL matches your cluster configuration exactly.
Create CMDB CI classes for Kubernetes resources
Navigate to Configuration > CI Class Manager and verify that Kubernetes CI classes exist: cmdb_ci_kubernetes_cluster, cmdb_ci_kubernetes_node, and cmdb_ci_kubernetes_pod. If missing, create these classes extending from cmdb_ci_computer or cmdb_ci_service as appropriate. Add custom attributes like namespace, labels, resource_version, and cluster_name to capture Kubernetes-specific metadata. These CI classes will store the discovered Kubernetes resources and their relationships.
Set up event management for Kubernetes alerts
Navigate to Event Management > Event Rules and create rules to transform Kubernetes events into ServiceNow incidents or alerts. Configure event parsing rules to extract severity, node name, pod name, and namespace from Kubernetes event JSON payloads. Create an inbound email action or scripted REST API endpoint that Kubernetes monitoring tools like Prometheus AlertManager can POST alerts to. Set up event correlation rules to group related Kubernetes events and prevent alert storms.
var gr = new GlideRecord('em_event');
gr.initialize();
gr.source = 'Kubernetes';
gr.node = event_payload.involvedObject.name;
gr.type = event_payload.type;
gr.severity = event_payload.type == 'Warning' ? 3 : 5;
gr.description = event_payload.message;
gr.additional_info = JSON.stringify(event_payload);
gr.insert();Create kubectl automation workflows using Integration Hub
Navigate to Integration Hub > Flow Designer and create flows that leverage the Kubernetes spoke's 'Execute kubectl Command' action for operational tasks. Design flows for common operations like scaling deployments, restarting pods, or applying configuration changes triggered by ServiceNow catalog requests or incidents. Configure input variables for namespace, resource name, and command parameters to make flows reusable across different clusters. Add error handling and logging to capture kubectl command output and failures in flow execution records.
// In Flow Designer kubectl action script
var command = 'scale deployment ' + fd_data.deployment_name + ' --replicas=' + fd_data.replica_count + ' -n ' + fd_data.namespace;
var result = inputs.u_kubectl_command = command;
outputs.command_result = result;Test discovery and validate CMDB population
Navigate to Discovery > Discovery Status and manually execute the Kubernetes discovery against your cluster to validate the integration. Monitor the discovery logs for any authentication errors or API connectivity issues during the discovery process. Once complete, verify that Kubernetes CIs appear in Configuration > Servers > Computers and check that relationships between clusters, nodes, and pods are correctly established. Review the Discovery Log to ensure all expected resources were discovered and troubleshoot any missing or failed discoveries.
Common Use Cases
Automated CMDB population from Kubernetes clusters
Discovery jobs automatically scan Kubernetes clusters every 24 hours to create and update CMDB Configuration Items for clusters, nodes, pods, and services. This creates a complete inventory view of containerized infrastructure alongside traditional servers and applications. The discovery captures metadata like labels, annotations, resource limits, and namespace information. This enables change management processes to include Kubernetes resources and provides dependency mapping for impact analysis during incidents.
Incident creation from Kubernetes events and alerts
Kubernetes events like pod failures, node not ready states, or resource exhaustion trigger automatic incident creation in ServiceNow. Prometheus AlertManager or other monitoring tools POST alerts to ServiceNow's Event API, which applies parsing and correlation rules. Events are enriched with CMDB CI relationships to identify affected applications and assignment groups. High-priority alerts create Priority 1 incidents while warning-level events create low-priority incidents or are grouped into problem records.
Self-service pod scaling through Service Catalog
ServiceNow catalog items allow developers to request pod scaling, deployment updates, or resource limit changes through standard request fulfillment processes. Integration Hub flows execute kubectl commands on target clusters using the Kubernetes spoke after approval workflows complete. Requests capture business justification, change schedules, and approval requirements before making cluster modifications. The system logs all changes and maintains audit trails linking ServiceNow change records to actual Kubernetes resource modifications.
Kubernetes cluster health monitoring and reporting
Custom dashboard widgets display real-time cluster metrics pulled from the Kubernetes API including node status, pod health, and namespace resource utilization. Scheduled jobs query cluster endpoints and update Performance Analytics metrics for historical trending and capacity planning reports. Automated health checks create warning incidents when clusters approach resource limits or when critical system pods become unhealthy. Executive dashboards show cluster uptime, deployment frequency, and incident trends across the container platform estate.
Change management integration for Kubernetes deployments
Standard and emergency change requests trigger automated Kubernetes deployments through Integration Hub flows that execute kubectl apply commands or Helm chart installations. Change approval workflows include technical reviewers familiar with Kubernetes architecture and security policies. Post-deployment validation includes automated testing and rollback capabilities if health checks fail after changes. Change records maintain complete deployment artifacts, configuration diffs, and links to associated code repositories or container image versions.
Troubleshooting
Discovery failing with 'Connection refused' or timeout errors to Kubernetes API
Check that the MID Server can reach the Kubernetes API endpoint by testing connectivity from the MID Server host using curl or telnet. Verify that the API server URL in the Connection Alias matches exactly including port number (typically 6443). Review MID Server logs in /logs/wrapper.log for DNS resolution failures or network routing issues. Ensure firewall rules allow outbound HTTPS traffic from MID Server to Kubernetes API server and that any corporate proxy configuration is properly set in the MID Server parameters.
Authentication errors or 'Unauthorized' responses during discovery
Validate that the service account token stored in ServiceNow credentials is still valid and hasn't expired by testing it directly with kubectl commands. Check the RBAC permissions for the servicenow-discovery service account using kubectl auth can-i --list --as=system:serviceaccount:default:servicenow-discovery to ensure cluster-admin or sufficient read permissions. Review the Kubernetes credential configuration in ServiceNow to confirm the bearer token is correctly stored in the Password field with no extra whitespace or formatting characters.
Kubernetes CIs not appearing in CMDB after successful discovery
Navigate to Discovery > Discovery Log and review the payload data to confirm that Kubernetes resources are being detected and processed during discovery runs. Check that the required CI classes (cmdb_ci_kubernetes_cluster, cmdb_ci_kubernetes_node, cmdb_ci_kubernetes_pod) exist in the CMDB Class Manager and have proper inheritance relationships. Verify that discovery transform maps are correctly parsing Kubernetes API responses and populating CI attributes by examining the transform map logs for any field mapping errors or data validation failures.
Integration Hub flows failing with kubectl command errors
Ensure kubectl binary is installed and properly configured on the MID Server by logging into the MID Server host and running kubectl version to verify installation. Check that the kubeconfig file or service account credentials are accessible to the MID Server service account and have not expired or been revoked. Review flow execution logs in Integration Hub to identify the specific kubectl command that's failing and test the same command manually on the MID Server to isolate whether the issue is with command syntax or cluster connectivity.
Events from Kubernetes not creating incidents or alerts in Event Management
Verify that the Event Management plugin is activated and event processing rules are correctly configured to parse Kubernetes event JSON payloads. Check the event registration table (em_event) to confirm that events are being received but may be filtered out by correlation or suppression rules. Review the inbound web service or email action that receives Kubernetes events to ensure authentication is working and payloads are being accepted. Test event creation manually by POSTing a sample Kubernetes event payload to the Event API endpoint to isolate processing rule issues.
Discovery performance issues or timeouts with large Kubernetes clusters
Adjust discovery performance parameters in the MID Server configuration to increase timeout values and concurrent thread limits for handling large API responses. Consider implementing namespace-based discovery filtering to reduce the scope of each discovery run by targeting specific namespaces rather than entire clusters. Monitor Kubernetes API server metrics during discovery runs to identify if rate limiting or resource constraints are causing response delays, and adjust discovery schedules to run during off-peak hours to minimize cluster impact.
Pro Tips
- →Implement namespace-based RBAC in your Kubernetes clusters and create separate ServiceNow credentials for different namespaces to provide granular access control and support multi-tenancy requirements. This allows different ServiceNow assignment groups to manage their own Kubernetes resources without accessing other teams' workloads.
- →Use ServiceNow's Configuration Compliance to automatically scan Kubernetes resources for security policy violations like pods running as root, missing resource limits, or deprecated API versions. Create compliance rules that trigger change requests when non-compliant resources are detected during discovery runs.
- →Configure custom event correlation rules in Event Management to group related Kubernetes events (like all pods failing in a namespace) into single incidents to prevent alert storms. Use time-based correlation windows and event deduplication based on cluster, namespace, and error message patterns to reduce noise.
- →Leverage ServiceNow's REST API to build custom Kubernetes operators that can create ServiceNow records from within cluster workloads, enabling applications to automatically generate incidents, change requests, or configuration items based on application-specific events and metrics.
- →Set up automated Performance Analytics metrics collection from Kubernetes clusters by scheduling Integration Hub flows that query resource usage APIs and populate custom metrics tables. This enables capacity planning dashboards and predictive scaling recommendations based on historical usage patterns.
- →Implement GitOps workflows where ServiceNow change requests automatically update Git repositories containing Kubernetes manifests, triggering ArgoCD or Flux deployments. This maintains ServiceNow change control while enabling cloud-native deployment practices and audit trails.
Known Limitations
- —The Kubernetes spoke requires Integration Hub Professional licensing, which may not be available in all ServiceNow licensing tiers and represents an additional cost for organizations using the Standard Integration Hub. Custom REST message implementations can provide basic functionality but lack the pre-built actions and error handling of the official spoke.
- —Discovery performance can be significantly impacted when scanning large Kubernetes clusters with thousands of pods, as the API responses may exceed ServiceNow's default payload size limits and cause timeout errors. Large clusters may require custom discovery patterns with namespace filtering to reduce scope and improve reliability.
- —Real-time event integration depends on external monitoring tools like Prometheus AlertManager to transform native Kubernetes events into ServiceNow-compatible formats, as Kubernetes doesn't natively support webhook notifications to external systems. This requires additional infrastructure and monitoring tool configuration beyond the basic ServiceNow integration.
- —The integration cannot automatically detect or remediate split-brain scenarios where Kubernetes resources exist in clusters but are missing from the ServiceNow CMDB due to discovery failures or cluster connectivity issues. Manual reconciliation processes may be required to maintain data consistency between systems.
- —Kubectl-based automation workflows through Integration Hub require MID Server deployment and may introduce security concerns if kubectl commands allow destructive operations without proper approval workflows and change management controls integrated into the flow design.
Frequently Asked Questions
Can ServiceNow discover Kubernetes resources across multiple clusters in different environments?
Yes, ServiceNow supports multi-cluster discovery by creating separate Connection Aliases and credentials for each Kubernetes cluster, then configuring individual discovery schedules for each environment. You can create different discovery definitions targeting dev, test, and production clusters with appropriate credentials and discovery patterns. Use the cluster_name attribute in CMDB CIs to distinguish resources from different clusters and configure separate assignment groups and approval workflows based on cluster environment classification.
How does ServiceNow handle Kubernetes resources that are created and destroyed frequently like job pods?
ServiceNow discovery can be configured to handle ephemeral resources by adjusting the CI lifecycle and staleness detection settings in the discovery patterns. Short-lived resources like job pods will create CMDB CIs during discovery but will be marked as 'retired' in subsequent discovery runs when they no longer exist in the cluster. You can configure data retention policies to automatically delete retired Kubernetes CIs after a specified period to prevent CMDB bloat from temporary resources while maintaining historical change tracking.
What's the best practice for managing ServiceNow credentials when Kubernetes service account tokens rotate?
Implement automated credential rotation by creating long-lived service account tokens (8760 hours or 1 year) and setting up monitoring alerts when tokens are approaching expiration. Alternatively, use Kubernetes service account token auto-rotation with a script that updates ServiceNow credentials via REST API when new tokens are generated. Store backup credentials and implement failover logic in Integration Hub flows to automatically switch to secondary credentials if primary authentication fails during discovery or automation workflows.
Can ServiceNow create Kubernetes resources like namespaces or deployments through the integration?
Yes, the Kubernetes spoke in Integration Hub provides actions to create, update, and delete Kubernetes resources including namespaces, deployments, services, and config maps. These actions can be incorporated into ServiceNow catalog items, change request fulfillment workflows, or automated remediation flows triggered by incidents. Implement proper approval workflows and change management processes around resource creation to maintain governance while enabling self-service capabilities for development teams through ServiceNow's standard request fulfillment processes.
How can I integrate Kubernetes logs and metrics into ServiceNow for troubleshooting?
While ServiceNow doesn't directly ingest Kubernetes logs, you can configure Integration Hub flows to query logging systems like Elasticsearch or Splunk and attach relevant log excerpts to incident records when Kubernetes-related incidents are created. For metrics, create scheduled flows that query Prometheus or other metrics systems and populate ServiceNow Performance Analytics tables for trending and dashboard visualization. Use the incident correlation functionality to automatically enrich Kubernetes incidents with contextual metrics and logs from the time period when issues occurred.
What happens if the MID Server loses connectivity to Kubernetes clusters during discovery?
ServiceNow discovery will mark the affected discovery schedule as failed and generate discovery error records that can trigger notification to administrators. Existing CMDB CIs from previous successful discoveries remain unchanged and are not deleted due to single discovery failures. Configure discovery retry policies and multiple MID Servers in different network zones for high availability, and set up automated incident creation when discovery schedules fail consecutively to ensure prompt remediation of connectivity issues that could impact CMDB accuracy.
How do I handle Kubernetes RBAC and security when integrating with ServiceNow?
Create dedicated ServiceNow service accounts with minimal required permissions using Kubernetes RBAC policies that grant only the specific API access needed for discovery and automation workflows. Implement namespace-based access controls where different ServiceNow credentials have permissions only to specific namespaces corresponding to application teams or environments. Store sensitive credentials using ServiceNow's credential encryption capabilities and regularly audit service account permissions to ensure they align with principle of least privilege and organizational security policies.
Test Your Knowledge
Quick 3-question quiz — see how your ServiceNow skills stack up.
A list view on a table with millions of records is slow. Best fix?
Select an answer to continue