Skip to content

Commit 1cda3df

Browse files
pkenchapprb112
authored andcommitted
Added scripts for the kind cluster support and readme
Signed-off-by: Punith Kenchappa <[email protected]>
1 parent b00d3fd commit 1cda3df

File tree

6 files changed

+161
-0
lines changed

6 files changed

+161
-0
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ $(CMD_TARGETS): cmd-%:
7676
CC=$(CC) CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) \
7777
go build -ldflags "-s -w -X $(CLI_VERSION_PACKAGE).gitCommit=$(GIT_COMMIT) -X $(CLI_VERSION_PACKAGE).version=$(VERSION)" $(COMMAND_BUILD_OPTIONS) $(MODULE)/cmd/$(*)
7878

79+
.PHONY: dev-setup
80+
dev-setup:
81+
dev/setup.sh
82+
83+
.PHONY: dev-clean
84+
dev-clean:
85+
dev/teardown.sh
86+
7987
########################################################################
8088
# Container Targets
8189

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ You must have Power10 or higher logical partitions that are part of your cluster
1818

1919
You should also be using an OpenShift Container Platform 4.19+.
2020

21+
## Kind cluster
22+
23+
To use the kind cluster in the power arch machine, run the script to create the kind cluster with single worker node.
24+
``` shell
25+
./dev/setup.sh
26+
```
27+
2128
## Install
2229

2330
To install the code, use:
@@ -38,6 +45,14 @@ To uninstall the code, use:
3845
helm uninstall power-dra-driver -n power-dra-driver
3946
```
4047

48+
## Delete the kind cluster
49+
50+
To delete the kind cluster created , run the script to delete it.
51+
52+
``` shell
53+
./dev/teardown.sh
54+
```
55+
4156
## License
4257

4358
All source files must include a Copyright and License header. The SPDX license header is

dev/common.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2023 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
# A reference to the current directory where this script is located
19+
SCRIPTS_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
20+
21+
# The name of the example driver
22+
: ${DRIVER_NAME:=power-dra-driver}
23+
24+
# The name of the kind cluster to create
25+
: ${KIND_CLUSTER_NAME:="${DRIVER_NAME}-cluster"}
26+
27+
# The path to kind's cluster configuration file
28+
: ${KIND_CLUSTER_CONFIG_PATH:="${SCRIPTS_DIR}/kind-cluster-config.yaml"}
29+
30+
# Container tool, e.g. docker/podman
31+
if [[ -z "${CONTAINER_TOOL}" ]]; then
32+
if [[ -n "$(which docker)" ]]; then
33+
echo "Docker found in PATH."
34+
CONTAINER_TOOL=docker
35+
elif [[ -n "$(which podman)" ]]; then
36+
echo "Podman found in PATH."
37+
CONTAINER_TOOL=podman
38+
else
39+
echo "No container tool detected. Please install Docker or Podman."
40+
return 1
41+
fi
42+
fi
43+
44+
: ${KIND:="env KIND_EXPERIMENTAL_PROVIDER=${CONTAINER_TOOL} kind"}

dev/kind-cluster-config.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
kind: Cluster
2+
apiVersion: kind.x-k8s.io/v1alpha4
3+
featureGates:
4+
DynamicResourceAllocation: true
5+
containerdConfigPatches:
6+
# Enable CDI as described in
7+
# https://tags.cncf.io/container-device-interface#containerd-configuration
8+
- |-
9+
[plugins."io.containerd.grpc.v1.cri"]
10+
enable_cdi = true
11+
nodes:
12+
- role: control-plane
13+
kubeadmConfigPatches:
14+
- |
15+
kind: ClusterConfiguration
16+
apiServer:
17+
extraArgs:
18+
runtime-config: "resource.k8s.io/v1beta1=true"
19+
scheduler:
20+
extraArgs:
21+
v: "1"
22+
controllerManager:
23+
extraArgs:
24+
v: "1"
25+
- |
26+
kind: InitConfiguration
27+
nodeRegistration:
28+
kubeletExtraArgs:
29+
v: "1"
30+
- role: worker
31+
kubeadmConfigPatches:
32+
- |
33+
kind: JoinConfiguration
34+
nodeRegistration:
35+
kubeletExtraArgs:
36+
v: "1"

dev/setup.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
CURRENT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
4+
5+
set -ex
6+
set -o pipefail
7+
8+
source "${CURRENT_DIR}/common.sh"
9+
go install sigs.k8s.io/[email protected]
10+
11+
# Default image
12+
KIND_IMAGE="quay.io/powercloud/kind-node:v1.33.1"
13+
14+
# Override for arm64
15+
if [[ "$(uname -m)" == "arm64" ]]; then
16+
KIND_IMAGE="kindest/node:latest"
17+
fi
18+
19+
# Allow passing image as argument (optional override)
20+
KIND_IMAGE="${1:-$KIND_IMAGE}"
21+
22+
# Create the cluster
23+
kind create cluster \
24+
--image "${KIND_IMAGE}" \
25+
--name "${KIND_CLUSTER_NAME}" \
26+
--config "${KIND_CLUSTER_CONFIG_PATH}" \
27+
--wait 5m

dev/teardown.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2023 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# This scripts invokes `kind build image` so that the resulting
18+
# image has a containerd with CDI support.
19+
#
20+
# Usage: kind-build-image.sh <tag of generated image>
21+
22+
# A reference to the current directory where this script is located
23+
CURRENT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
24+
25+
set -ex
26+
set -o pipefail
27+
28+
source "${CURRENT_DIR}/common.sh"
29+
30+
KIND delete cluster \
31+
--name "${KIND_CLUSTER_NAME}"

0 commit comments

Comments
 (0)