Skip to main content

Kubernetes

The kubernetes config type scrapes the configurations of your Kubernetes resources as specified with the fields; namespace, selector, fieldSelector and more.

kubernetes-scraper.yaml
apiVersion: configs.flanksource.com/v1
kind: ScrapeConfig
metadata:
name: kubernetes-scraper
spec:
kubernetes:
- clusterName: local-kind-cluster
exclusions:
- Secret
- ReplicaSet
- APIService
- endpoints.discovery.k8s.io
- endpointslices.discovery.k8s.io
- leases.coordination.k8s.io
- podmetrics.metrics.k8s.io
- nodemetrics.metrics.k8s.io
- customresourcedefinition
- controllerrevision
- certificaterequest
- orders.acme.cert-manager.io
event:
exclusions:
- SuccessfulCreate
- Created
- DNSConfigForming
severityKeywords:
error:
- failed
- error
warn:
- backoff
- nodeoutofmemory

Scraper

FieldDescriptionSchemeRequired
logLevelSpecify the level of logging.string
scheduleSpecify the interval to scrape in cron format. Defaults to every 60 minutes.string
retentionSettings for retaining changes, analysis and scraped itemsRetention
kubernetesSpecifies the list of Kubernetes configurations to scrape.[]Kubernetes

Kubernetes

FieldDescriptionSchemeRequired
allowIncompleteShow partial results when fetching of API resources failsbool
clusterNameSpecify cluster namestring
eventSpecify configuration to handle Kubernetes events.Event
exclusionsSpecify Kubernetes resources to be excluded from scraping[]string
fieldSelectorSpecify Kubernetes resource based on value of resource fields. e.g status.Phase=Runningstring
kubeconfigSpecify kubeconfig for access to your Kubernetes Cluster[]EnvVar
maxInFlightrestrict parallelism to X inflight requestsint64
namespaceSpecify namespace for scraping of Kubernetes resourcesstring
relationshipsCreate relationships between kubernetes objects.[]Relationship
scopeSpecify scope for scrape. e.g cluster for scraping at Cluster levelstring
selectorSpecify Kubernetes resource to scrape based on selector. e.g matchLabelsstring
sinceSet time constraint for scraping resources within the set periodstring
useCacheSpecify boolean value to toggle fetching results from Kube-apiserver or fetch response from etcdbool
propertiesCustom templatable properties for the scraped config items.[]ConfigProperty
transformField to transform resultTransform
tagsset custom tags on the scraped config itemsmap[string]string

Transform

FieldDescriptionSchemeRequired
gotemplateGo template to transform the scraped config itemstring
javascriptJavascript to transform the scraped config itemstring
jsonpathSpecify JSONPathjsonpath
exprSpecify Cel expressioncel-expression
changesApply transformation on the scraped changes[]Changes
excludeFields to remove from the config, useful for removing sensitive data and fields that change often without a material impact i.e. Last Scraped Time[]Exclude
maskSpecify configurations to replace sensitive fields with hash functions or static string.[]Mask
relationshipForm relationships between config items using selectors[]RelationshipConfig
info

Both the go template and javascript receive ScrapeResult as the template variable.

Events

Config DB maps Kubernetes Event objects to config changes unlike other objects that are mapped to config items. This configuration allows you to exclude or include the Kubernetes Event objects based on the reason.

In addition, you can also specify keywords used to identify the severity of the Kubernetes Event based on the reason.

FieldDescriptionSchemeRequired
exclusionsA list of keywords used to exclude event objects based on the reason[]string
severityKeywordsSpecify keywords used to identify the severity of the Kubernetes Event based on the reasonSeverityKeywords

SeverityKeywords

FieldDescriptionSchemeRequired
warnA list of keywords used to identify a warning severity from the reason. It could also be a match pattern: example "*" to match all or "!badword" to exclude "badword"[]string
errorSame as warn but used to map to error severity.[]string

Kubernetes Relationship

You can create relationships between kubernetes objects on the basis of kind, name and labels. While relationships between node and pod, deployment and pod, namespace and deployment are created automatically, there are cases where we want to link objects on the basis of metadata (like linking resources created by a flux object to it). See Example.

We support static values, expressions and label lookups to find the parent

FieldDescriptionSchemeRequired
kindkind of Kubernetes ObjectRelationshipLookuptrue
namename of Kubernetes ObjectRelationshipLookuptrue
namespacenamespace of Kubernetes ObjectRelationshipLookuptrue
Relationship Lookup

RelationshipLookup offers different ways to specify a lookup value

FieldDescriptionSchemeRequired
exprUse an expression to get the valuestring
valueSpecify a static valuestring
labelGet the value from a labelstring