Kubernetes

Configure the agent

Chart values for the LevelFour agent, and how to read Prometheus history, publish cost metrics, measure network by destination, turn on the JVM reader, send through a proxy, pull from a private registry and verify the release signatures.

Helm installs and GitOps installs take the same chart values. With GitOps, add them to your values. With Helm, apply a values file over the install you have:

helm upgrade levelfour-agent oci://public.ecr.aws/levelfour/charts/levelfour-agent \
  --version 0.8.6 \
  --namespace levelfour --reset-then-reuse-values -f values.yaml

Set --version to the chart version you run. Without it, Helm pulls the newest chart and upgrades the agent as well.

Chart values

The chart validates its values and refuses to install when clusterName breaks the naming rule, when neither token nor existingSecret.name is set, when both are, when automation.enabled is true with no automation.allowedNamespaces, when an automation.hardLimits value is not positive, when an automation or jvmReader key is one it does not know, or when jvmReader.namespace is the release namespace.

ValueDefaultWhat it sets
clusterNamenoneThe cluster's name in LevelFour. Required. Lowercase letters, digits and hyphens, at most 63 characters, starting and ending with a letter or digit. Unique across your organization
tokennoneA cluster token (l4k_...) or an install key (l4ki_...). Set token or existingSecret.name, not both
existingSecret.namenoneA Secret in the release namespace that holds the token or install key
existingSecret.keytokenThe key inside that Secret
apiUrlhttps://api.levelfour.aiWhere the agent sends data. Keep the default
prometheus.urlnoneAn in-cluster Prometheus to read usage and history from. See Read history from Prometheus
kubelet.insecureSkipTLSVerifyfalseSkips kubelet certificate checks, for local kind clusters only. On a real cluster it sends the agent's service account token to kubelets the agent cannot verify
image.repositorypublic.ecr.aws/levelfour/k8s-agentThe agent image. Point it at your mirror
image.tagThe chart's versionLeave it unset so the image moves with the chart
image.digestnonePulls the image by digest (sha256:...) instead of by tag
image.pullPolicyIfNotPresentIfNotPresent, Always or Never
imagePullSecrets[]Pull Secrets for a private registry
nameOverridenoneReplaces the chart name in object names and in the app.kubernetes.io/name label
fullnameOverridenoneReplaces the whole object name. A release named levelfour-agent names its objects levelfour-agent
serviceAccount.createtrueWhether the chart creates the agent's service account
serviceAccount.nameThe object nameThe service account the agent runs as. With create: false, name one that exists
serviceAccount.annotations{}Annotations on the service account the chart creates
commonLabels{}Labels added to every object the chart creates
podAnnotations{}Annotations on the agent pod
podLabels{}Labels on the agent pod, added to the chart's own
priorityClassNamenoneThe PriorityClass of the agent pod. Wins over priorityClass.create
priorityClass.createfalseCreates a PriorityClass and gives it to the agent pod. On Spot or heavily consolidated nodes, turn it on: after an interruption the agent's pod is otherwise scheduled behind every other evicted pod and waits minutes for a new node, and those minutes are missing from the data. With the class it starts first, and with PreemptLowerPriority may evict one lower-priority pod to start on a running node. The class is cluster-scoped, so the install needs permission to create PriorityClasses
priorityClass.value1000000The class's priority, below the system classes
priorityClass.preemptionPolicyPreemptLowerPriorityNever only puts the agent's pod first in the scheduling queue, without evicting anything
podSecurityContextNon-root user and group 65532, RuntimeDefault seccompThe pod security context
containerSecurityContextNo privilege escalation, read-only root filesystem, every capability droppedThe container security context
resourcesSee FootprintCPU and memory requests and limits
metrics.port9090The port that serves /metrics and /healthz
metrics.costs.enabledfalseAlso serves this cluster's cost on /metrics. See Cost metrics for your Prometheus
serviceMonitor.enabledfalseCreates a Prometheus Operator ServiceMonitor for /metrics. Needs the monitoring.coreos.com CRDs
serviceMonitor.labels{}Labels your Prometheus selects ServiceMonitors by
grafanaDashboard.enabledfalseCreates a ConfigMap with a LevelFour cost dashboard for Grafana's dashboard sidecar. Needs metrics.costs.enabled
grafanaDashboard.labelsgrafana_dashboard: "1"Labels the sidecar loads dashboards by
netflow.enabledfalseRuns the netflow DaemonSet. See Network by destination
netflow.existingSecret.namenoneA Secret in the release namespace that holds the token the agent and the netflow pods share, instead of the one the chart generates. Set it for GitOps installs. See Network by destination
netflow.existingSecret.keytokenThe key inside that Secret
netflow.port9188The port each netflow pod answers the agent on, at its node's own address. The pods use the node's network, so pick a port free on every node
netflow.resourcesRequests 50m CPU and 32 MiB, limits 200m CPU and 256 MiBCPU and memory of each netflow pod. See the memory sizing under Network by destination
netflow.tolerationsTolerates every taintRuns a netflow pod on every node, tainted ones included, so no node's traffic goes uncounted
netflow.priorityClassNamenoneThe PriorityClass of the netflow pods
jvmReader.enabledfalseRuns the JVM reader DaemonSet. See Turn on the JVM reader
jvmReader.namespacelevelfour-jvmThe namespace of the reader's pods. It must differ from the release namespace, because it allows privileged pods
jvmReader.createNamespacetrueCreates jvmReader.namespace with the Pod Security labels the reader needs. Set false to bring your own, labelled pod-security.kubernetes.io/enforce: privileged
jvmReader.existingSecret.namenoneA Secret that holds the token the agent and the reader pods share, instead of the one the chart generates. It must exist in the release namespace and in jvmReader.namespace, with the same token. Set it for GitOps installs
jvmReader.existingSecret.keytokenThe key inside that Secret
jvmReader.requireLandlocktrueKeeps the reader's server from serving on a node whose kernel cannot confine it with Landlock. Set false to let it serve there unconfined
jvmReader.port9189The port each reader pod answers the agent on, at the pod's own address
jvmReader.interval30sHow often the reader samples the JVMs on its node
jvmReader.namespaces[]The only namespaces whose JVMs the reader reads. Empty reads every namespace but kube-system, the release namespace and the reader's own, which it never reads
jvmReader.nodeSelector{}Narrows the nodes the reader runs on. It never runs on Windows nodes, EKS Fargate or virtual kubelets
jvmReader.tolerations[]Taints the reader tolerates. Empty runs it on untainted nodes only
jvmReader.priorityClassNamenoneThe PriorityClass of the reader pods
jvmReader.seLinuxOptionslevel: s0:c0.c1023The SELinux options of the probe container. See Nodes it runs on
jvmReader.probe.resourcesRequests 10m CPU and 48 MiB, limits 100m CPU and 128 MiBCPU and memory of the probe container on each node
jvmReader.server.resourcesRequests 5m CPU and 32 MiB, limits 100m CPU and 128 MiBCPU and memory of the server container, which keeps three hours of samples
kro.instanceGroups[]API groups of kro instances outside kro.run. See KNative and kro
extraEnv[]Extra environment variables for the agent, such as a proxy
nodeSelectorkubernetes.io/os: linuxNode selector for the agent pod
tolerations[]Tolerations for the agent pod
affinity{}Affinity rules for the agent pod
automation.enabledfalseInstalls the automation component and its configuration objects, with its own service account and permissions. It changes nothing until an object or an admin in the dashboard turns automation on
automation.allowedNamespaces[]The namespaces the component may change. Required when automation.enabled is true. ["*"] grants it the whole cluster and makes it watch every pod, so a list is lighter on a big cluster
automation.hardLimits.maximumCores8The most CPU, in cores, the component or its webhook sets on one container, request or limit, whatever an object or the dashboard asks for. A container never goes past double its workload's own spec either way
automation.hardLimits.maximumGiB16The same ceiling for memory, in GiB
automation.revert.allowPodEvictionfalseLets a revert evict a pod whose memory limit cannot go back down in place, on Kubernetes 1.33 and 1.34. Only this value allows an eviction
automation.resourcesrequests 20m, 128Mi; limits 200m, 256MiThe component's own resources. Its pod cache grows with the pods in the allowed namespaces, so raise the memory limit for ["*"] on a big cluster
automation.priorityClassNamenoneThe PriorityClass of the component's pod and of the webhook's pods
automation.webhook.enabledfalseInstalls the admission webhook that gives each new pod of a rightsized workload its values. Needs automation.enabled, and the control plane must reach its pods on port 9443
automation.webhook.resourcesrequests 20m, 64Mi; limits 200m, 128MiEach webhook pod's resources. Its cache holds the rightsized values of the allowed namespaces

