k8s-inventory

by Anchore

Helm chartv0.7.3App 1.8.7

A Helm chart for Kubernetes Automated Inventory, which describes which images are in use in a given Kubernetes Cluster

About this chart

K8s Inventory Helm Chart

Note: this integration requires a valid license or subscription entitlement from Anchore

K8s Inventory is the foundation of Anchore Enterprise's Runtime Inventory feature. Running K8s Inventory via Helm is a great way to retrieve your Kubernetes Image inventory without providing Cluster Credentials to Anchore. The minimum version of the Anchore Enterprise platform required for K8s Inventory is 4.7.

K8s Inventory runs as a read-only service account in the cluster it's deployed to.

In order to report the inventory to Anchore, K8s Inventory does require authentication material for your Anchore Enterprise deployment. K8s Inventory's helm chart automatically creates a kubernetes secret for the Anchore Password based on the values file you use, Ex.:

k8sInventory:
    anchore:
        password: foobar

It will set the following environment variable based on this: ANCHORE_K8S_INVENTORY_ANCHORE_PASSWORD=foobar.

If you don't want to store your Anchore password in the values file, you can create your own secret to do this:

apiVersion: v1
kind: Secret
metadata:
  name: k8s-inventory-anchore-password
type: Opaque
stringData:
  ANCHORE_K8S_INVENTORY_ANCHORE_PASSWORD: foobar

and then provide it to the helm chart via the values file:

useExistingSecret: true
existingSecretName: k8s-inventory-anchore-password

You can install the chart via via:

helm repo add anchore https://charts.anchore.io
helm install <release-name> -f <values.yaml> anchore/k8s-inventory

A basic values file can always be found here

The key configurations are in the k8sInventory.anchore section. K8s Inventory must be able to resolve the Anchore URL and requires API credentials.

Note: the Anchore API Password can be provided via a kubernetes secret, or injected into the environment of the K8s Inventory container

  • For injecting the environment variable, see: injectSecretsViaEnv
  • For providing your own secret for the Anchore API Password, see: useExistingSecret. K8s Inventory creates it's own secret based on your values.yaml file for key k8sInventory.anchore.password, but the k8sInventory.useExistingSecret key allows you to create your own secret and provide it in the values file.

See the K8s Inventory repo for more information about the K8s Inventory specific configuration

Image Registry

The chart's image is a set of parts rather than one string:

image:
  registry: ""            # empty -> taken from global.imageRegistryHost
  repository: anchore/k8s-inventory
  tag: "vX.Y.Z"

The registry is chosen from three levels, most specific first:

LevelWhereWins over
1. Per-image registryimage.registryeverything below
2. global.imageRegistryHostone value for the whole chartthe chart defaults
3. Chart defaultdocker.io—

Stated as one rule:

An image value that states no registry of its own takes one from global.imageRegistryHost. An image value that does state one keeps it.

To mirror the image, set the global once:

global:
  imageRegistryHost: harbor.example.com

Only the registry comes from the global — the repository and tag stay with the chart, so chart upgrades keep moving the version. global.imageRegistryHost may include a path, eg. harbor.example.com/anchore. See the enterprise chart's Using a Private Registry section for the full rule.

This chart takes the dict form only — image.pullPolicy lives in the same dict, so a bare reference string is not a valid value here.

Parameters

Global Resource Parameters

NameDescriptionValue
global.imageRegistryHostregistry host used by every image value that does not set its owndocker.io

Common Resource Parameters

NameDescriptionValue
replicaCountNumber of replicas for the K8s Inventory deployment1
image.pullPolicyImage pull policy used by the K8s Inventory deploymentIfNotPresent
image.registryRegistry for the K8s Inventory image. Empty means take it from global.imageRegistryHost""
image.repositoryRepository for the K8s Inventory imageanchore/k8s-inventory
image.tagImage tag used for the K8s Inventory deploymentv1.8.7
imagePullSecretssecrets where Kubernetes should get the credentials for pulling private images[]
nameOverrideoverrides the name set on resources""
fullnameOverrideoverrides the fullname set on resources""
injectSecretsViaEnvEnable secret injection into pod via environment variables instead of via k8s secretsfalse
serviceAccount.createCreate a service account for k8s-inventory to usetrue
serviceAccount.annotationsAnnotations to add to the service account{}
serviceAccount.nameThe name of the service account to use. If not set and create is true, a name is generated using the fullname template.k8s-inventory
podAnnotationsAnnotations set on all pods{}
annotationsCommon annotations set on all Kubernetes resources{}
podSecurityContextSecurity context set on all pods{}
securityContextSecurity context set on all containers{}
service.typeService type for K8s InventoryClusterIP
service.portService port for K8s Inventory80
resourcesResource requests and limits for K8s Inventory pods{}
nodeSelectorNode labels for K8s Inventory pods assignment{}
tolerationsTolerations for K8s Inventory pods assignment[]
affinityAffinity for K8s Inventory pods assignment{}
labelsAdds additionnal labels to all kubernetes resources{}
probes.liveness.initialDelaySecondsInitial delay seconds for liveness probe1
probes.liveness.timeoutSecondsTimeout seconds for liveness probe10
probes.liveness.periodSecondsPeriod seconds for liveness probe5
probes.liveness.failureThresholdFailure threshold for liveness probe6
probes.liveness.successThresholdSuccess threshold for liveness probe1
probes.readiness.timeoutSecondsTimeout seconds for the readiness probe10
probes.readiness.periodSecondsPeriod seconds for the readiness probe15
probes.readiness.failureThresholdFailure threshold for the readiness probe3
probes.readiness.successThresholdSuccess threshold for the readiness probe1
extraVolumesmounts additional volumes to each pod[]
extraVolumeMountsmounts additional volumes to each pod[]
useExistingSecretSpecify whether to use an existing secretfalse
existingSecretNameif using an existing secret, specify the existing secret name""

k8sInventory Parameters

NameDescriptionValue
k8sInventory.outputThe output format of the report (options: table, json)json
k8sInventory.quietDetermine whether or not to log the inventory report to stdoutfalse
k8sInventory.verboseInventoryReportsDetermine whether or not to log the inventory report to stdoutfalse
k8sInventory.log.structuredDetermine whether or not to use structured logsfalse
k8sInventory.log.levelthe level of verbosity for logsdebug
k8sInventory.log.filelocation to write the log file (default is not to have a log file)""
k8sInventory.anchoreRegistration.RegistrationIdIdentifier that the integration uses when registering. Can""
k8sInventory.anchoreRegistration.IntegrationNameName of the integration instance. If left empty the agent""
`k8sInventory.anchoreRe

Deploy k8s-inventory with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has k8s-inventory on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartk8s-inventory is pinned at v0.7.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply