Skip to content

Commit 1c83fbd

Browse files
committed
WIP: Adds kind make target
Signed-off-by: Daneyon Hansen <[email protected]>
1 parent d2b3004 commit 1c83fbd

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed

.github/workflows/e2e.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
jobs:
2+
e2e-tests:
3+
runs-on: ubuntu-latest
4+
steps:
5+
- uses: actions/checkout@v3
6+
7+
# Set up Go, Kubectl, KinD, etc.
8+
- name: Set up Go
9+
uses: actions/setup-go@v3
10+
with:
11+
go-version: "1.20"
12+
13+
- name: Install kind
14+
uses: helm/[email protected]
15+
with:
16+
install_only: true
17+
version: ${{ inputs.kind-version }}
18+
- uses: azure/setup-kubectl@v4
19+
id: kubectl
20+
with:
21+
version: ${{ inputs.kubectl-version }}
22+
- uses: azure/setup-helm@v4
23+
with:
24+
version: ${{ inputs.helm-version }}
25+
26+
- name: Setup test env
27+
shell: bash
28+
env:
29+
CLUSTER_NAME: ${{ inputs.cluster-name }}
30+
CLUSTER_NODE_VERSION: ${{ inputs.kind-node-version }}
31+
ISTIO_VERSION: ${{ inputs.istio-version }}
32+
CONFORMANCE_VERSION: ${{ inputs.k8sgateway-api-version }}
33+
run: ./ci/kind/setup-kind.sh
34+
35+
- name: Run e2e tests
36+
env:
37+
HF_API_TOKEN: ${{ secrets.HF_API_TOKEN }}
38+
run: |
39+
# Start your test environment, e.g. a KinD cluster or ephemeral cluster
40+
# Then pass HF_API_TOKEN to your test harness, e.g.:
41+
make e2e

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ ifndef ignore-not-found
183183
ignore-not-found = false
184184
endif
185185

186+
.PHONY: kind
187+
kind: ## Install a kind cluster
188+
./ci/hack/kind.sh create
189+
190+
.PHONY: unkind
191+
unkind: ## Uninstall a kind cluster
192+
./ci/hack/kind.sh delete
193+
186194
.PHONY: install
187195
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
188196
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -

hack/kind.sh

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# The name of the kind cluster
6+
CLUSTER_NAME="${CLUSTER_NAME:-"kind"}"
7+
8+
# Function to check if a command exists
9+
command_exists() {
10+
command -v "$1" >/dev/null 2>&1
11+
}
12+
13+
# Function to display usage information
14+
usage() {
15+
echo "Usage: $0 [create|delete]"
16+
exit 1
17+
}
18+
19+
# Check if kubectl is installed
20+
if ! command_exists kubectl; then
21+
echo "kubectl is not installed. Please install kubectl before running this script."
22+
exit 1
23+
fi
24+
25+
# Check if kind is installed
26+
if ! command_exists kind; then
27+
echo "kind is not installed. Please install kind before running this script."
28+
exit 1
29+
fi
30+
31+
# Check if helm is installed
32+
if ! command_exists helm; then
33+
echo "helm is not installed. Please install helm before running this script."
34+
exit 1
35+
fi
36+
37+
# Check the argument
38+
if [ $# -ne 1 ]; then
39+
usage
40+
fi
41+
42+
ACTION=$1
43+
44+
# Validate input argument
45+
if [ "$ACTION" != "create" ] && [ "$ACTION" != "delete" ]; then
46+
echo "Invalid argument. Please use 'create' or 'delete'."
47+
usage
48+
fi
49+
50+
# Check if the cluster already exists
51+
CLUSTER_EXISTS=$(kind get clusters)
52+
53+
# Handle the case where no clusters are found
54+
if [[ "$CLUSTER_EXISTS" == "No kind clusters found." ]]; then
55+
CLUSTER_EXISTS=""
56+
fi
57+
58+
if [ "$ACTION" == "create" ]; then
59+
if echo "$CLUSTER_EXISTS" | grep -qw "$CLUSTER_NAME"; then
60+
echo "Cluster '$CLUSTER_NAME' already exists. Exiting."
61+
exit 1
62+
fi
63+
64+
# Cluster configuration YAML
65+
cat <<EOF > kind-config.yaml
66+
apiVersion: kind.x-k8s.io/v1alpha4
67+
kind: Cluster
68+
nodes:
69+
- role: control-plane
70+
image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
71+
# required for GPU workaround (https://github.com/NVIDIA/nvidia-docker/issues/614#issuecomment-423991632)
72+
extraMounts:
73+
- hostPath: /dev/null
74+
containerPath: /var/run/nvidia-container-devices/all
75+
EOF
76+
77+
# Create the kind cluster
78+
echo "Creating kind cluster..."
79+
kind create cluster --name "$CLUSTER_NAME" --config kind-config.yaml
80+
81+
# Cleanup
82+
rm kind-config.yaml
83+
84+
echo "Kind cluster created successfully."
85+
86+
echo "Implementing nvidia-docker/issues/614 workaround..."
87+
docker exec -ti $CLUSTER_NAME-control-plane ln -s /sbin/ldconfig /sbin/ldconfig.real
88+
89+
echo "Installing Nvidia GPU operator..."
90+
helm repo add nvidia https://helm.ngc.nvidia.com/nvidia || true
91+
helm repo update
92+
helm install --wait --generate-name \
93+
-n gpu-operator --create-namespace \
94+
nvidia/gpu-operator --set driver.enabled=false
95+
96+
echo "Installation completed successfully."
97+
98+
elif [ "$ACTION" == "delete" ]; then
99+
if [ -z "$CLUSTER_EXISTS" ]; then
100+
echo "Cluster '$CLUSTER_NAME' does not exist. Exiting."
101+
exit 1
102+
fi
103+
104+
# Delete the kind cluster
105+
echo "Deleting kind cluster..."
106+
kind delete cluster --name "$CLUSTER_NAME"
107+
108+
echo "Kind cluster deleted successfully."
109+
fi

0 commit comments

Comments
 (0)