kubernetes

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

README

kubernetes

Extract infrastructure topology metadata from a Kubernetes cluster.

Usage

source:
  name: kubernetes
  scope: my-cluster
  config:
    kubeconfig: ~/.kube/config
    namespaces:
      - default
      - production
    extract:
      - namespaces
      - deployments
      - services
      - jobs
    exclude:
      - kube-system
      - kube-public

Config

Key Type Required Default Description
kubeconfig string No Auto-detected Path to kubeconfig file. Falls back to KUBECONFIG env, in-cluster config, then ~/.kube/config.
namespaces []string No All namespaces Namespaces to extract from.
extract []string No ["namespaces", "deployments", "services", "jobs"] Resource types to extract. Pods excluded by default.
exclude []string No Namespaces to exclude from extraction.

Entities

namespace

Kubernetes namespace.

Property Description
labels Namespace labels
status Namespace phase (Active, Terminating)
created_at Creation timestamp
deployment

Kubernetes deployment.

Property Description
namespace Namespace name
replicas Desired replica count
ready_replicas Ready replica count
strategy Deployment strategy (RollingUpdate, Recreate)
containers List of container name/image pairs
labels Deployment labels
created_at Creation timestamp
service

Kubernetes service.

Property Description
namespace Namespace name
type Service type (ClusterIP, NodePort, LoadBalancer)
cluster_ip Cluster IP address
ports List of port configurations
selector Label selector
labels Service labels
created_at Creation timestamp
job

Kubernetes job.

Property Description
namespace Namespace name
completions Desired completions
active Active pod count
succeeded Succeeded pod count
failed Failed pod count
labels Job labels
created_at Creation timestamp

Edges

From To Type Description
deployment namespace belongs_to Deployment belongs to a namespace
service namespace belongs_to Service belongs to a namespace
job namespace belongs_to Job belongs to a namespace

Authentication

The extractor supports three authentication methods, tried in order:

  1. Explicit kubeconfig — set kubeconfig in config
  2. In-cluster — uses service account token at /var/run/secrets/kubernetes.io/serviceaccount/token
  3. Default kubeconfig~/.kube/config

Both bearer token and client certificate authentication from kubeconfig are supported.

Contribute

Refer to the contribution guidelines for information on contributing to this module.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the Kubernetes REST API.

func NewClient

func NewClient(kubeconfigPath string) (*Client, error)

NewClient creates a client from kubeconfig or in-cluster config.

func (*Client) ListDeployments

func (c *Client) ListDeployments(ctx context.Context, namespace string) (map[string]any, error)

func (*Client) ListJobs

func (c *Client) ListJobs(ctx context.Context, namespace string) (map[string]any, error)

func (*Client) ListNamespaces

func (c *Client) ListNamespaces(ctx context.Context) (map[string]any, error)

func (*Client) ListPods

func (c *Client) ListPods(ctx context.Context, namespace string) (map[string]any, error)

func (*Client) ListServices

func (c *Client) ListServices(ctx context.Context, namespace string) (map[string]any, error)

type Config

type Config struct {
	Kubeconfig string   `mapstructure:"kubeconfig"`
	Namespaces []string `mapstructure:"namespaces"`
	Extract    []string `mapstructure:"extract" validate:"omitempty,dive,oneof=namespaces deployments services pods jobs"`
	Exclude    []string `mapstructure:"exclude"`
}

type Extractor

type Extractor struct {
	plugins.BaseExtractor
	// contains filtered or unexported fields
}

func New

func New(logger log.Logger) *Extractor

func (*Extractor) Extract

func (e *Extractor) Extract(ctx context.Context, emit plugins.Emit) error

func (*Extractor) Init

func (e *Extractor) Init(ctx context.Context, config plugins.Config) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL