Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- `nr cluster operator upgrade` bumps hypervisor CRD + operator Helm charts and the Harbor `v*` image tag while reusing cluster Secrets (no hypervisor token prompt). `nr cluster register --resume --reinstall-operator` does the same when credentials are not passed; pass `PROXMOX_*` / an instances file only to rotate tokens.

### Fixed

- Operator upgrade on agents that installed Proxmox CRDs as the operator subchart applies the standalone CRD chart in place instead of failing Helm ownership checks, and annotates those CRDs so Helm does not delete them when `crds.enabled=false`.
- In-place operator upgrade uses Helm `--reset-then-reuse-values` so new chart keys (hooks, exporter image) apply while instance Secrets stay reused.
- Operator upgrade pins `vncGateway.image.repository` to Harbor (retired `harbor.nrings.io` values cannot stick) and waits for the Proxmox exporter Deployment the same way VirtFusion/SolusVM already did.

## [1.0.13] - 2026-09-14

### Changed
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,22 @@ If registration is interrupted:
nr cluster register --resume --name edge-ams-01 --org-id <org-uuid>
```

Upgrade the operator later without re-entering hypervisor tokens:

```bash
nr cluster operator upgrade
```

`nr cluster register --resume --reinstall-operator` also reuses existing Secrets unless you pass credentials (that path is for rotating tokens).

## Common commands

```bash
nr auth status
nr cluster status --name edge-ams-01
nr cluster verify --name edge-ams-01
nr cluster health --name edge-ams-01
nr cluster operator upgrade
nr cluster deregister --name edge-ams-01
```

Expand Down
2 changes: 1 addition & 1 deletion docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ TLS verification is off. No flag or env var is required.

Registration checkpoints live under `~/.nr/`. Do not copy these directories between machines.

Never commit tokens, kubeconfigs, or instances files to version control. If a token may have leaked, rotate it and re-run `nr cluster register --resume --reinstall-operator`.
Never commit tokens, kubeconfigs, or instances files to version control. If a hypervisor token leaked, rotate it and re-run `nr cluster register --resume --reinstall-operator` with the new credentials (env or instances file). Chart-only upgrades use `nr cluster operator upgrade` and do not rewrite Secrets.
10 changes: 10 additions & 0 deletions docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ nr cluster register --resume --name <same-name> --org-id <org-uuid>

Checkpoints live under `~/.nr/`. Use `nr cluster status` and `nr cluster debug` for details.

**Upgrade operator charts (no hypervisor tokens)**

```bash
nr cluster operator upgrade
```

Reuses Helm values and Kubernetes Secrets. Does not need `NR_API_TOKEN` or `--org-id`. To rotate hypervisor credentials, use `--resume --reinstall-operator` with env or an instances file.

If CRDs were first installed as the operator chart subchart, upgrade applies the dedicated CRD charts in place (Helm 3.16 cannot take ownership) and keeps the CRDs when the operator subchart is disabled.

**Post-register verification failed**

```bash
Expand Down
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/noderings/cli

go 1.25.0

toolchain go1.25.13

