marmotdata/kubernetes
Discover namespaces, services, workloads, and cron jobs from self-managed Kubernetes clusters
The Kubernetes plugin discovers namespaces, services, deployments, stateful sets, cron jobs, and pods from Kubernetes clusters. Each resource kind can be toggled on or off, and discovery can be scoped to specific namespaces or a label selector.
Discovered resources are linked together: namespaces contain their resources, services link to the deployments and stateful sets they expose (matched by selector), and workloads link to their pods (matched by owner references). Cron jobs come with run history built from their recent job runs, so the catalog shows whether the nightly pipeline actually succeeded. When cluster_name is set, a Cluster asset is created as the root of the tree.
Pods are not discovered by default because they are short-lived and can flood the catalog; enable discover_pods when pod-level visibility is worth the churn. One-off Jobs are never cataloged for the same reason; only jobs owned by a cron job are used, as run history.
Prerequisites
The plugin needs read access to the resources it discovers. When running inside a cluster, bind a role like this to the service account Marmot runs as:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: marmot-discovery
rules:
- apiGroups: [""]
resources: ["namespaces", "services", "pods"]
verbs: ["get", "list"]
- apiGroups: ["apps"]
resources: ["deployments", "statefulsets", "replicasets"]
verbs: ["get", "list"]
- apiGroups: ["batch"]
resources: ["cronjobs", "jobs"]
verbs: ["get", "list"]
Managed clusters
This plugin is for self-managed and on-prem clusters. For managed clusters that authenticate with cloud IAM, use the dedicated plugins, which reuse this plugin's discovery engine:
- Amazon EKS: the EKS plugin
- Google GKE: the GKE plugin
Authentication
The plugin supports three authentication methods:
- In-cluster: when Marmot runs inside Kubernetes and no connection settings are provided, the pod's service account is used automatically. The projected token is rotated automatically, so there is nothing to refresh.
- Kubeconfig:
$KUBECONFIGor~/.kube/configis used when Marmot runs somewhere kubectl already works. Setkubeconfig_pathandcontextto pick a specific file and context. - Direct token: set
host,token, andca_certificateto connect to any cluster with a service account token.
Connecting with a service account token
Create a service account bound to the read-only role above and mint a token for it:
kubectl create serviceaccount marmot-discovery
kubectl create clusterrolebinding marmot-discovery \
--clusterrole=marmot-discovery --serviceaccount=default:marmot-discovery
kubectl create token marmot-discovery --duration=48h
Tokens expire
kubectl create token mints a time-bounded token, and the API server caps the lifetime (often 48h) regardless of the --duration you request, so a scheduled ingest will start failing once it expires. For unattended discovery, prefer in-cluster auth (its token is rotated automatically), or rotate the token on a schedule. A long-lived token can be created with a kubernetes.io/service-account-token Secret, but that is discouraged upstream and disabled on some clusters.
Then give the plugin the cluster endpoint, the token, and the cluster's CA certificate. The connection fields go in the same config as the discovery options, not a separate file:
host: "https://mycluster.example.com:6443"
token: "${K8S_SA_TOKEN}"
ca_certificate: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
cluster_name: "prod"
namespaces:
- "payments"
- "orders"
discover_pods: false
tags:
- "kubernetes"
- "${labels.team}"
In the UI
Point and click, no config file needed.
- Open Runs and choose Create pipeline.
- Pick Kubernetes from the plugin list.
- Fill in the settings, set a schedule and save.
With the CLI
Save a YAML config, then run marmot ingest.
Not using plugins? Other ways to populate Marmot
Configuration
Fields marked Required must be set.
tagsList of textTags to apply to discovered assets
external_linksList of groupsExternal links to show on all assets
nameTextDisplay name for the link
iconTextIcon identifier for the link
urlTextURL to the external resource
filterGroup of settingsFilter discovered assets by name (regex)
includeList of textInclude patterns for resource names (regex)
excludeList of textExclude patterns for resource names (regex)
zoneTextTells this system apart from others of the same technology and becomes part of every asset's MRN
cluster_nameTextCluster name to prefix asset names with
namespacesList of textNamespaces to discover. Empty or ["*"] means all namespaces
exclude_namespacesList of textNamespaces to skip when discovering all namespaces
label_selectorTextOnly discover namespaced resources matching this label selector (e.g. team=data)
discover_namespacesYes or noDiscover namespaces
discover_servicesYes or noDiscover services
discover_deploymentsYes or noDiscover deployments
discover_statefulsetsYes or noDiscover stateful sets
discover_cronjobsYes or noDiscover cron jobs, with their recent job runs as run history
discover_podsYes or noDiscover pods. Off by default because pods are short-lived and can flood the catalog
labels_to_metadataYes or noInclude resource labels in asset metadata
annotations_to_metadataYes or noInclude resource annotations in asset metadata
kubeconfig_pathTextKubeconfig path. Defaults to in-cluster, then $KUBECONFIG
contextTextKubeconfig context. Defaults to the current context
hostTextAPI server URL for direct token authentication
tokenSecretBearer token, typically a service account token
ca_certificateTextPEM-encoded CA certificate of the API server
Assets emitted
Metadata this plugin attaches to each discovered asset.
Cluster
Kubernetes cluster metadata fields
Namespace
Kubernetes namespace metadata fields
Service
Kubernetes service metadata fields
Deployment
Kubernetes deployment metadata fields
Stateful Set
Kubernetes stateful set metadata fields
Cron Job
Kubernetes cron job metadata fields
Pod
Kubernetes pod metadata fields