Skip to content

Commit

Permalink
Merge pull request #2 from NVIDIA/kind
Browse files Browse the repository at this point in the history
Add Kind as kubernetes installer
  • Loading branch information
ArangoGutierrez authored Jan 23, 2024
2 parents 3d80bd6 + 4fc425d commit e982d75
Show file tree
Hide file tree
Showing 14 changed files with 479 additions and 139 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ IMAGE_TAG := $(IMAGE_REPO):$(IMAGE_TAG_NAME)
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

build:
@rm -rf bin
$(GO_CMD) build -o bin/$(BINARY_NAME) cmd/main.go

fmt:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ metadata:
spec:
provider: aws
auth:
keyName: eduardoa
privateKey: "/Users/eduardoa/.ssh/eduardoa.pem"
keyName: user
privateKey: "/Users/user/.ssh/user.pem"
instance:
hostUrl: "some-reachable-host-ip"
hostUrl: "<some-reachable-host-ip>"
```
## Usage
Expand All @@ -59,8 +59,8 @@ metadata:
spec:
provider: aws # or ssh for now
auth:
keyName: eduardoa
privateKey: "/Users/eduardoa/.ssh/eduardoa.pem"
keyName: user
privateKey: "/Users/user/.ssh/user.pem"
instance: # if provider is ssh you need to define here the hostUrl
type: g4dn.xlarge
region: eu-north-1
Expand All @@ -75,7 +75,7 @@ spec:
version: 1.6.24
kubernetes:
install: true
enable: true
installer: kubeadm # supported installers: kubeadm, kind
version: v1.28.5
```
Expand Down
9 changes: 9 additions & 0 deletions api/holodeck/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ type Kubernetes struct {
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"`
Expand All @@ -174,6 +175,14 @@ type Kubernetes struct {
// A set of key=value pairs that describe feature gates for
// alpha/experimental features
K8sFeatureGates []string `json:"K8sFeatureGates"`

// Kind exclusive
KindConfig string `json:"kindConfig"`
}

type ExtraPortMapping struct {
ContainerPort int `json:"containerPort"`
HostPort int `json:"hostPort"`
}

type NVContainerToolKit struct {
Expand Down
22 changes: 22 additions & 0 deletions examples/aws_kind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: holodeck.nvidia.com/v1alpha1
kind: Environment
metadata:
name: draKind
description: "DRA on Kind infra environment"
spec:
provider: aws
auth:
keyName: eduardoa
privateKey: "/Users/eduardoa/.ssh/eduardoa.pem"
instance:
type: g4dn.xlarge
region: eu-north-1
ingressIpRanges:
- 213.179.129.0/26
image:
architecture: amd64
imageId: ami-0fe8bec493a81c7da
kubernetes:
install: true
installer: kind
kindConfig: "./examples/kind.yaml"
64 changes: 64 additions & 0 deletions examples/kind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright 2023 The Kubernetes Authors.
# Copyright 2023 NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
featureGates:
DynamicResourceAllocation: true
containerdConfigPatches:
# Enable CDI as described in
# https://tags.cncf.io/container-device-interface#containerd-configuration
- |-
[plugins."io.containerd.grpc.v1.cri"]
enable_cdi = true
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: ClusterConfiguration
apiServer:
extraArgs:
runtime-config: "resource.k8s.io/v1alpha2=true"
scheduler:
extraArgs:
v: "1"
controllerManager:
extraArgs:
v: "1"
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
v: "1"
- role: worker
kubeadmConfigPatches:
- |
kind: JoinConfiguration
nodeRegistration:
kubeletExtraArgs:
v: "1"
extraMounts:
# We inject all NVIDIA GPUs using the nvidia-container-runtime.
# This requires `accept-nvidia-visible-devices-as-volume-mounts = true` be set
# in `/etc/nvidia-container-runtime/config.toml`
- hostPath: /dev/null
containerPath: /var/run/nvidia-container-devices/all
# The generated CDI specification assumes that `nvidia-ctk` is available on a
# node -- specifically for the `nvidia-ctk hook` subcommand. As a workaround,
# we mount it from the host.
# TODO: Remove this once we have a more stable solution to make `nvidia-ctk`
# on the kind nodes.
- hostPath: /usr/bin/nvidia-ctk
containerPath: /usr/bin/nvidia-ctk
3 changes: 1 addition & 2 deletions examples/v1alpha1_environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ spec:
containerRuntime:
install: true
name: containerd
version: 1.6.24
kubernetes:
install: true
enable: true
installer: kubeadm
version: v1.28.5
2 changes: 1 addition & 1 deletion pkg/provider/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func New(env v1alpha1.Environment, cacheFile string) (*Client, error) {
c := &Client{
[]types.Tag{
{Key: aws.String("Product"), Value: aws.String("Cloud Native")},
{Key: aws.String("Name"), Value: aws.String("devel")},
{Key: aws.String("Name"), Value: aws.String(env.Name)},
{Key: aws.String("Project"), Value: aws.String("holodeck")},
{Key: aws.String("Environment"), Value: aws.String("cicd")},
},
Expand Down
17 changes: 13 additions & 4 deletions pkg/provider/aws/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package aws

import (
"os"
"path/filepath"
"time"

"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -147,10 +148,18 @@ func update(env *v1alpha1.Environment, cachePath string) error {
return err
}

// if the cache directory doesn't exist, create it
_, err = os.Stat(cachePath)
if os.IsNotExist(err) {
err = os.MkdirAll(cachePath, 0755)
// if the cache file does not exist, check if the directory exists
// if the directory does not exist, create it
// if the directory exists, create the cache file
if _, err := os.Stat(cachePath); os.IsNotExist(err) {
dir := filepath.Dir(cachePath)
if _, err := os.Stat(dir); os.IsNotExist(err) {
err := os.MkdirAll(dir, 0755)
if err != nil {
return err
}
}
_, err := os.Create(cachePath)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit e982d75

Please sign in to comment.