Susan

nexushelm

Homelab

nexushelm runs helm against the cluster of the homelab setup with the same accesses as nexusctl (an access is a cluster account with limited rights and a fixed duration; see the glossary). It writes every call to the same journal, masks the values of Secrets in the output, and adds the precheck subcommand, which lists the rights a chart requires and the access lacks. Accesses are created and revoked with nexusadm. Messages of the command are in French.

Synopsis

nexushelm [--nexusconfig <name|path>] <helm arguments>
nexushelm [--nexusconfig <name|path>] precheck <release> <chart> [helm template options] [--detail] [--nouvel-acces]

Accesses

The access is chosen as with nexusctl: --nexusconfig <name> (file <name>.json of the access folder), --nexusconfig <path> (a value that contains /), the NEXUSCONFIG variable, otherwise the access named read. The table and the access folder are described on the nexusctl page.

nexushelm removes KUBECONFIG and every HELM_KUBE* variable from the environment of helm, then sets KUBECONFIG to the temporary kubeconfig of the access.

Subcommands with and without the cluster

These helm subcommands work without the cluster:

Subcommands
completion, create, dependency, env, help, lint, package, plugin
pull, push, registry, repo, search, show, template, verify, version

When the access is missing or expired, they still run, with an empty kubeconfig so that helm does not read the default kubeconfig of the account; the journal records the account as (aucun accès). When the access is available, they run with it.

Every other subcommand (install, upgrade, uninstall, rollback, list, status, history, get, test, and precheck) requires the access. Without it, nexushelm prints the cause and exits with code 1.

Refused options

These options would replace the account, the context or the server of the access. nexushelm ends with exit code 2 when one of them appears before --, in the --option value form or the --option=value form:

Options
--kubeconfig, --kube-context, --kube-apiserver
--kube-token, --kube-as-user, --kube-as-group
--kube-ca-file, --kube-tls-server-name, --kube-insecure-skip-tls-verify

nexushelm checks these options before reading the access, and records the refused command in the journal with the decision refusee and the account (refusé avant l'accès).

Releases and their Secrets

A release (one installation of a chart in a namespace, under a name) is stored by Helm in Secrets of the release namespace. nexushelm does not change the storage driver of Helm. An access that installs or upgrades a release therefore needs get, list, create and update on the Secrets of that namespace, which precheck checks.

Each release Secret contains the values passed to Helm. Anyone who can read the Secrets of the namespace can read those values.

SECRET: references are refused

A SECRET: reference (see nexusctl) is not accepted by nexushelm. The command ends with exit code 2, before helm runs, when a reference appears:

Files given with --set-file are not read. To give a secret to a chart, create the Secret with nexusctl and pass its name to the chart, when the chart reads an existing Secret (often a value named existingSecret):

nexusctl --nexusconfig deploy -n my-app create secret generic my-release-db \
  --from-literal=password=SECRET:keyring/db-password
nexushelm --nexusconfig deploy upgrade --install my-release ./chart -n my-app \
  --set db.existingSecret=my-release-db

Masking

The output of helm is masked as with nexusctl: each value of a Secret that the access can read, and each listed keyring secret, is replaced with its reference. See Masking in the output.

Journal

nexushelm writes to the same journal as nexusctl (infra/.nexusctl/journal.jsonl, or NEXUSCTL_JOURNAL), with the tool nexushelm. The events and fields are described on the nexusctl page.

In the recorded arguments, nexushelm replaces with ***:

precheck

nexushelm precheck renders the chart and asks the API server, for each right the install requires, whether the access holds it. It prints the rules to request with nexusadm grant request --rule.

nexushelm --nexusconfig deploy precheck my-release ./chart -n my-app -f values.yaml

Arguments

ArgumentDescription
<release> <chart> and other optionsPassed to helm template: -n/--namespace, -f/--values, --set, --create-namespace…
--detailAdds a line per object and per missing right
--nouvel-accesLists every right the chart requires, without querying the API server, for an access requested from scratch

Without -n or --namespace, the release namespace is default.

Rights checked

ObjectRights
Release Secretget, list, create, update on secrets of the release namespace
--create-namespacecreate on namespaces
Each rendered objectget, create, patch on its resource, in its namespace or the release namespace
Role or ClusterRole with rulesEvery right it grants, or escalate on the role (limited to its name when the role already exists)
RoleBinding or ClusterRoleBindingThe rights of the bound role when the chart renders it, or bind on that role

Before the check, precheck reads kubectl api-versions and passes each group to helm template with --api-versions, so that a chart that tests for an installed API renders as it does with helm upgrade. When the access cannot read whether a role exists, the role counts as a creation and the report starts with the number of such roles.

Report

By default, the report lists each rule to request as a --rule "<scope>:<resource>[/<name>]:<verbs>" line, followed by up to three objects of the chart that need it. --detail replaces the object lists with one block per object. When an unnamed escalate is required, the report states that this right allows creating a role with any rights.

Without --nouvel-acces, the report lists only the rights the access lacks. An access requested with nexusadm grant request starts with no rights, so the rules for a new access come from --nouvel-acces.

What precheck does not see

For an object whose type the cluster does not know yet (a CRD not installed), the resource name is guessed as the lowercase kind followed by s.

Exit codes of precheck

CodeMeaning
0The access covers every right checked
1Rights are missing, or a step failed (helm template, a kubectl call, an unexpected response)

Inside the sandbox

In the sandbox that infra/bin/nexus-sandbox starts, nexushelm sends the command to the broker outside the sandbox, as nexusctl does. See Inside the sandbox.

Exit codes

CodeMeaning
Code of helmhelm ran
0 or 1precheck (see above)
1Access missing or expired for a subcommand that requires the cluster; journal cannot be written
2--nexusconfig repeated or empty; refused option; SECRET: reference in the arguments or a values file; broker unreachable
127helm is missing from PATH or cannot start

Examples

List the releases of a namespace with the deploy access (the read access cannot read Secrets, where releases are stored):

nexushelm --nexusconfig deploy list -n my-app

Render a chart without an access:

nexushelm template my-release ./chart -n my-app -f values.yaml

List the rules a new access needs to install a chart, then install it:

nexushelm precheck my-release ./chart -n my-app -f values.yaml --nouvel-acces
nexushelm --nexusconfig deploy upgrade --install my-release ./chart -n my-app -f values.yaml