require (
github.com/Masterminds/semver/v3 v3.4.0
github.com/avast/retry-go/v5 v5.0.0
Expand All @@ -12,7 +14,7 @@ require (
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
github.com/zalando/go-keyring v0.2.6
golang.org/x/term v0.39.0
golang.org/x/term v0.43.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.35.0
k8s.io/apimachinery v0.35.0
Expand Down Expand Up @@ -51,10 +53,10 @@ require (
github.com/x448/float16 v0.8.4 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.39.0 // indirect
golang.org/x/time v0.14.0 // indirect
google.golang.org/protobuf v1.36.8 // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -130,25 +130,25 @@ go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww=
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4=
golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk=
golang.org/x/text v0.39.0 h1:UbZz4pLOvn600D6Oh6GGEI6VAmndrEBLv8/6BEXzyus=
golang.org/x/text v0.39.0/go.mod h1:3UwRclnC2g0TU9x8PZiyfOajCd1zaUNHF9cvqcQZ+ZM=
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ=
golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q=
golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA=
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func init() {
clusterRegisterCmd.Flags().Bool("dry-run", false, "Show what would be executed without running")
clusterRegisterCmd.Flags().Bool("offline", false, "Skip fetching platform versions from the API (use local config pins)")
clusterRegisterCmd.Flags().Bool("skip-operator-install", false, "Skip hypervisor operator / vnc-gateway Helm install")
clusterRegisterCmd.Flags().Bool("reinstall-operator", false, "Re-run hypervisor operator Helm install even if that phase already succeeded (use with --resume)")
clusterRegisterCmd.Flags().Bool("reinstall-operator", false, "Re-run hypervisor operator Helm install even if that phase already succeeded (use with --resume). Reuses cluster Secrets unless hypervisor credentials are provided.")
clusterRegisterCmd.Flags().String("operator-chart", "", "Local path or OCI ref for the hypervisor operator chart (default: Harbor OCI or sibling checkout)")
clusterRegisterCmd.Flags().String("operator-chart-version", "", "Helm chart version when using OCI (default: "+config.DefaultProxmoxOperatorChartVersion+")")
clusterRegisterCmd.Flags().String("hypervisor-driver", "", "Required until the first agent in this organization is registered. After that, omit it or pass the same driver (proxmox, virtfusion, or solusvm).")
Expand Down Expand Up @@ -891,7 +891,7 @@ func handleResume(ctx context.Context, stateManager *state.Manager, apiClient *a
if err := runPostRegisterVerify(ctx, apiClient, log, installState.AgentID, registerOpts); err != nil {
return err
}
log.Info("Tip: re-run operator install with --resume --reinstall-operator")
log.Info("Tip: upgrade charts with 'nr cluster operator upgrade', or --resume --reinstall-operator")
return nil
}

Expand Down
116 changes: 116 additions & 0 deletions internal/cli/cluster_operator_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cli
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -67,6 +68,14 @@ func runOperatorInstallPhase(
}
log.Infof("Operator chart: %s%s", opCfg.ChartPath, chartVersionSuffix(opCfg.ChartVersion))

done, err := completeOperatorInstallFromReuse(ctx, log, stateManager, kubeconfig, config.HypervisorDriverProxmox, opCfg.ChartPath, opCfg.ChartVersion, opts)
if err != nil {
return err
}
if done {
return nil
}

instancesFile := opts.proxmoxInstancesFile
if instancesFile == "" {
instancesFile = strings.TrimSpace(os.Getenv("PROXMOX_INSTANCES_FILE"))
Expand Down Expand Up @@ -142,6 +151,14 @@ func runVirtFusionOperatorInstallPhase(
}
log.Infof("Operator chart: %s%s", opCfg.ChartPath, chartVersionSuffix(opCfg.ChartVersion))

done, err := completeOperatorInstallFromReuse(ctx, log, stateManager, kubeconfig, config.HypervisorDriverVirtFusion, opCfg.ChartPath, opCfg.ChartVersion, opts)
if err != nil {
return err
}
if done {
return nil
}

instancesFile := opts.virtfusionInstancesFile
if instancesFile == "" {
instancesFile = strings.TrimSpace(os.Getenv("VIRTFUSION_INSTANCES_FILE"))
Expand Down Expand Up @@ -214,6 +231,14 @@ func runSolusVMOperatorInstallPhase(
}
log.Infof("Operator chart: %s%s", opCfg.ChartPath, chartVersionSuffix(opCfg.ChartVersion))

done, err := completeOperatorInstallFromReuse(ctx, log, stateManager, kubeconfig, config.HypervisorDriverSolusVM, opCfg.ChartPath, opCfg.ChartVersion, opts)
if err != nil {
return err
}
if done {
return nil
}

instancesFile := opts.solusvmInstancesFile
if instancesFile == "" {
instancesFile = strings.TrimSpace(os.Getenv("SOLUSVM_INSTANCES_FILE"))
Expand Down Expand Up @@ -257,6 +282,97 @@ func chartVersionSuffix(version string) string {
return " @" + version
}

func completeOperatorInstallFromReuse(
ctx context.Context,
log *logger.Logger,
stateManager *state.Manager,
kubeconfig, driver, chart, version string,
opts clusterRegisterOpts,
) (bool, error) {
if !opts.reinstallOperator {
return false, nil
}
reused, err := tryReuseOperatorSecrets(ctx, log, kubeconfig, driver, chart, version, opts)
if err != nil {
stateManager.SetError(state.PhaseOperatorInstall, err.Error(), true)
_ = stateManager.Save()
return false, err
}
if !reused {
return false, nil
}
stateManager.AddCheckpoint(state.PhaseOperatorInstall, state.CheckpointStatusSuccess, "")
log.Info("✓ Operator install complete")
return true, nil
}

func tryReuseOperatorSecrets(
ctx context.Context,
log *logger.Logger,
kubeconfig, driver, chart, version string,
opts clusterRegisterOpts,
) (bool, error) {
provided, err := hypervisorCredsProvided(driver, opts)
if err != nil {
return false, err
}
if provided {
log.Info("Hypervisor credentials provided; rewriting operator Secrets")
return false, nil
}
existing, err := install.DetectReusableOperator(ctx, kubeconfig, driver)
if errors.Is(err, install.ErrNoReusableOperator) {
return false, nil
}
if err != nil {
return false, fmt.Errorf("detect operator release: %w", err)
}
log.Infof("Reusing %d existing hypervisor Secret(s); skipping credential prompt", len(existing.SecretNames))
u, err := install.NewOperatorUpgrade(driver, kubeconfig, chart, version)
if err != nil {
return false, err
}
if err := u.BindLiveRelease(existing.Release, existing.Namespace); err != nil {
return false, err
}
if err := install.UpgradeOperatorRelease(ctx, u, log); err != nil {
return false, err
}
return true, nil
}

func hypervisorCredsProvided(driver string, opts clusterRegisterOpts) (bool, error) {
switch {
case config.IsSolusVMHypervisor(driver):
if strings.TrimSpace(opts.solusvmInstancesFile) != "" || strings.TrimSpace(os.Getenv(config.EnvSolusVMInstancesFile)) != "" {
return true, nil
}
inst, err := install.SolusVMInstanceFromEnv()
if err != nil {
return false, err
}
return inst != nil, nil
case config.IsVirtFusionHypervisor(driver):
if strings.TrimSpace(opts.virtfusionInstancesFile) != "" || strings.TrimSpace(os.Getenv(config.EnvVirtFusionInstancesFile)) != "" {
return true, nil
}
inst, err := install.VirtFusionInstanceFromEnv()
if err != nil {
return false, err
}
return inst != nil, nil
default:
if strings.TrimSpace(opts.proxmoxInstancesFile) != "" || strings.TrimSpace(os.Getenv(config.EnvProxmoxInstancesFile)) != "" {
return true, nil
}
inst, err := install.ProxmoxInstanceFromEnv()
if err != nil {
return false, err
}
return inst != nil, nil
}
}

// resolveExistingAgent loads an agent by ID and returns its name. Optionally checks name/IP consistency.
// When allowProvisioned is false, already-provisioned agents are rejected (UI install-command path).
func resolveExistingAgent(ctx context.Context, apiClient *api.Client, agentID, expectedName, expectedIP string, allowProvisioned bool) (string, error) {
Expand Down
Loading
Loading