Read history from Prometheus

The agent measures usage from the kubelet on each node, so it needs no Prometheus. If the cluster already runs one, such as kube-prometheus-stack, point the agent at it. At its first start the agent reads up to 14 days of history from Prometheus, so the first recommendations can come sooner than 7 days after install.

values.yaml
prometheus:
  url: http://prometheus-operated.monitoring.svc:9090

With Helm, set it on the command line:

helm upgrade levelfour-agent oci://public.ecr.aws/levelfour/charts/levelfour-agent \
  --version 0.8.6 \
  --namespace levelfour --reset-then-reuse-values \
  --set prometheus.url=http://prometheus-operated.monitoring.svc:9090

The agent queries Prometheus from inside the cluster. LevelFour never connects to it, and nothing is exposed outside the cluster.

With prometheus.url set, the agent reads all usage from Prometheus and no longer calls the kubelets, so the nodes need no inbound rule on port 10250 for it. That Prometheus has to scrape each kubelet's cAdvisor endpoint (/metrics/cadvisor) and the kubelet's own metrics, as kube-prometheus-stack does by default. The agent reads container CPU, memory, file system, throttling and network from cAdvisor, and volume use from kubelet_volume_stats_used_bytes. Usage shows for one node only covers the port 10250 rule for an agent that reads the kubelets.

GPU usage from DCGM

When the same Prometheus scrapes NVIDIA's DCGM exporter, the agent also reads each container's GPU utilization and GPU memory, and the workload drawer shows them beside the GPUs it requested. The exporter's Helm chart creates the ServiceMonitor that kube-prometheus-stack picks up. Without the exporter, GPU usage reads as not measured, and nothing else changes.

Cost metrics for your Prometheus

With metrics.costs.enabled, the agent's ingest token also reads this cluster's cost from LevelFour once an hour, and the agent republishes it in the cluster on the same /metrics port, to anyone who can reach that port. Chart your LevelFour cost in your own Grafana, next to the rest of your metrics.

values.yaml
metrics:
  costs:
    enabled: true
serviceMonitor:
  enabled: true
  labels:
    release: kube-prometheus-stack
grafanaDashboard:
  enabled: true

Each series carries a window label: last_day, the last day the bill priced, or month_to_date. Each window carries the 500 costliest workloads, and sums the rest into one series whose namespace, kind and workload are __other__.

MetricWhat it is
levelfour_namespace_cost_usd{namespace,window}A namespace's cost
levelfour_workload_cost_usd{namespace,kind,workload,window}A workload's cost
levelfour_workload_waste_usd{namespace,kind,workload,window}The cost of what a workload requested and did not use
levelfour_cluster_idle_cost_usd{window}The cost of node capacity no workload requested
levelfour_cost_day_timestamp_secondsThe start of the last priced day, as a Unix time. 0 until a day is priced

serviceMonitor.labels has to match what your Prometheus selects. kube-prometheus-stack selects ServiceMonitors labelled release: <its release name>, and its Grafana dashboard sidecar loads ConfigMaps labelled grafana_dashboard: "1", the chart's default (kube-prometheus-stack values).

When a read fails, or LevelFour answers in a currency other than US dollars, the agent keeps serving the last values it had, and levelfour_cost_day_timestamp_seconds shows how old they are. A scrape always sees one whole refresh.

Network by destination

The agent counts the bytes each workload sends, but not where they go. With netflow.enabled, the chart adds a DaemonSet, one pod per node, that measures where: a workload in the same zone or another zone, a node, a private address outside the cluster, or the internet. LevelFour then splits each node's data transfer bill by it, so cross-zone and internet egress cost lands on the workloads that cause it. AWS bills a byte that crosses zones on both nodes, the one it leaves and the one it reaches, so the cost of a zone pair counts both ends.

values.yaml
netflow:
  enabled: true

Each netflow pod reads its node's connection tracking table (conntrack) every 10 seconds, or every ten times as long as its last read took when that is longer, and watches only the pods on its own node. A receiver with a public IPv4 address counts as internet, and the netflow pod drops the address at once. Every other receiver, a private IPv4 address or any IPv6 address that is not loopback or link-local, keeps its address only as far as the agent, inside the cluster. The agent names it from the pods and nodes it already watches: a pod becomes its workload and zone, a node becomes node, and an address it does not know becomes private inside a private range and internet outside one. No address reaches LevelFour. The agent reads each node one minute late, and tries a node twice more after a connection failure, a server error or a refused token before that window goes without it. Reading conntrack takes privileges the agent never has: The netflow component lists each one and why.

