turbot/kubernetes
steampipe plugin install kubernetes

Table: kubernetes_node - Query Kubernetes Nodes using SQL

Kubernetes Nodes are the worker machines that run containerized applications and other workloads. Nodes include the necessary services to run Pods (the smallest and simplest unit in the Kubernetes object model that you create or deploy) and are managed by the master components. The services on a node include the container runtime, kubelet and kube-proxy.

Table Usage Guide

The kubernetes_node table provides insights into the Nodes within Kubernetes. As a DevOps engineer, explore node-specific details through this table, including its status, capacity, and allocatable resources. Utilize it to uncover information about nodes, such as the number of pods that can be scheduled for execution on the Node, the amount of CPU and memory resources available, and the overall status of the Node.

Examples

Basic Info

Assess the elements within your Kubernetes nodes to gain insights into their creation time, capacity, and associated addresses. This query is beneficial for understanding your nodes' infrastructure and helps in efficient resource allocation and management.

select
name,
pod_cidr,
pod_cidrs,
provider_id,
creation_timestamp,
addresses,
capacity
from
kubernetes_node;
select
name,
pod_cidr,
pod_cidrs,
provider_id,
creation_timestamp,
addresses,
capacity
from
kubernetes_node;

List conditions for node

This example demonstrates how to analyze the status and conditions of nodes within a Kubernetes system. It's useful for maintaining system health and troubleshooting, as it enables users to track node conditions over time and identify potential issues based on changes in status or the occurrence of specific conditions.

select
name,
cond ->> 'type' as type,
lower(cond ->> 'status') :: bool as status,
(cond ->> 'lastHeartbeatTime') :: timestamp as last_heartbeat_time,
(cond ->> 'lastTransitionTime') :: timestamp as last_transition_time,
cond ->> 'reason' as reason,
cond ->> 'message' as message
from
kubernetes_node,
jsonb_array_elements(conditions) as cond
order by
name,
status desc;
select
name,
json_extract(cond.value, '$.type') as type,
lower(json_extract(cond.value, '$.status')) = 'true' as status,
datetime(json_extract(cond.value, '$.lastHeartbeatTime')) as last_heartbeat_time,
datetime(json_extract(cond.value, '$.lastTransitionTime')) as last_transition_time,
json_extract(cond.value, '$.reason') as reason,
json_extract(cond.value, '$.message') as message
from
kubernetes_node,
json_each(conditions) as cond
order by
name,
status desc;

Get system info for nodes

Explore the system information for specific nodes to gain insights into machine specifications, operating system details, and various versions of installed software. This could be beneficial for troubleshooting, system audits, or understanding the overall system configuration.

select
name,
node_info ->> 'machineID' as machine_id,
node_info ->> 'systemUUID' as systemUUID,
node_info ->> 'bootID' as bootID,
node_info ->> 'kernelVersion' as kernelVersion,
node_info ->> 'osImage' as osImage,
node_info ->> 'operatingSystem' as operatingSystem,
node_info ->> 'architecture' as architecture,
node_info ->> 'containerRuntimeVersion' as containerRuntimeVersion,
node_info ->> 'kubeletVersion' as kubeletVersion,
node_info ->> 'kubeProxyVersion' as kubeProxyVersion
from
kubernetes_node;
select
name,
json_extract(node_info, '$.machineID') as machine_id,
json_extract(node_info, '$.systemUUID') as systemUUID,
json_extract(node_info, '$.bootID') as bootID,
json_extract(node_info, '$.kernelVersion') as kernelVersion,
json_extract(node_info, '$.osImage') as osImage,
json_extract(node_info, '$.operatingSystem') as operatingSystem,
json_extract(node_info, '$.architecture') as architecture,
json_extract(node_info, '$.containerRuntimeVersion') as containerRuntimeVersion,
json_extract(node_info, '$.kubeletVersion') as kubeletVersion,
json_extract(node_info, '$.kubeProxyVersion') as kubeProxyVersion
from
kubernetes_node;

Node IP info

Gain insights into the distribution of internal and external IP addresses, as well as hostnames and internal DNS, across your Kubernetes nodes. This can help in managing network configurations and troubleshooting connectivity issues.

select
name,
jsonb_path_query_array(
addresses,
'$[*] ? (@.type == "ExternalIP").address'
) as public_ips,
jsonb_path_query_array(
addresses,
'$[*] ? (@.type == "InternalIP").address'
) as internal_ips,
jsonb_path_query_array(
addresses,
'$[*] ? (@.type == "InternalDNS").address'
) as internal_dns,
jsonb_path_query_array(
addresses,
'$[*] ? (@.type == "Hostname").address'
) as hostnames
from
kubernetes_node;
Error: The corresponding SQLite query is unavailable.

List manifest resources

Explore which Kubernetes nodes have a specified path, providing insights into the distribution of resources across your infrastructure. This can help optimize resource allocation and ensure balanced workload distribution.

select
name,
pod_cidr,
pod_cidrs,
provider_id,
addresses,
capacity,
path
from
kubernetes_node
where
path is not null;
select
name,
pod_cidr,
pod_cidrs,
provider_id,
addresses,
capacity,
path
from
kubernetes_node
where
path is not null;

Schema for kubernetes_node

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
addressesjsonbEndpoints of daemons running on the Node.
allocatablejsonbAllocatable represents the resources of a node that are available for scheduling. Defaults to capacity.
annotationsjsonbAnnotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata.
capacityjsonbCapacity represents the total resources of a node.
conditionsjsonbList of current observed node conditions.
configjsonbStatus of the config assigned to the node via the dynamic Kubelet config feature.
config_sourcejsonbThe source to get node configuration from.
context_nametextKubectl config context name.
creation_timestamptimestamp with time zoneCreationTimestamp is a timestamp representing the server time when this object was created.
daemon_endpointsjsonbSet of ids/uuids to uniquely identify the node.
deletion_grace_period_secondsbigintNumber of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set.
deletion_timestamptimestamp with time zoneDeletionTimestamp is RFC 3339 date and time at which this resource will be deleted.
end_linebigintThe path to the manifest file.
finalizersjsonbMust be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed.
generate_nametextGenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided.
generationbigintA sequence number representing a specific generation of the desired state.
imagesjsonbList of container images on this node.
labelsjsonbMap of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services.
nametextName of the object. Name must be unique within a namespace.
node_infojsonbList of container images on this node.
owner_referencesjsonbList of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.
pathtextThe path to the manifest file.
phasetextThe recently observed lifecycle phase of the node.
pod_cidrcidrPod IP range assigned to the node.
pod_cidrsjsonbList of the IP ranges assigned to the node for usage by Pods.
provider_idtextID of the node assigned by the cloud provider in the format: <ProviderName>://<ProviderSpecificNodeID>.
resource_versiontextAn opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed.
source_typetextThe source of the resource. Possible values are: deployed and manifest. If the resource is fetched from the spec file the value will be manifest.
sp_connection_nametextSteampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
start_linebigintThe path to the manifest file.
tagsjsonbA map of tags for the resource. This includes both labels and annotations.
taintsjsonbList of the taints attached to the node to has the "effect" on pod that does not tolerate the Taint
titletextTitle of the resource.
uidtextUID is the unique in time and space value for this object.
unschedulablebooleanUnschedulable controls node schedulability of new pods. By default, node is schedulable.
volumes_attachedjsonbList of volumes that are attached to the node.
volumes_in_usejsonbList of attachable volumes in use (mounted) by the node.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- kubernetes

You can pass the configuration to the command with the --config argument:

steampipe_export_kubernetes --config '<your_config>' kubernetes_node