Skip to content

Commit

Permalink
wip: zarf package
Browse files Browse the repository at this point in the history
  • Loading branch information
gphorvath committed Jul 19, 2024
1 parent 4eb7cb4 commit 1d9fb14
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ local-registry: ## Start up a local container registry. Errors in this target ar
# Clean up: Stop and remove the local registry
clean-registry:
@echo "Cleaning up..."
@docker stop registry
@docker stop ${REG_NAME}
@docker rm ${REG_NAME}

sdk-wheel: ## build wheels for the leapfrogai_sdk package as a dependency for other lfai components
Expand Down
2 changes: 1 addition & 1 deletion packages/k3d-gpu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COPY --from=k3s / / --exclude=/bin/
COPY --from=k3s /bin /bin

# Deploy the nvidia driver plugin on startup
COPY packages/k3d-gpu/plugin/device-plugin-daemonset.yaml /var/lib/rancher/k3s/server/manifests/nvidia-device-plugin-daemonset.yaml
COPY ./plugin/device-plugin-daemonset.yaml /var/lib/rancher/k3s/server/manifests/nvidia-device-plugin-daemonset.yaml

VOLUME /var/lib/kubelet
VOLUME /var/lib/rancher/k3s
Expand Down
4 changes: 2 additions & 2 deletions packages/k3d-gpu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
ORGANIZATION := defenseunicorns
PLATFORM := linux/amd64
TAG := latest
K3D_CLUSTER_NAME := k3d-core-slim-dev:0.24.0
UDS_CORE := k3d-core-slim-dev:0.24.0
K3S_TAG := $(shell jq -r .k3s_tag ${MAKEFILE_DIR}/version_config.json)
CUDA_TAG := $(shell jq -r .cuda_tag ${MAKEFILE_DIR}/version_config.json)

Expand Down Expand Up @@ -36,7 +36,7 @@ push-k3d-gpu: local-registry build-k3d-gpu
@docker push localhost:${REG_PORT}/${ORGANIZATION}/k3d-gpu-support:${TAG}

uds-gpu-cluster: local-registry build-k3d-gpu push-k3d-gpu
uds deploy ${K3D_CLUSTER_NAME} --set K3D_EXTRA_ARGS="--gpus=all --image=localhost:${REG_PORT}/${ORGANIZATION}/k3d-gpu-support:${TAG}" --confirm
uds deploy ${UDS_CORE} --set K3D_EXTRA_ARGS="--gpus=all --image=localhost:${REG_PORT}/${ORGANIZATION}/k3d-gpu-support:${TAG}" --confirm

test-k3d-gpu:
@uds zarf tools kubectl apply -f ${MAKEFILE_DIR}/test/cuda-vector-add.yaml
Expand Down
7 changes: 7 additions & 0 deletions packages/k3d-gpu/zarf-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package:
create:
set:
# x-release-please-start-version
version: 0.9.1
# x-release-please-end
reg_name: registry
91 changes: 91 additions & 0 deletions packages/k3d-gpu/zarf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/defenseunicorns/zarf/main/zarf.schema.json

kind: ZarfPackageConfig
metadata:
name: "k3d-gpu"
version: '###ZARF_PKG_TMPL_VERSION###'
description: >
k3d base image with GPU support
variables:
- name: REG_PORT
description: "Local registry port"
default: "5000"
- name: UDS_CORE
description: "UDS Core version to use"
default: "k3d-core-slim-dev:0.24.0"
- name: K3S_TAG
description: "K3s version to use"
default: "v1.28.8-k3s1"
- name: CUDA_TAG
description: "CUDA version to use"
default: "12.4.1-base-ubuntu22.04"

components:
- name: create-local-registry
required: true
actions:
onDeploy:
before:
- cmd: |
set +e
docker run -d --name ###ZARF_PKG_TMPL_REG_NAME### -p ${ZARF_VAR_REG_PORT}:5000 registry:2
set -e
description: "Start the local registry"
mute: true
onRemove:
before:
- cmd: |
set +e
docker stop ###ZARF_PKG_TMPL_REG_NAME###
docker rm ###ZARF_PKG_TMPL_REG_NAME###
set -e
description: "Stop and remove the local registry"
mute: true
- name: build-image
required: true
files:
- source: Dockerfile
target: Dockerfile
- source: plugin/device-plugin-daemonset.yaml
target: plugin/device-plugin-daemonset.yaml
actions:
onDeploy:
before:
- cmd: |
docker build \
--platform linux/amd64 \
--build-arg K3S_TAG=${ZARF_VAR_K3S_TAG} \
--build-arg CUDA_TAG=${ZARF_VAR_CUDA_TAG} \
-t ghcr.io/defenseunicorns/leapfrogai/k3d-gpu:###ZARF_PKG_TMPL_VERSION### \
-f ./Dockerfile .
docker tag \
ghcr.io/defenseunicorns/leapfrogai/k3d-gpu:###ZARF_PKG_TMPL_VERSION### \
localhost:${ZARF_VAR_REG_PORT}/defenseunicorns/leapfrogai/k3d-gpu:###ZARF_PKG_TMPL_VERSION###
description: "Build the k3d-gpu image"
# mute: true
after:
- cmd:
docker push localhost:${ZARF_VAR_REG_PORT}/defenseunicorns/leapfrogai/k3d-gpu:###ZARF_PKG_TMPL_VERSION###
description: "Push the image to the local registry"
mute: true

- name: create-cluster
required: true
actions:
onDeploy:
before:
- cmd: |
uds deploy ${ZARF_VAR_UDS_CORE} \
--set K3D_EXTRA_ARGS="--gpus=all \
--image=localhost:${ZARF_VAR_REG_PORT}/defenseunicorns/leapfrogai/k3d-gpu:###ZARF_PKG_TMPL_VERSION###" \
--no-progress --insecure --confirm
description: "Create a k3d cluster with GPU support"
onRemove:
before:
- cmd: |
k3d cluster delete uds
description: "Delete the k3d cluster"
mute: true

0 comments on commit 1d9fb14

Please sign in to comment.