The netflow pods answer only the agent, with a token they share. The chart generates it in a Secret of its own. Argo CD and Flux render the chart with helm template, which generates a new token on every sync, so the netflow pods would refuse the agent until both sides reload. For a GitOps install, create the token once in the release namespace and point the chart at it:

kubectl -n levelfour create secret generic levelfour-netflow-token --from-literal=token="$(openssl rand -hex 32)"
values.yaml
netflow:
  enabled: true
  existingSecret:
    name: levelfour-netflow-token

Each netflow pod holds about 1 KiB per connection its node tracks, on top of about 30 MiB, and its GOMEMLIMIT follows the container's memory limit. The default 256 MiB fits about 200,000 tracked connections. Check a node with cat /proc/sys/net/netfilter/nf_conntrack_count, and raise netflow.resources.limits.memory for busier nodes.

Netflow sees only traffic that passes through the node's netfilter. Cilium with eBPF host routing, which Cilium turns on together with eBPF kube-proxy replacement when the kernel supports it, and Cilium's installNoConntrackIptablesRules both bypass it, so netflow reads nothing there. Cilium with bpf.hostLegacyRouting=true works. Cilium's tuning guide describes both settings.

Netflow also misses:

  • Pods on the host network. Their traffic is the node's own.
  • A connection whose conntrack entry is gone before the next read. The kernel keeps a closed TCP connection's entry for 2 minutes by default, so short requests count in full. What can go missing is a connection reset by either side, whose entry lasts 10 seconds, and an entry the kernel drops early because the table is full.
  • Traffic to a pod that ended before the agent read the window. The agent no longer knows that pod, so the traffic counts as private or internet by its address.
  • Windows nodes. The DaemonSet runs on Linux nodes only.

The Network view on the cluster page shows the result under By destination: bytes and cost between each pair of zones, internet egress per workload, and how the measured gigabytes compare with the gigabytes the bill charged.

Turn on the JVM reader

The agent reads a JVM's heap from the pod spec only where -Xmx sets it plainly. With jvmReader.enabled, the chart adds the JVM reader, a DaemonSet that reads the heap, garbage collection and options of each running HotSpot JVM on its node. The measured heap explains what LevelFour does with them. It runs in a namespace of its own, levelfour-jvm, which allows privileged pods, and its probe container runs as root in the node's process namespace with SYS_PTRACE. Read The JVM reader for each privilege, what it reads and what it sends before you turn it on.

Upgrade with the reader off

Upgrade to 0.8.6 first. The reader stays off, its default:

helm upgrade levelfour-agent oci://public.ecr.aws/levelfour/charts/levelfour-agent --version 0.8.6 \
  --namespace levelfour --reset-then-reuse-values

--reset-then-reuse-values keeps the token and the values you installed with, and applies the new chart's defaults, the reader's among them. It needs Helm 3.14 or later, as Upgrade explains.

Turn the reader on

Pick the tab for the admission checks your cluster runs.

On a cluster whose only admission check is Pod Security, this is one command. The chart creates levelfour-jvm labelled privileged:

helm upgrade levelfour-agent oci://public.ecr.aws/levelfour/charts/levelfour-agent --version 0.8.6 \
  --namespace levelfour --reset-then-reuse-values --set jvmReader.enabled=true

