k8s-inventory
by Anchore
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:
| Level | Where | Wins over |
|---|---|---|
1. Per-image registry | image.registry | everything below |
2. global.imageRegistryHost | one value for the whole chart | the chart defaults |
| 3. Chart default | docker.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
| Name | Description | Value |
|---|---|---|
global.imageRegistryHost | registry host used by every image value that does not set its own | docker.io |
Common Resource Parameters
| Name | Description | Value |
|---|---|---|
replicaCount | Number of replicas for the K8s Inventory deployment | 1 |
image.pullPolicy | Image pull policy used by the K8s Inventory deployment | IfNotPresent |
image.registry | Registry for the K8s Inventory image. Empty means take it from global.imageRegistryHost | "" |
image.repository | Repository for the K8s Inventory image | anchore/k8s-inventory |
image.tag | Image tag used for the K8s Inventory deployment | v1.8.7 |
imagePullSecrets | secrets where Kubernetes should get the credentials for pulling private images | [] |
nameOverride | overrides the name set on resources | "" |
fullnameOverride | overrides the fullname set on resources | "" |
injectSecretsViaEnv | Enable secret injection into pod via environment variables instead of via k8s secrets | false |
serviceAccount.create | Create a service account for k8s-inventory to use | true |
serviceAccount.annotations | Annotations to add to the service account | {} |
serviceAccount.name | The name of the service account to use. If not set and create is true, a name is generated using the fullname template. | k8s-inventory |
podAnnotations | Annotations set on all pods | {} |
annotations | Common annotations set on all Kubernetes resources | {} |
podSecurityContext | Security context set on all pods | {} |
securityContext | Security context set on all containers | {} |
service.type | Service type for K8s Inventory | ClusterIP |
service.port | Service port for K8s Inventory | 80 |
resources | Resource requests and limits for K8s Inventory pods | {} |
nodeSelector | Node labels for K8s Inventory pods assignment | {} |
tolerations | Tolerations for K8s Inventory pods assignment | [] |
affinity | Affinity for K8s Inventory pods assignment | {} |
labels | Adds additionnal labels to all kubernetes resources | {} |
probes.liveness.initialDelaySeconds | Initial delay seconds for liveness probe | 1 |
probes.liveness.timeoutSeconds | Timeout seconds for liveness probe | 10 |
probes.liveness.periodSeconds | Period seconds for liveness probe | 5 |
probes.liveness.failureThreshold | Failure threshold for liveness probe | 6 |
probes.liveness.successThreshold | Success threshold for liveness probe | 1 |
probes.readiness.timeoutSeconds | Timeout seconds for the readiness probe | 10 |
probes.readiness.periodSeconds | Period seconds for the readiness probe | 15 |
probes.readiness.failureThreshold | Failure threshold for the readiness probe | 3 |
probes.readiness.successThreshold | Success threshold for the readiness probe | 1 |
extraVolumes | mounts additional volumes to each pod | [] |
extraVolumeMounts | mounts additional volumes to each pod | [] |
useExistingSecret | Specify whether to use an existing secret | false |
existingSecretName | if using an existing secret, specify the existing secret name | "" |
k8sInventory Parameters
| Name | Description | Value |
|---|---|---|
k8sInventory.output | The output format of the report (options: table, json) | json |
k8sInventory.quiet | Determine whether or not to log the inventory report to stdout | false |
k8sInventory.verboseInventoryReports | Determine whether or not to log the inventory report to stdout | false |
k8sInventory.log.structured | Determine whether or not to use structured logs | false |
k8sInventory.log.level | the level of verbosity for logs | debug |
k8sInventory.log.file | location to write the log file (default is not to have a log file) | "" |
k8sInventory.anchoreRegistration.RegistrationId | Identifier that the integration uses when registering. Can | "" |
k8sInventory.anchoreRegistration.IntegrationName | Name 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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartk8s-inventory is pinned at v0.7.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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