Kubernetes leader node detection in Discovery on OpenShift clustersSummary<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } .kb-wrapper { font-family: 'Lato', sans-serif; font-size: 12pt; line-height: 1.7; color: #1d1d1d; max-width: 100%; } .kb-wrapper h3 { font-family: 'Lato', sans-serif; font-size: 12pt; font-weight: 900; color: #032D42; border-bottom: 2px solid #e8fce4; padding-bottom: 4px; margin-top: 20px; margin-bottom: 8px; } .kb-wrapper p { margin: 0 0 12px 0; } .kb-wrapper code { background-color: #e6f0f5; color: #032D42; border: 1px solid #b8cfd8; border-radius: 3px; padding: 1px 5px; font-family: 'Courier New', Courier, monospace; font-size: 11pt; } .kb-wrapper pre { background-color: #e6f0f5; color: #032D42; border: 1px solid #b8cfd8; border-radius: 4px; padding: 12px 16px; overflow-x: auto; margin: 12px 0; } .kb-wrapper pre code { background: none; border: none; padding: 0; font-size: 11pt; } .kb-wrapper ul { margin: 0 0 12px 0; padding-left: 24px; } .kb-wrapper li { margin-bottom: 4px; } This article describes how ServiceNow Discovery identifies the Kubernetes leader node using the Kubernetes Leader library, and explains the endpoint path differences between standard Kubernetes and Red Hat OpenShift clusters. The Kubernetes pattern references the Kubernetes Leader library to determine the primary node in a cluster. Steps 9.2 and 9.3 of this library query the kube-controller-manager endpoint to identify which node holds the leader role. Standard Kubernetes and OpenShift namespace paths Standard Kubernetes clusters expose the controller-manager endpoint in the kube-system namespace: /api/v1/namespaces/kube-system/endpoints/kube-controller-manager Red Hat OpenShift clusters use a different namespace for this endpoint: /api/v1/namespaces/openshift-kube-controller-manager/endpoints/kube-controller-manager Beginning with the fix delivered in PRB1968741, step 9.3 in the Kubernetes Leader library provides a failover path for OpenShift. If step 9.2 returns a 404 error because the kube-system namespace does not contain the kube-controller-manager endpoint, Discovery retries the query using the OpenShift namespace path. Expected API response When the endpoint is present, the API response includes a metadata block that identifies the endpoint name and namespace. The following example shows the expected structure: "metadata": { "name": "kube-controller-manager", "namespace": "kube-system" } Verifying that the endpoint exists To confirm whether the kube-controller-manager endpoint exists in the kube-system namespace, you can test by editing the command in step 9.2 to list the endpoints: namespaces/kube-system/endpoints Alternatively, launch the same API request via POSTMAN: If the response does not include an entry named kube-controller-manager, the 404 error returned by step 9.2 is expected. Discovery then falls over to step 9.3 to query the OpenShift namespace path. When the endpoint is absent from both namespaces A Kubernetes endpoint object stores the IP addresses of pods behind a Service. If no Service is configured to expose the kube-controller-manager, Kubernetes does not create an endpoint object, and both step 9.2 and step 9.3 return 404 errors. If the endpoint is absent from both namespace paths, verify that a Service is configured in your cluster to expose the kube-controller-manager. Check your Kubernetes cluster configuration to confirm this setup.