Where Kyverno or Gatekeeper may refuse the reader, find out before anything runs. helm upgrade --dry-run=server cannot tell you: Helm renders the chart with the cluster's data and stops before it sends an object, so no admission webhook sees one. A kubectl server-side dry run goes through the admission chain, but only into a namespace that exists, so bring your own namespace:

  1. Create the reader's namespace, labelled for privileged pods. If your cluster runs Kyverno's deny-privileged-profile, only a user bound to the cluster-admin ClusterRole may set that label.

    kubectl create namespace levelfour-jvm
    kubectl label namespace levelfour-jvm pod-security.kubernetes.io/enforce=privileged
  2. Apply the Kyverno exception or the Gatekeeper exclusion, if your cluster runs either.

  3. Dry-run the DaemonSet with your release's values. helm template renders it and sends nothing. kubectl sends it to the API server as a dry run, which goes through every admission webhook and stores nothing.

    helm get values levelfour-agent --namespace levelfour --output yaml \
      | helm template levelfour-agent oci://public.ecr.aws/levelfour/charts/levelfour-agent --version 0.8.6 \
          --namespace levelfour --values - \
          --set jvmReader.enabled=true --set jvmReader.createNamespace=false \
          --show-only templates/jvmreader-daemonset.yaml \
      | kubectl apply --dry-run=server --filename -

    daemonset.apps/levelfour-agent-jvm-reader created (server dry run) means admission let it through. A refusal names the webhook and each policy, with the rule for a ClusterPolicy. Copy those names into the exception, then run the dry run again.

  4. Turn the reader on in your namespace:

    helm upgrade levelfour-agent oci://public.ecr.aws/levelfour/charts/levelfour-agent --version 0.8.6 \
      --namespace levelfour --reset-then-reuse-values \
      --set jvmReader.enabled=true --set jvmReader.createNamespace=false

Check every node

kubectl --namespace levelfour-jvm get daemonset levelfour-agent-jvm-reader
kubectl --namespace levelfour-jvm get events --field-selector reason=FailedCreate

READY matches DESIRED once every node the reader may run on has a ready pod. A FailedCreate event names a pod an admission check refused. Pod Security, and Gatekeeper without workload expansion, check the pods and not the DaemonSet, so their refusals show up here, after a dry run that passed.

From agent 0.8.1, the agent runs the same check every hour. A refused reader pod, a node with a taint the reader does not tolerate, and processes or JVMs the kernel hid from the reader turn its JVM reader health from OK to an error that names them.

Pod Security

The probe fails the baseline and restricted levels. The chart labels the namespace it creates privileged for enforce, warn and audit. With jvmReader.createNamespace=false the namespace is yours, and it needs pod-security.kubernetes.io/enforce: privileged.

Kyverno exceptions

Kyverno 1.19 ships with exceptions off. Its admission controller needs --enablePolicyException=true and --exceptionNamespace=<namespace> (features.policyExceptions.enabled and features.policyExceptions.namespace in its Helm chart), and it reads exceptions only from that namespace, or from all of them with *. Ask your Kyverno admins which namespace it is. The exception's kind follows the policy that refused:

  • A ClusterPolicy or Policy takes a kyverno.io/v2 PolicyException, which Kyverno 1.19 deprecates. Its policyName takes no wildcard, and ruleNames does. Kyverno checks the DaemonSet with the rule it generated from each Pod rule, named autogen-<rule>, and the pods with the rule itself, so list both.
  • A ValidatingPolicy takes a policies.kyverno.io/v1 PolicyException. It names policies in policyRefs, by exact name, and picks resources with CEL matchConditions. These policies have no rules to name.

These stock policies from kyverno/policies refuse the reader. The first five come in its pod-security, pod-security-cel and pod-security-vpol sets under the same names, and the kyverno-policies Helm chart installs them as ValidatingPolicy, or as ClusterPolicy with policyType=ClusterPolicy:

PolicyRuleWhat it refuses
disallow-host-namespaces (baseline)host-namespaceshostPID
disallow-capabilities (baseline)adding-capabilitiesSYS_PTRACE, which is not on its list
disallow-capabilities-strict (restricted)adding-capabilities-strictAny added capability but NET_BIND_SERVICE
require-run-as-nonroot (restricted)run-as-non-rootrunAsNonRoot: false
require-run-as-non-root-user (restricted)run-as-non-root-userrunAsUser: 0
require-pod-probes (best practices)validate-probesA container with no liveness, readiness or startup probe, as the probe container is
deny-privileged-profile (Pod Security Admission)check-privilegedThe privileged namespace label, from anyone not bound to cluster-admin

They ship in Audit mode, which reports and refuses nothing. A copy that refuses was set to Enforce (Deny for a ValidatingPolicy), and your copies may carry other names, so take the policy and rule names from the dry run's refusal. The stock disallow-selinux checks the SELinux type, user and role, so the probe's level passes it. LevelFour checked these exceptions on Kyverno 1.19.2.

For a ClusterPolicy, in your exception namespace:

levelfour-jvm-reader-exception.yaml
apiVersion: kyverno.io/v2
kind: PolicyException
metadata:
  name: levelfour-jvm-reader
  namespace: <exceptionNamespace>
