Skip to content

Conversation

@ArangoGutierrez
Copy link
Collaborator

@ArangoGutierrez ArangoGutierrez commented Feb 15, 2025

This patch adds support for nvkind as kubernetes installer type, allowing users to do the following on the config file

  kubernetes:
    install: true
    version: v1.32.0
    installer: nvkind

sudo install ./kind /usr/local/bin/kind
# Install docker buildx, needed for building the kind image
install_packages_with_retry docker-buildx-plugin

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retries like this can save so much time/noise down the line. Nice.

Where do the retry helpers used in this PR come from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sudo systemctl restart docker
# install nvkind
go install github.com/NVIDIA/nvkind/cmd/nvkind@latest
Copy link

@jgehrcke jgehrcke Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we maybe pin this to a specific commit? (and then explicitly bump, potentially often)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah thought the same, even I think we should make the case for a tag release of nvkind in a way that
nvkind tag -> kind tag
and we can have that relation be documented on the repo in a markdown file

// Download kubeconfig
if opts.cfg.Spec.Kubernetes.Install && (opts.cfg.Spec.Kubernetes.KubeConfig != "" || opts.kubeconfig != "") {
if opts.cfg.Spec.Kubernetes.KubernetesInstaller == "microk8s" || opts.cfg.Spec.Kubernetes.KubernetesInstaller == "kind" {
if opts.cfg.Spec.Kubernetes.KubernetesInstaller == "microk8s" || opts.cfg.Spec.Kubernetes.KubernetesInstaller == "kind" || opts.cfg.Spec.Kubernetes.KubernetesInstaller == "nvkind" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This conditional is getting quite long. What about:

Suggested change
if opts.cfg.Spec.Kubernetes.KubernetesInstaller == "microk8s" || opts.cfg.Spec.Kubernetes.KubernetesInstaller == "kind" || opts.cfg.Spec.Kubernetes.KubernetesInstaller == "nvkind" {
doesNotSupportKubeconfigRetrieval := map[string]bool{
"mikrok8s": true,
"kind": true,
"nvkind": true,
}
if doesNotSupportKubeconfigRetrieval[opts.cfg.Spec.Kubernetes.KubernetesInstaller] {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adopted

# see https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl
cd $DOWNLOAD_DIR
sudo curl -L --remote-name-all https://dl.k8s.io/release/${K8S_VERSION}/bin/linux/${ARCH}/kubectl
sudo curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${ARCH}/kubectl"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we removed support for setting the k8s verison?

Also, could we have two separate curl commands instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just for kubectl; stable is ok. This is mostly to interact with the cluster after it is done.

fi
export PATH="/usr/local/go/bin:$HOME/go/bin:$PATH"
# Make
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states that we need Make. Do we really need build-essentials?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so that I'm clear. Is make required to run go install?

Comment on lines 224 to 233
# Build the kind node image.
# The default base image will be used unless it is specified using the
# KIND_BASE_IMAGE environment variable.
# This could be needed if new container runtime features are required.
# Examples are:
# gcr.io/k8s-staging-kind/base:v20240213-749005b2
# docker.io/kindest/base:v20240202-8f1494ea
kind build node-image \
--image "${KIND_IMAGE}" \
"${KIND_K8S_DIR}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it strictly required to build custom node images as part of this CI?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, removed

echo "ssh -i <your-private-key> ubuntu@${INSTANCE_ENDPOINT_HOST}"
`

const NVKindTemplate = `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this template, it seems as if we're duplicating the logic to install kind. Can we not have kind as a prerequisite for nvkind?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@jgehrcke
Copy link

Oh, and for myself but also for all of our future selves it will be nice to have a very pragmatic pull request description with the motivation and potential trade-offs! :)

I have dabbled with nvkind's code a bit, so I do understand some of its purpose. But I do not know why "support for nvkind" is relevant in the context of holodeck. Things I'd like to understand from a very high-level PR description: why does this project so far work without nvkind? Is the nvkind-based method replacing a less-ideal method, or is this adding an optional way of doing things? If yes, who would use it when?

I don't ask for an essay, really just two minutes of effort.

functions = map[string]ProvisionFunc{
kubeadmInstaller: kubeadm,
kindInstaller: kind,
NVKindInstaller: nvkind,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be:

Suggested change
NVKindInstaller: nvkind,
nvkindInstaller: nvkind,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, edited

const (
kubeadmInstaller = "kubeadm"
kindInstaller = "kind"
NVKindInstaller = "nvkind"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NVKindInstaller = "nvkind"
nvkindInstaller = "nvkind"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, edited

@ArangoGutierrez ArangoGutierrez force-pushed the nvkind branch 3 times, most recently from e8e5a50 to a1f464d Compare February 25, 2025 16:38
return kind.Execute(tpl, env)
}

func nvkind(tpl *bytes.Buffer, env v1alpha1.Environment) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that's strange here is that all these functions are the same. Why not have a single function for all k8s installers, or pull the differences into these functions?

Comment on lines +138 to +144
case nvkindInstaller:
d.Dependencies = append(d.Dependencies, functions[nvkindInstaller])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's strange that we have a dependency on kind for nvkind, but this is not defined here and is defined at a template level instead.

# Download kind
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-arm64
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.26.0/kind-linux-${ARCH}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the version here seems brittle.

Comment on lines 163 to 167
GO_VERSION="1.23.6"
wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz -O /tmp/go${GO_VERSION}.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf /tmp/go${GO_VERSION}.linux-amd64.tar.gz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really does seem like a strange place to install go.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since there's no official release for nvkind we are installing it via go install so this step is only needed for nvkind but not for kind

kubernetesTemplate := new(template.Template)

// load kind base template
kindBase := template.Must(template.New("common-functions").Parse(KindBaseTemplate))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we parse this template even though we don't need it?

@ArangoGutierrez
Copy link
Collaborator Author

@elezar Thanks for the review. All your comments have been addressed

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request adds support for the new "nvkind" Kubernetes installer type while refactoring several installer-related fields and updating dependency mappings and retry logic in various templates and commands.

  • Adds a new NVKind template and adjusts the template execution flow in the Kubernetes provisioner.
  • Refactors the installer field from "KubernetesInstaller" to "Installer" in API types and related logic.
  • Updates dependency mappings and command retry mechanisms to support NVKind and other installer types.

Reviewed Changes

File Description
pkg/provisioner/templates/kubernetes.go Introduces NVKind template support and updates existing Kind logic.
cmd/cli/create/create.go Updates kubeconfig retrieval logic and installer name matching.
pkg/provisioner/templates/docker.go Replaces apt-get updates with retry logic.
pkg/provisioner/templates/container-toolkit.go Replaces apt-get commands with retry and safer install commands.
pkg/provisioner/provisioner.go Updates installer field checks and Kind config file creation logic.
api/holodeck/v1alpha1/types.go Renames installer and version fields to align with new naming.
pkg/provisioner/dependency.go Adds NVKind support to dependency resolution and refactors function names.
pkg/provisioner/dryrun.go Updates installer field usage and version validation.
api/holodeck/v1alpha1/zz_generated.deepcopy.go Updates deep copy functions to reflect field name changes.

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

pkg/provisioner/templates/kubernetes.go:113

  • Shell script syntax error: missing space before the closing bracket. It should be formatted as: if [ -n "{{.KindConfig}}" ] ; then.
if [ -n "{{.KindConfig}}"]; then

cmd/cli/create/create.go:201

  • The installer key "mikrok8s" appears to be a typo and should likely be "microk8s" to align with the API naming.
"mikrok8s": true,

# Add Go to PATH
if ! grep -q 'export PATH="/usr/local/go/bin:$PATH"' ~/.bashrc; then
echo 'export PATH="/usr/local/go/bin:/$HOME/go/bin:$PATH"' >> ~/.bashrc
Copy link

Copilot AI Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exported PATH includes an extra slash before $HOME. It should be "$HOME/go/bin" instead of "/$HOME/go/bin".

Suggested change
echo 'export PATH="/usr/local/go/bin:/$HOME/go/bin:$PATH"' >> ~/.bashrc
echo 'export PATH="/usr/local/go/bin:$HOME/go/bin:$PATH"' >> ~/.bashrc

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR adds support for the new "nvkind" installer type for Kubernetes, updating configuration handling, templates, and dependency resolution accordingly. Key changes include:

  • Introducing a new NVKindTemplate with installation steps for nvkind.
  • Refactoring fields and switch-cases to use the unified "Installer" field.
  • Enhancing retry logic for package installations in multiple templates.

Reviewed Changes

File Description
pkg/provisioner/templates/kubernetes.go Added NVKindTemplate and modified installer switch-case and constants.
cmd/cli/create/create.go Adjusted kubeconfig retrieval logic and installer key mapping.
pkg/provisioner/templates/docker.go Wrapped apt-get update with a retry mechanism.
pkg/provisioner/templates/container-toolkit.go Updated retry and install package commands for container toolkit.
pkg/provisioner/provisioner.go Changed installer field usage and kind config creation logic.
api/holodeck/v1alpha1/types.go Renamed and realigned Kubernetes spec fields for consistency.
pkg/provisioner/dependency.go Updated dependency mapping and switch-case to support nvkind.
pkg/provisioner/dryrun.go Modified installer version check to use the updated "Installer" field.
api/holodeck/v1alpha1/zz_generated.deepcopy.go Updated deepcopy logic to reflect renamed field 'Features'.

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

pkg/provisioner/templates/kubernetes.go:113

  • Missing space before the closing bracket in the if statement may lead to a shell syntax error. Consider changing it to: if [ -n "{{.KindConfig}}" ]; then
if [ -n "{{.KindConfig}}"];

log.Warning("kubeconfig retrieval is not supported for %s, skipping kubeconfig download", opts.cfg.Spec.Kubernetes.KubernetesInstaller)
if opts.cfg.Spec.Kubernetes.Install && (opts.cfg.Spec.Kubernetes.Config != "" || opts.kubeconfig != "") {
doesNotSupportKubeconfigRetrieval := map[string]bool{
"mikrok8s": true,
Copy link

Copilot AI Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key 'mikrok8s' appears to be misspelled. It should likely be 'microk8s' to match the expected installer type.

Suggested change
"mikrok8s": true,
"microk8s": true,

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request adds support for NVKIND as a new Kubernetes installer type. Key changes include:

  • Adding a dedicated NVKind installation template and related logic.
  • Refactoring installer field names and logic across multiple packages.
  • Updating retry mechanisms for package installation commands.

Reviewed Changes

File Description
pkg/provisioner/templates/kubernetes.go Added NVKind template, renamed templates, and included installer logic for both kind and nvkind.
cmd/cli/create/create.go Adjusted kubeconfig retrieval logic to include nvkind installer.
pkg/provisioner/templates/docker.go Updated apt-get update commands to use a retry mechanism.
pkg/provisioner/templates/container-toolkit.go Replaced apt-get update with a retry mechanism and package installation improvements.
pkg/provisioner/provisioner.go Updated installer name references and kind config handling.
api/holodeck/v1alpha1/types.go Renamed fields to reflect updated installer model.
pkg/provisioner/dependency.go Revised dependency mapping to include nvkind and standardized installer function.
pkg/provisioner/dryrun.go Corrected installer field checks for kubeadm.
api/holodeck/v1alpha1/zz_generated.deepcopy.go Updated deepcopy function to use the new field naming.

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

pkg/provisioner/templates/kubernetes.go:113

  • The condition in the shell 'if' statement is missing a space before the closing bracket. It should be 'if [ -n "{{.KindConfig}}" ]; then' to ensure the bash syntax is correct.
if [ -n "{{.KindConfig}}"]; then

@ArangoGutierrez ArangoGutierrez requested a review from Copilot March 3, 2025 09:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR adds support for NVKIND as a new Kubernetes installer, enabling users to provision clusters with NVIDIA-specific configurations using nvkind.

  • Introduces a new installer option "nvkind" with its own template in pkg/provisioner/templates/kubernetes.go.
  • Updates dependency resolver, CLI kubeconfig retrieval logic, and related types to integrate NVKIND alongside existing installers.
  • Applies minor improvements for package installation retries in Docker and container toolkit templates.

Reviewed Changes

File Description
pkg/provisioner/templates/kubernetes.go Added NVKIND template and refactored installer handling.
cmd/cli/create/create.go Modified kubeconfig retrieval to support NVKIND.
pkg/provisioner/templates/docker.go Updated apt-get update commands with retry logic.
pkg/provisioner/templates/container-toolkit.go Applied retry logic and improved package installation syntax.
pkg/provisioner/provisioner.go Refactored installer property usage and kind config handling.
api/holodeck/v1alpha1/types.go Updated Kubernetes configuration fields to reflect new names.
pkg/provisioner/dependency.go Added NVKIND installer to the dependency resolver.
pkg/provisioner/dryrun.go Updated installer conditions for kubeadm with revised version usage.

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

pkg/provisioner/templates/kubernetes.go:113

  • Ensure proper spacing in the shell condition; there should be a space before the closing bracket (i.e., '[ -n "{{.KindConfig}}" ]') to avoid potential syntax errors.
if [ -n "{{.KindConfig}}"]; then

Comment on lines 165 to 179
wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz -O /tmp/go${GO_VERSION}.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf /tmp/go${GO_VERSION}.linux-amd64.tar.gz
Copy link

Copilot AI Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding the Linux amd64 Go binary in the NVKindTemplate may cause issues on non-amd64 systems; consider using an ARCH variable (similar to the KindBaseTemplate) to dynamically determine the correct binary URL.

Suggested change
wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz -O /tmp/go${GO_VERSION}.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf /tmp/go${GO_VERSION}.linux-amd64.tar.gz
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; fi
if [ "$ARCH" = "aarch64" ]; then ARCH="arm64"; fi
wget https://go.dev/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz -O /tmp/go${GO_VERSION}.linux-${ARCH}.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf /tmp/go${GO_VERSION}.linux-${ARCH}.tar.gz

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR adds support for a new installer type "nvkind" in the Kubernetes provisioning logic. Key changes include:

  • Extending template logic to support a new NVKind installation flow.
  • Updating installer field references and dependency resolutions to include nvkind.
  • Adjusting CLI and package-level functionality (e.g., retry logic for package installation and file updates) to support nvkind alongside existing installer types.

Reviewed Changes

File Description
pkg/provisioner/templates/kubernetes.go Refactors templates to include a new KindBaseTemplate and NVKindTemplate with nvkind installer support.
cmd/cli/create/create.go Updates kubeconfig retrieval logic to consider the nvkind installer.
pkg/provisioner/templates/docker.go Introduces retry logic for apt-get updates.
pkg/provisioner/templates/container-toolkit.go Adds retry and installation flag changes for container toolkit.
pkg/provisioner/provisioner.go Adjusts installer field references and kind-config creation to support nvkind.
pkg/provisioner/dependency.go Updates dependency mapping to route nvkind through the kubernetes template path.
api/holodeck/v1alpha1/types.go Renames and reorganizes Kubernetes API fields.
pkg/provisioner/dryrun.go Updates field reference in dry-run validation to match new API.
api/holodeck/v1alpha1/zz_generated.deepcopy.go Adapts deepcopy generation to reflect field name changes.

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

pkg/provisioner/templates/kubernetes.go:113

  • There is a syntax error due to a missing space before the closing bracket. Update the condition to: if [ -n "{{.KindConfig}}" ]; then.
if [ -n "{{.KindConfig}}"]; then

Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants