Documentation
¶
Index ¶
- Constants
- func CreateImagePullSecret(ctx context.Context, c client.Client, ...) (string, bool, error)
- func DeleteRunBinding(ctx context.Context, c client.Client, namespace string, out io.Writer) error
- func EnsureNamespace(ctx context.Context, c client.Client, name string, out io.Writer) (bool, error)
- func EnsureRunBinding(ctx context.Context, c client.Client, namespace string, opts RunBindingOptions, ...) (bool, error)
- func NewCommand(version string) *cobra.Command
- func ReleaseRunBinding(ctx context.Context, c client.Client, namespace string, runGone bool, ...) (warned, retry bool)
- func RunInit(version string, image, imagePullSecret, skipPhases string, autoApprove bool, ...) error
- func RunInitWithValues(version string, image, imagePullSecret, skipPhases string, autoApprove bool, ...) error
- func RunReset(skipPhases string, autoApprove bool, configFlags *kubeconfig.ConfigFlags, ...) error
- func WaitForNamespaceDeletion(ctx context.Context, c client.Client, name string, out io.Writer)
- func WorkloadPullSecretName(resourceName string) string
- type ChartValues
- type HelmReleaseStatus
- type RunBindingOptions
- type SetupStatus
- type SetupStatusComponents
- type TrainerVersionStatus
Constants ¶
const RunBindingRollbackTimeout = 30 * time.Second
RunBindingRollbackTimeout bounds releasing a binding after a failed submit. The release runs on its own context, because an interrupt that cancelled the submit would otherwise cancel the release too.
Variables ¶
This section is empty.
Functions ¶
func CreateImagePullSecret ¶
func CreateImagePullSecret(ctx context.Context, c client.Client, namespace, secretName, server, username, password string) (string, bool, error)
CreateImagePullSecret creates a dockerconfigjson Secret for the given registry. server is the registry hostname (e.g. "nvcr.io", "ghcr.io"). username is the registry username (e.g. "$oauthtoken" for NGC, "token" for GHCR). password is the registry password or API key. secretName is the name to give the created Secret. Returns (secretName, wasCreated, error) where wasCreated is true only when a new Secret was created — false means an existing Secret was updated. Callers must only delete the secret on rollback when wasCreated is true.
func DeleteRunBinding ¶ added in v0.8.0
DeleteRunBinding deletes a RoleBinding EnsureRunBinding created. Call it only once the run object is fully deleted: its finalizers write in the namespace until then.
func EnsureNamespace ¶
func EnsureNamespace(ctx context.Context, c client.Client, name string, out io.Writer) (bool, error)
EnsureNamespace creates a namespace if it doesn't exist. Returns true if the namespace was created by this call (false if it already existed).
func EnsureRunBinding ¶ added in v0.8.0
func EnsureRunBinding(ctx context.Context, c client.Client, namespace string, opts RunBindingOptions, out io.Writer) (bool, error)
EnsureRunBinding makes sure the controller can write in namespace before a run is submitted there (ADR-092), and reports whether it created a RoleBinding that the caller now owns.
It does nothing when no per-namespace binding is needed: the chart was installed with rbac.scope: cluster, or predates the role split. Otherwise it adopts an existing nvcre-manager-run binding, or creates one, but only in a namespace this run created or with --grant-run-access. In a namespace that already existed it refuses, so a shared namespace such as default never becomes a standing grant without the user asking, and the error carries the manifest.
The create runs with the user's credentials. Kubernetes allows it only if the user holds every permission in nvcre-run-role within the namespace, or has bind on the role.
func NewCommand ¶
NewCommand returns the "setup" cobra command. version is the running binary version and is threaded through to init/upgrade operations.
func ReleaseRunBinding ¶ added in v0.8.0
func ReleaseRunBinding( ctx context.Context, c client.Client, namespace string, runGone bool, runKind string, out io.Writer, ) (warned, retry bool)
ReleaseRunBinding deletes, during cleanup, a RoleBinding EnsureRunBinding created in a namespace the run did not create. It reports whether it printed a warning, and whether the run should keep owning the binding because the release could not complete, so a later --cleanup tries again. runGone says whether the run object (runKind) is fully deleted: until it is, its finalizers write in the namespace and need the binding, so it is kept with a warning instead. It is also kept while any other run is still in the namespace: a later run adopts the binding rather than creating its own, so deleting it would take that run's access away, mid-run or in its finalizers. If the other runs cannot be listed, it is kept too, as is one another run adopted within the adoption lease, with a warning: the adopter does not release it, so if its run never comes the binding is left for the user to delete. Once another run uses or adopted the binding, retrying is pointless and the caller gives up ownership.
func RunInit ¶
func RunInit( version string, image, imagePullSecret, skipPhases string, autoApprove bool, configFlags *kubeconfig.ConfigFlags, versionOverride string, chartRef, trainerChartRef, rbacScope string, in io.Reader, out io.Writer, ) error
RunInit executes the init phases sequentially. chartRef and trainerChartRef override the chart locations the NVCRE and Kubeflow Trainer releases are installed from; empty means the published GHCR charts. rbacScope sets the chart's rbac.scope; empty keeps the installed release's value. It passes no chart values of its own; the installed release's values are kept (ADR-098). Use RunInitWithValues to pass chart values.
func RunInitWithValues ¶ added in v0.8.0
func RunInitWithValues( version string, image, imagePullSecret, skipPhases string, autoApprove bool, configFlags *kubeconfig.ConfigFlags, versionOverride string, chartRef, trainerChartRef, rbacScope string, values ChartValues, in io.Reader, out io.Writer, ) error
RunInitWithValues is RunInit with this run's chart values for the NVCRE release: --values, --set, --set-json and --reset-values (ADR-098).
func RunReset ¶
func RunReset( skipPhases string, autoApprove bool, configFlags *kubeconfig.ConfigFlags, in io.Reader, out io.Writer, ) error
runReset executes the reset phases in reverse order.
func WaitForNamespaceDeletion ¶
waitForNamespaceDeletion polls until a namespace is fully removed.
func WorkloadPullSecretName ¶
WorkloadPullSecretName returns the name of the workload image pull secret for a given Certification or WorkloadRun. Deriving from the resource name prevents concurrent runs in the same namespace from fighting over a single fixed name.
Types ¶
type ChartValues ¶ added in v0.8.0
type ChartValues struct {
Files []string
SetJSON []string
Set []string
// Reset drops the installed release's values except rbac.scope and
// rbac.runNamespaces.
Reset bool
}
ChartValues are the chart values `setup init` passes to the NVCRE release (ADR-098): Helm's --values, --set-json and --set, in Helm's syntax, and --reset-values. They never reach the Kubeflow Trainer release.
type HelmReleaseStatus ¶
type HelmReleaseStatus struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
// State is the release state helm reports ("deployed", "failed",
// "pending-upgrade", ...), "not installed" when helm has no record of
// the release, or "unknown" when the query could not be completed.
State string `json:"state"`
}
HelmReleaseStatus reports the Helm state of one managed release.
type RunBindingOptions ¶ added in v0.8.0
type RunBindingOptions struct {
// NamespaceCreated is true when this nvcrectl invocation created the
// namespace. Deleting the namespace then removes the binding with it.
NamespaceCreated bool
// Grant is --grant-run-access: create the binding in a namespace that
// already existed, which leaves a standing grant there.
Grant bool
}
RunBindingOptions says how a run namespace came to be and what the user allowed, which together decide whether EnsureRunBinding may create a binding there.
type SetupStatus ¶
type SetupStatus struct {
// Installed is true when all required components are present and ready
// and no managed Helm release is in a failed or pending state.
Installed bool `json:"installed"`
Components SetupStatusComponents `json:"components"`
// KubeflowTrainerVersion reports the detected Kubeflow Trainer version
// against the version this build supports. Nil when the TrainJob CRD is
// not installed.
KubeflowTrainerVersion *TrainerVersionStatus `json:"kubeflowTrainerVersion,omitempty"`
// HelmReleases reports the state of the Helm releases setup init manages.
HelmReleases []HelmReleaseStatus `json:"helmReleases"`
// contains filtered or unexported fields
}
SetupStatus is the JSON output structure for nvcrectl setup status.
type SetupStatusComponents ¶
type SetupStatusComponents struct {
NVCRECRDs bool `json:"nvcreCRDs"`
NVCREController bool `json:"nvcreController"`
KubeflowTrainer bool `json:"kubeflowTrainer"`
LogProfiles bool `json:"logProfiles"`
GPUOperator bool `json:"gpuOperator"`
// DCGM is optional. Only the diagnostics/dcgm-level4 category needs it,
// so it does not count toward Installed.
DCGM bool `json:"dcgm"`
}
SetupStatusComponents reports the status of each individual component.
type TrainerVersionStatus ¶
type TrainerVersionStatus struct {
// Supported is the Trainer version this NVCRE build supports.
Supported string `json:"supported"`
// Detected is the installed Trainer version, empty when it could not be
// determined.
Detected string `json:"detected,omitempty"`
// Source names where Detected came from: "helm release", "deployment
// image", or "crd label".
Source string `json:"source,omitempty"`
}
TrainerVersionStatus reports the installed Kubeflow Trainer version against the version this NVCRE build is pinned to.