Files
nvke/cli/internal/deploypath/deploypath.go
Lia 1dbd483a98 docs: the install pages follow the operator guide; the Deploy Path reference (#1616)
* docs: the install guide, the deploy README and the pages that point at the install

docs/site-bootstrap/install-site-controller.md describes
deploy/nvke-deploy.sh install: its inputs, the six steps, removal,
upgrade and the GitOps mapping. deploy/README.md lists every flag and
variable of the script. The first-cluster page, the docs index and the
site-bootstrap pages that pointed at deploy/install.sh point at the
command. The site spec reference and the e2e README no longer mention
a registry pull secret.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs(cli): user-flow follows the real order: release, site spec, bootstrap, one install command

The example starts with nvkr release verify and export, bootstraps the
site, then installs the controller stack with deploy/nvke-deploy.sh
install as one command. The deploy path is the interface and the script
is the reference executor; an operator can apply the items another way.
The command table replaces the two manual rows with that command, and
the dead README anchor is gone.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: deploy-repository.md describes the deploy path as implemented

The page described tooling that no longer exists: a Go binary that
cloned a deploy repository and shipped it to the init node, ArgoCD items
with sync monitoring, a BootstrapConfig with database and monitoring
fields, and a deploy/reference directory. It now describes deploy/nico:
nvke-deploy.yaml, the four item types as nvke-deploy.sh applies them,
the template context the site spec supplies, what a render adds, and
what another executor has to do. The pages that linked to it as a
GitOps repository are updated with it.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: nvkectl comes from the NVKR release; build from source without one

The release carries nvkectl as an executable output built from the same
commit as the controller image. The install page takes it from there:
read the output's reference from the release description, pull it, and
unpack the binary. Building from the clone stays as the path without a
release. The GitHub Releases download is gone.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: the install guide offers the script, by hand and GitOps; the overview sends readers to it

The install guide's Release section is a paragraph with deep links to
NVKR's release quickstart. The install itself is three options that
apply the same deploy path: the script, the six steps by hand, and
GitOps. The overview's after-bootstrap section no longer tells readers
to install Cluster API and a provider first; the install does that, and
the page lists it as the fourth step.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: the site spec page opens with its two parts and shows what validate says between them

The bootstrap part is all the bootstrap requires; the controllerStack
section is read by the install and can stay unfilled until then. The
validation section shows the output on a freshly generated spec: the
bootstrap line, the values still to fill in, and the non-zero exit that
says the bootstrap can run now.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* refactor(deploy): drop the argocd item type; docs no longer say NVKE needs Argo CD

No deploy path has an argocd item and nothing tested the code that
applied one. A deploy path is template, manifest and helm items; a
GitOps tool delivers the same items, as the install guide's GitOps
option describes. The concepts, lifecycle and pre-provisioned-nodes
pages said the stack is managed by Argo CD and installed from a deploy
repository; they now point at the install from the deploy path.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: the install guide no longer lists an untaint step

The bootstrap removes the control-plane taint; the readiness check
reports one that is left.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: the install guide separates what the install does from what the operator does

Five steps: readiness, Cluster API, the site controller, secure, verify.
The StorageClass, the site registration and the client network policy
are the operator's, listed after the install with the commands. The
deploy README, the user flow and the nico README match.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: the site controller install is a list of commands

check-site.sh, clusterctl init, the executor, the release resources, the
exec-auth patch, then set-site and the network policy on the operator's
machine, each a command that stands on its own. The install guide gives
them in order with what each one does, how to take the executor apart,
and how a GitOps tool delivers the same items. The deploy README
describes check-site.sh and the executor; the user flow, the nico README
and the pages that pointed at a single command point at the list.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: review fixes on the install pages

The removal section deletes the stack's namespaces and says what that
removes and what stays. The lifecycle page no longer installs CAPNICo a
second time. The credential claims are limited to the controllerStack
file paths, with registry.apiKey left to the environment. The values
order names the files a render adds. The CLI's plain-HTTP NodePort is
called out as trusted-network only. jq and oras are named where the
release download uses them.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: review fixes on the install list

The release resources are published with nvkectl create, after the
site is registered; they are not manifests. The hand-apply and GitOps
recipes name helm dependency build for a path chart with a Chart.lock,
chart.setFile entries, and the nktp-cluster ConfigMap the base-config
item renders. The removal block pins its kubeconfig. The Deploy Path
page names the executor's one subcommand and says where an unknown item
type is refused. The first-cluster page folds the separate Cluster API
and CAPNICo install into the install guide's list and registers the
plain-HTTP NodePort. The nvkectl download filter accepts a description
whose executable output declares no architecture. Anchors fixed.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: nvkectl create writes the release resources through the site kubeconfig

The step needs the registration, which records the kubeconfig, and not
the network policy, which admits clients to the controller API.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: second review round on the install pages

The nico README publishes the release resources with nvkectl create
after set-site and leaves the taint to the bootstrap and the check. The
Deploy Path page names the executor's subcommand in its two examples.
The concepts page describes the PostgreSQL item rather than CNPG and
no longer names Argo CD as the GitOps controller. The local-run
sentence says what still comes from a repository and where images
land. The check prints the commands that remain. The GitOps section
says the render writes the per-site values. The validate sample shows
the trust-domain line. The custom base OS page no longer downloads
nvkectl from GitHub Releases.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: the install pages that stay point at the operator guide

The legacy site-bootstrap pages are left as they are on main; the
operator guide under docs/operate describes the install. The CLI docs,
the deploy READMEs, the concepts, lifecycle and first-cluster pages and
the Deploy Path reference link to it. The install page publishes the OS
release resources with nvkectl create after nvkectl points at the API,
and the artifacts page writes them as the metadata-and-spec documents
that command takes; the check's description names the kubeadm
providers it confirms.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: two links follow the install guide to the operator pages

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

* docs: third review round on the install pages

The executor's parser no longer accepts argocd, so both parsers refuse
an unknown type before anything is applied, as the Deploy Path page
says. The command lists in the deploy README and the user flow include
the NetworkPolicy step. The first-cluster page publishes a second
release rather than the first. The artifacts page lists nvkectl among
its prerequisites and names the kubeconfig the publish goes through.
The check prints the commands that remain. The deploy README's Cluster
API and egress rows say what the check reads.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Lia Campbell <liac@nvidia.com>

---------

Signed-off-by: Lia Campbell <liac@nvidia.com>
2026-10-14 11:59:55 -07:00

247 lines
7.6 KiB
Go

// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
// Package deploypath reads a deploy path: a directory holding nvke-deploy.yaml
// and one directory per item, as documented in
// docs/site-bootstrap/deploy-repository.md. It parses the item list and an
// item's release.yaml, and writes release.yaml back in the same grammar the
// shell-side reader (deploy/lib/nvke-deploy-items.py) accepts: one `key: value`
// per line under chart: and release:, `- key=path` under chart.setFile:,
// `- file` under values:, and one flow mapping per line under requires:.
package deploypath
import (
"bytes"
"errors"
"fmt"
"os"
"path/filepath"
"regexp"
"strings"
"gopkg.in/yaml.v3"
)
// Item types a deploy path lists.
const (
TypeTemplate = "template"
TypeManifest = "manifest"
TypeHelm = "helm"
)
// tokenPattern is an item name: letters, digits, `-`, `_` and inner dots.
// `.` and `..` are not names, and the shell reader accepts the same set.
var tokenPattern = regexp.MustCompile(`^[\w-]+(\.[\w-]+)*$`)
// Item is one entry of nvke-deploy.yaml.
type Item struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
}
type itemList struct {
Items []Item `yaml:"items"`
}
// Items reads nvke-deploy.yaml under dir and returns its items in order.
func Items(dir string) ([]Item, error) {
path := filepath.Join(dir, "nvke-deploy.yaml")
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
decoder := yaml.NewDecoder(bytes.NewReader(data))
decoder.KnownFields(true)
var list itemList
if err := decoder.Decode(&list); err != nil {
return nil, fmt.Errorf("%s: %w", path, err)
}
if len(list.Items) == 0 {
return nil, fmt.Errorf("%s: no items", path)
}
for _, item := range list.Items {
if !tokenPattern.MatchString(item.Name) {
return nil, fmt.Errorf("%s: item %q: names are tokens", path, item.Name)
}
switch item.Type {
case TypeTemplate, TypeManifest, TypeHelm:
default:
return nil, fmt.Errorf("%s: item %q has unknown type %q", path, item.Name, item.Type)
}
}
return list.Items, nil
}
// MarshalItems writes nvke-deploy.yaml's item list in the grammar the
// shell-side reader accepts, with a header naming the render.
func MarshalItems(items []Item, header string) []byte {
var b strings.Builder
if header != "" {
for _, line := range strings.Split(strings.TrimRight(header, "\n"), "\n") {
fmt.Fprintf(&b, "# %s\n", line)
}
}
b.WriteString("items:\n")
for _, item := range items {
fmt.Fprintf(&b, " - {name: %s, type: %s}\n", item.Name, item.Type)
}
return []byte(b.String())
}
// Chart is the chart: section of a helm item's release.yaml.
type Chart struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Repository string `yaml:"repository,omitempty"`
Path string `yaml:"path,omitempty"`
// Artifact, ImageArtifact and ProfilesArtifact bind the item to the
// artifacts of an NVKR release: the chart (default: the item name), the
// image the chart runs, and its profiles content image.
Artifact string `yaml:"artifact,omitempty"`
ImageArtifact string `yaml:"imageArtifact,omitempty"`
ProfilesArtifact string `yaml:"profilesArtifact,omitempty"`
// SetFile lists <helm key>=<absolute path> entries the executor passes
// as --set-file, so a file the operator holds is read at install time
// and never copied into the deploy path.
SetFile []string `yaml:"setFile,omitempty"`
}
// HelmRelease is the release: section.
type HelmRelease struct {
Name string `yaml:"name"`
Namespace string `yaml:"namespace"`
}
// Require is one requires: entry: an object that must exist and reach a
// condition before the item installs.
type Require struct {
Kind string `yaml:"kind"`
Name string `yaml:"name"`
Namespace string `yaml:"namespace"`
Condition string `yaml:"condition"`
}
// Release is an item's release.yaml. A helm item fills Chart, HelmRelease,
// Values and Requires; a manifest item fills Image and Artifact.
type Release struct {
Chart *Chart `yaml:"chart,omitempty"`
Release *HelmRelease `yaml:"release,omitempty"`
Values []string `yaml:"values,omitempty"`
Requires []Require `yaml:"requires,omitempty"`
// Image is the image a manifest item's committed YAML runs, as
// repository:tag; Artifact is the NVKR artifact that publishes it.
Image string `yaml:"image,omitempty"`
Artifact string `yaml:"artifact,omitempty"`
}
// ReadRelease parses release.yaml under an item directory.
func ReadRelease(itemDir string) (*Release, error) {
path := filepath.Join(itemDir, "release.yaml")
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
decoder := yaml.NewDecoder(bytes.NewReader(data))
decoder.KnownFields(true)
var r Release
if err := decoder.Decode(&r); err != nil {
return nil, fmt.Errorf("%s: %w", path, err)
}
if err := r.validate(); err != nil {
return nil, fmt.Errorf("%s: %w", path, err)
}
return &r, nil
}
func (r *Release) validate() error {
if r.Chart == nil {
if r.Image != "" {
last := r.Image[strings.LastIndex(r.Image, "/")+1:]
name, tag, ok := strings.Cut(last, ":")
if !ok || name == "" || tag == "" || strings.Contains(r.Image, "@") {
return fmt.Errorf("image must be <repository>:<tag>, with no digest: %s", r.Image)
}
}
return nil
}
if r.Chart.Name == "" {
return errors.New("chart.name is required")
}
if r.Chart.Repository != "" && r.Chart.Path != "" {
return errors.New("chart has both repository and path; name one source")
}
// A repository chart is selected by its version. A path chart carries
// its own, and a release that carries the chart decides it.
if r.Chart.Path == "" && r.Chart.Version == "" {
return errors.New("chart.version is required for a repository chart")
}
if r.Release == nil || r.Release.Name == "" || r.Release.Namespace == "" {
return errors.New("release.name and release.namespace are required")
}
for _, entry := range r.Chart.SetFile {
key, path, ok := strings.Cut(entry, "=")
if !ok || key == "" || !filepath.IsAbs(path) {
return fmt.Errorf("chart.setFile entry must be <helm key>=<absolute path>: %s", entry)
}
}
return nil
}
// Marshal writes release.yaml in the grammar the shell-side reader accepts.
func (r *Release) Marshal() []byte {
var b strings.Builder
if r.Chart != nil {
version := ""
if r.Chart.Version != "" {
version = quote(r.Chart.Version)
}
b.WriteString("chart:\n")
for _, kv := range [][2]string{
{"name", r.Chart.Name},
{"version", version},
{"repository", r.Chart.Repository},
{"path", r.Chart.Path},
{"artifact", r.Chart.Artifact},
{"imageArtifact", r.Chart.ImageArtifact},
{"profilesArtifact", r.Chart.ProfilesArtifact},
} {
if kv[1] != "" {
fmt.Fprintf(&b, " %s: %s\n", kv[0], kv[1])
}
}
if len(r.Chart.SetFile) > 0 {
b.WriteString(" setFile:\n")
for _, entry := range r.Chart.SetFile {
fmt.Fprintf(&b, " - %s\n", entry)
}
}
}
if r.Release != nil {
fmt.Fprintf(&b, "release:\n name: %s\n namespace: %s\n", r.Release.Name, r.Release.Namespace)
}
if len(r.Values) > 0 {
b.WriteString("values:\n")
for _, v := range r.Values {
fmt.Fprintf(&b, " - %s\n", v)
}
}
if len(r.Requires) > 0 {
b.WriteString("requires:\n")
for _, q := range r.Requires {
fmt.Fprintf(&b, " - {kind: %s, name: %s, namespace: %s, condition: %s}\n", q.Kind, q.Name, q.Namespace, q.Condition)
}
}
if r.Image != "" {
fmt.Fprintf(&b, "image: %s\n", r.Image)
}
if r.Artifact != "" && r.Chart == nil {
fmt.Fprintf(&b, "artifact: %s\n", r.Artifact)
}
return []byte(b.String())
}
// quote keeps a version a string, as the committed files do.
func quote(value string) string {
return `"` + value + `"`
}