spec:
  exceptions:
    - policyName: disallow-host-namespaces
      ruleNames: [host-namespaces, autogen-host-namespaces]
    - policyName: disallow-capabilities
      ruleNames: [adding-capabilities, autogen-adding-capabilities]
    - policyName: disallow-capabilities-strict
      ruleNames: [adding-capabilities-strict, autogen-adding-capabilities-strict]
    - policyName: require-run-as-nonroot
      ruleNames: [run-as-non-root, autogen-run-as-non-root]
    - policyName: require-run-as-non-root-user
      ruleNames: [run-as-non-root-user, autogen-run-as-non-root-user]
    - policyName: require-pod-probes
      ruleNames: [validate-probes, autogen-validate-probes]
  match:
    any:
      - resources:
          kinds: [DaemonSet, Pod]
          namespaces: [levelfour-jvm]
          names: [levelfour-agent-jvm-reader*]

For a ValidatingPolicy:

levelfour-jvm-reader-exception.yaml
apiVersion: policies.kyverno.io/v1
kind: PolicyException
metadata:
  name: levelfour-jvm-reader
  namespace: <exceptionNamespace>
spec:
  policyRefs:
    - {kind: ValidatingPolicy, name: disallow-host-namespaces}
    - {kind: ValidatingPolicy, name: disallow-capabilities}
    - {kind: ValidatingPolicy, name: disallow-capabilities-strict}
    - {kind: ValidatingPolicy, name: require-run-as-nonroot}
    - {kind: ValidatingPolicy, name: require-run-as-non-root-user}
    - {kind: ValidatingPolicy, name: require-pod-probes}
  matchConditions:
    - name: levelfour-jvm-reader
      expression: >-
        object.metadata.namespace == 'levelfour-jvm' &&
        object.metadata.name.startsWith('levelfour-agent-jvm-reader')

Each matches the DaemonSet and its pods in levelfour-jvm for a release named levelfour-agent. Keep the entries your dry run names and drop the rest.

Gatekeeper exclusion

Gatekeeper's library constraints match Pods, so Gatekeeper refuses the reader's pods and lets the DaemonSet through, unless your Gatekeeper validates workloads through expansion. To leave the reader's namespace out of every constraint, add it to excludedNamespaces under spec.match of the Config resource named config in gatekeeper-system, with processes: ["webhook"], or ["*"] to leave it out of audit too. For one constraint, use that constraint's spec.match.excludedNamespaces. With the admission.gatekeeper.sh/ignore label, the API server stops calling Gatekeeper's webhook for anything in the namespace, and Gatekeeper allows that label only on a namespace listed in its --exempt-namespace flag.

GitOps installs

The chart generates the reader's token in a Secret in both namespaces. Argo CD and Flux render the chart with helm template, which cannot read the Secret the chart made before, so every sync would generate a new token and the reader would refuse the agent until both sides reload. For a GitOps install, create the reader's namespace and its token once, with the same token in the release namespace and in levelfour-jvm:

kubectl create namespace levelfour-jvm
kubectl label namespace levelfour-jvm pod-security.kubernetes.io/enforce=privileged
TOKEN="$(openssl rand -hex 32)"
kubectl -n levelfour create secret generic levelfour-jvm-reader-token --from-literal=token="$TOKEN"
kubectl -n levelfour-jvm create secret generic levelfour-jvm-reader-token --from-literal=token="$TOKEN"

Then pin chart version 0.8.6, as Upgrade shows for each tool, and add the reader to your values:

values.yaml
jvmReader:
  enabled: true
  createNamespace: false
  existingSecret:
    name: levelfour-jvm-reader-token

With Kyverno or Gatekeeper, add the exception before you commit the values, and run the dry run from the Kyverno or Gatekeeper tab first.

Turn it off

helm upgrade levelfour-agent oci://public.ecr.aws/levelfour/charts/levelfour-agent --version 0.8.6 \
  --namespace levelfour --reset-then-reuse-values --set jvmReader.enabled=false

Helm removes the DaemonSet, its service account and NetworkPolicy, and the token Secrets the chart generated, and the agent stops reading JVMs. When the chart created the namespace (jvmReader.createNamespace=true), Helm deletes it too, with anything else in it. A namespace you created stays, and so does your PolicyException, until you delete them.

Behind a proxy

The agent sends data to api.levelfour.ai on port 443. If the cluster reaches the internet through a proxy, set HTTPS_PROXY for the agent with extraEnv. Set NO_PROXY to your in-cluster addresses so the agent still reaches the kubelets and the API server directly: .svc, .cluster.local, the service CIDR, and the pod and node CIDRs.

values.yaml
extraEnv:
  - name: HTTPS_PROXY
    value: http://proxy.example.com:3128
  - name: NO_PROXY
    value: .svc,.cluster.local,172.20.0.0/16,10.0.0.0/16

Replace the CIDRs with your cluster's. The API server's in-cluster address sits in the service CIDR. On Amazon EKS, read it with:

aws eks describe-cluster --name YOUR_EKS_CLUSTER \
  --query cluster.kubernetesNetworkConfig.serviceIpv4Cidr --output text

Private registry mirror

To pull the agent from your own registry, copy the image there and point the chart at it. Copy both architectures (linux/amd64 and linux/arm64) and keep the tag, because the chart pulls the tag that matches its version. crane copy copies every architecture by default; with skopeo copy, pass --all.

crane copy public.ecr.aws/levelfour/k8s-agent:0.8.6 registry.example.com/levelfour/k8s-agent:0.8.6
values.yaml
image:
  repository: registry.example.com/levelfour/k8s-agent
imagePullSecrets:
  - name: registry-credentials

registry-credentials is a kubernetes.io/dockerconfigjson Secret in the levelfour namespace. To pin the exact image you verified, set image.digest to the digest crane digest public.ecr.aws/levelfour/k8s-agent:0.8.6 prints. crane copy keeps that digest.

To mirror the chart as well, pull it and push it to your registry, then install from oci://registry.example.com/levelfour/charts/levelfour-agent:

helm pull oci://public.ecr.aws/levelfour/charts/levelfour-agent --version 0.8.6
helm push levelfour-agent-0.8.6.tgz oci://registry.example.com/levelfour/charts

Verify the signatures on the public copies before you mirror them.

Verify the signatures and SBOM

LevelFour signs every agent image and chart with cosign, and attaches an SPDX SBOM to each image as a signed attestation. The signing key stays in AWS KMS. Check a release with the LevelFour public key and cosign 3 or later.

Download the public key:

curl -sSfLO https://docs.levelfour.ai/keys/levelfour-k8s-agent.pub

Verify the image and the chart:

cosign verify --key levelfour-k8s-agent.pub public.ecr.aws/levelfour/k8s-agent:0.8.6
cosign verify --key levelfour-k8s-agent.pub public.ecr.aws/levelfour/charts/levelfour-agent:0.8.6

Verify the SBOM attestation:

cosign verify-attestation --key levelfour-k8s-agent.pub --type spdxjson public.ecr.aws/levelfour/k8s-agent:0.8.6

To save the SBOM itself, pipe that command's output through jq -r .payload | base64 -d | jq .predicate > levelfour-agent-0.8.6.spdx.json.

Each command exits with an error when the signature is missing or a different key made it.

Verify the image your nodes run

The version tag points to the multi-arch index, and the SBOM on the tag lists the packages of the amd64 image. Releases after 0.2.0 also sign each architecture's image and attach an SBOM of its own packages, so you can check the exact image an arm64 or amd64 node pulls. List the digests:

docker buildx imagetools inspect public.ecr.aws/levelfour/k8s-agent:<version>

Then verify the digest listed for your nodes' platform, linux/arm64 on Graviton:

cosign verify --key levelfour-k8s-agent.pub public.ecr.aws/levelfour/k8s-agent@sha256:<digest>
cosign verify-attestation --key levelfour-k8s-agent.pub --type spdxjson public.ecr.aws/levelfour/k8s-agent@sha256:<digest>

Verify the chart in Flux

Flux 2.8 and later verify cosign 3 signatures, so Flux can check the chart on every pull. Put the public key in a Secret next to the OCIRepository. Flux reads every key in that Secret whose name ends in .pub, and the file name gives the key that name:

kubectl -n levelfour create secret generic levelfour-cosign-key \
  --from-file=levelfour-k8s-agent.pub

Then add verify to the OCIRepository from Install with GitOps. Flux refuses a chart that the LevelFour key did not sign:

levelfour-agent.yaml
spec:
  verify:
    provider: cosign
    secretRef:
      name: levelfour-cosign-key

On this page

Ask the FinOps Agent about your cloud spend