Skip to content
Open
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
20 changes: 10 additions & 10 deletions api/holodeck/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,16 @@ const (
type Kubernetes struct {
Install bool `json:"install"`
// KubeConfig is the path to the kubeconfig file on the local machine
KubeConfig string `json:"kubeConfig"`
KubernetesFeatures []string `json:"Features"`
KubernetesVersion string `json:"Version"`
KubernetesInstaller string `json:"Installer"`
KubeletReleaseVersion string `json:"KubeletReleaseVersion"`
Arch string `json:"Arch"`
CniPluginsVersion string `json:"CniPluginsVersion"`
CalicoVersion string `json:"CalicoVersion"`
CrictlVersion string `json:"CrictlVersion"`
K8sEndpointHost string `json:"K8sEndpointHost"`
Config string `json:"kubeConfig"`
Features []string `json:"Features"`
Version string `json:"Version"`
KindVersion string `json:"KindVersion"`
Installer string `json:"Installer"`
Arch string `json:"Arch"`
CniPluginsVersion string `json:"CniPluginsVersion"`
CalicoVersion string `json:"CalicoVersion"`
CrictlVersion string `json:"CrictlVersion"`
K8sEndpointHost string `json:"K8sEndpointHost"`
// A set of key=value pairs that describe feature gates for
// alpha/experimental features
K8sFeatureGates []string `json:"K8sFeatureGates"`
Expand Down
4 changes: 2 additions & 2 deletions api/holodeck/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions cmd/cli/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,14 @@ func runProvision(log *logger.FunLogger, opts *options) error {
}

// 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" {
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{
"microk8s": true,
"kind": true,
"nvkind": true,
}
if doesNotSupportKubeconfigRetrieval[opts.cfg.Spec.Kubernetes.Installer] {
log.Warning("kubeconfig retrieval is not supported for %s, skipping kubeconfig download", opts.cfg.Spec.Kubernetes.Installer)
return nil
}

Expand Down
16 changes: 10 additions & 6 deletions pkg/provisioner/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
const (
kubeadmInstaller = "kubeadm"
kindInstaller = "kind"
nvkindInstaller = "nvkind"
microk8sInstaller = "microk8s"
containerdRuntime = "containerd"
crioRuntime = "crio"
Expand All @@ -37,9 +38,10 @@

var (
functions = map[string]ProvisionFunc{
kubeadmInstaller: kubeadm,
kindInstaller: kind,
microk8sInstaller: microk8s,
kubeadmInstaller: k8s,
kindInstaller: k8s,
nvkindInstaller: k8s,
microk8sInstaller: k8s,
containerdRuntime: containerd,
crioRuntime: criO,
dockerRuntime: docker,
Expand Down Expand Up @@ -76,7 +78,7 @@
return containerToolkit.Execute(tpl, env)
}

func kubeadm(tpl *bytes.Buffer, env v1alpha1.Environment) error {
func k8s(tpl *bytes.Buffer, env v1alpha1.Environment) error {
kubernetes, err := templates.NewKubernetes(env)
if err != nil {
return err
Expand All @@ -84,7 +86,7 @@
return kubernetes.Execute(tpl, env)
}

func microk8s(tpl *bytes.Buffer, env v1alpha1.Environment) error {

Check failure on line 89 in pkg/provisioner/dependency.go

View workflow job for this annotation

GitHub Actions / check

func microk8s is unused (unused)

Check failure on line 89 in pkg/provisioner/dependency.go

View workflow job for this annotation

GitHub Actions / golang / check

func microk8s is unused (unused)
microk8s, err := templates.NewKubernetes(env)
if err != nil {
return err
Expand All @@ -92,7 +94,7 @@
return microk8s.Execute(tpl, env)
}

func kind(tpl *bytes.Buffer, env v1alpha1.Environment) error {

Check failure on line 97 in pkg/provisioner/dependency.go

View workflow job for this annotation

GitHub Actions / check

func kind is unused (unused)

Check failure on line 97 in pkg/provisioner/dependency.go

View workflow job for this annotation

GitHub Actions / golang / check

func kind is unused (unused)
kind, err := templates.NewKubernetes(env)
if err != nil {
return err
Expand Down Expand Up @@ -133,17 +135,19 @@
}

func (d *DependencyResolver) withKubernetes() {
switch d.env.Spec.Kubernetes.KubernetesInstaller {
switch d.env.Spec.Kubernetes.Installer {
case kubeadmInstaller:
d.Dependencies = append(d.Dependencies, functions[kubeadmInstaller])
case kindInstaller:
d.Dependencies = append(d.Dependencies, functions[kindInstaller])
case nvkindInstaller:
d.Dependencies = append(d.Dependencies, functions[nvkindInstaller])
Comment on lines +143 to +144
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.

case microk8sInstaller:
// reset the list to only include microk8s
d.Dependencies = nil
d.Dependencies = append(d.Dependencies, functions[microk8sInstaller])
default:
// default to kubeadm if KubernetesInstaller is empty
// default to kubeadm if Installer is empty
d.Dependencies = append(d.Dependencies, functions[kubeadmInstaller])
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/provisioner/dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestDependencyResolver_WithKubernetes(t *testing.T) {
env := v1alpha1.Environment{
Spec: v1alpha1.EnvironmentSpec{
Kubernetes: v1alpha1.Kubernetes{
KubernetesInstaller: "kubeadm",
Installer: "kubeadm",
},
},
}
Expand Down Expand Up @@ -78,8 +78,8 @@ func TestDependencyResolver_Resolve(t *testing.T) {
env := v1alpha1.Environment{
Spec: v1alpha1.EnvironmentSpec{
Kubernetes: v1alpha1.Kubernetes{
Install: true,
KubernetesInstaller: "kubeadm",
Install: true,
Installer: "kubeadm",
},
ContainerRuntime: v1alpha1.ContainerRuntime{
Install: true,
Expand Down
10 changes: 4 additions & 6 deletions pkg/provisioner/dryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ func Dryrun(log *logger.FunLogger, env v1alpha1.Environment) error {

go log.Loading("Resolving dependencies \U0001F4E6\n")
// Kubernetes -> Container Toolkit -> Container Runtime -> NVDriver
if env.Spec.Kubernetes.Install && env.Spec.Kubernetes.KubernetesInstaller == "kubeadm" {
if env.Spec.Kubernetes.Install && env.Spec.Kubernetes.Installer == "kubeadm" {
// check if env.Spec.Kubernetes.KubernetesVersion is in the format of vX.Y.Z
if env.Spec.Kubernetes.KubernetesVersion != "" {
if !strings.HasPrefix(env.Spec.Kubernetes.KubernetesVersion, "v") {
log.Fail <- struct{}{}
return fmt.Errorf("kubernetes version %s is not in the format of vX.Y.Z", env.Spec.Kubernetes.KubernetesVersion)
}
if env.Spec.Kubernetes.Installer == "kubeadm" && !strings.HasPrefix(env.Spec.Kubernetes.Version, "v") {
log.Fail <- struct{}{}
return fmt.Errorf("kubernetes version %s is not in the format of vX.Y.Z", env.Spec.Kubernetes.Version)
}
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/provisioner/dryrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ func TestDryrun_ValidKubernetesVersion(t *testing.T) {
env := v1alpha1.Environment{
Spec: v1alpha1.EnvironmentSpec{
Kubernetes: v1alpha1.Kubernetes{
Install: true,
KubernetesInstaller: "kubeadm",
KubernetesVersion: "v1.20.0",
Install: true,
Installer: "kubeadm",
Version: "v1.20.0",
},
},
}
Expand All @@ -28,9 +28,9 @@ func TestDryrun_InvalidKubernetesVersion(t *testing.T) {
env := v1alpha1.Environment{
Spec: v1alpha1.EnvironmentSpec{
Kubernetes: v1alpha1.Kubernetes{
Install: true,
KubernetesInstaller: "kubeadm",
KubernetesVersion: "1.20.0",
Install: true,
Installer: "kubeadm",
Version: "1.20.0",
},
},
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (p *Provisioner) Run(env v1alpha1.Environment) error {
dependencies := NewDependencies(env)

// Create kubeadm config file if required installer is kubeadm and not using legacy mode
if env.Spec.Kubernetes.KubernetesInstaller == "kubeadm" {
if env.Spec.Kubernetes.Installer == "kubeadm" {
// Set the k8s endpoint host to the host url
env.Spec.Kubernetes.K8sEndpointHost = p.HostUrl

Expand All @@ -140,12 +140,16 @@ func (p *Provisioner) Run(env v1alpha1.Environment) error {

// kind-config
// Create kind config file if it is provided
if env.Spec.Kubernetes.KubernetesInstaller == "kind" && env.Spec.Kubernetes.KindConfig != "" {
if (env.Spec.Kubernetes.Installer == "kind" || env.Spec.Kubernetes.Installer == "nvkind") && env.Spec.Kubernetes.KindConfig != "" {
if err := p.createKindConfig(env); err != nil {
return fmt.Errorf("failed to create kind config file: %v", err)
}
}

if env.Spec.Kubernetes.Installer == "kubeadm" {
env.Spec.Kubernetes.K8sEndpointHost = p.HostUrl
}

for _, node := range dependencies.Resolve() {
// Add script header and common functions to the script
if err := addScriptHeader(&p.tpl); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/provisioner/templates/container-toolkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dear
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list \
&& \
sudo apt-get update
with_retry 3 10s sudo apt-get update

sudo apt-get install -y nvidia-container-toolkit
install_packages_with_retry nvidia-container-toolkit

# Configure container runtime
sudo nvidia-ctk runtime configure --runtime={{.ContainerRuntime}} --set-as-default --enable-cdi={{.EnableCDI}}
Expand Down
4 changes: 2 additions & 2 deletions pkg/provisioner/templates/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const dockerTemplate = `
: ${DOCKER_VERSION:={{.Version}}}

# Add Docker's official GPG key:
sudo apt-get update
with_retry 3 10s sudo apt-get update
install_packages_with_retry ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Expand All @@ -41,7 +41,7 @@ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
with_retry 3 10s sudo apt-get update

# if DOCKER_VERSION is latest, then install latest version, else install specific version
if [ "$DOCKER_VERSION" = "latest" ]; then
Expand Down
Loading
Loading