-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: howard zhang <[email protected]>
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# K8S with mdev support in a Kind cluster | ||
|
||
Provides a pre-deployed k8s cluster that runs using [kind](https://github.com/kubernetes-sigs/kind) The cluster is completely ephemeral and is recreated on every cluster restart. | ||
The KubeVirt containers are built on the local machine and are then pushed to a registry which is exposed at | ||
`localhost:5000`. | ||
|
||
## Bringing the cluster up | ||
|
||
The following needs to be executed as root. Please refer to the name of the directory to get the kind version. | ||
|
||
```bash | ||
export KUBEVIRT_PROVIDER=kind-x.yz | ||
make cluster-up | ||
``` | ||
|
||
The cluster can be accessed as usual: | ||
|
||
```bash | ||
$ cluster-up/kubectl.sh get nodes | ||
NAME STATUS ROLES AGE | ||
kind-x.yz-control-plane Ready master 6m14s | ||
``` | ||
|
||
## Bringing the cluster down | ||
|
||
```bash | ||
make cluster-down | ||
``` | ||
|
||
This destroys the whole cluster. | ||
|
||
## Setting a custom kind version | ||
|
||
In order to use a custom kind image / kind version, | ||
export KIND_NODE_IMAGE, KIND_VERSION, KUBECTL_PATH before running cluster-up. | ||
For example in order to use kind 0.9.0 (which is based on k8s-1.19.1) use: | ||
```bash | ||
export KIND_NODE_IMAGE="kindest/node:v1.19.1@sha256:98cf5288864662e37115e362b23e4369c8c4a408f99cbc06e58ac30ddc721600" | ||
export KIND_VERSION="0.9.0" | ||
export KUBECTL_PATH="/usr/bin/kubectl" | ||
``` | ||
This allows users to test or use custom images / different kind versions before making them official. | ||
See https://github.com/kubernetes-sigs/kind/releases for details about node images according to the kind version. | ||
|
||
- In order to use `make cluster-down` please make sure the right `CLUSTER_NAME` is exported. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
DEFAULT_CLUSTER_NAME="kind-1.27" | ||
DEFAULT_HOST_PORT=5000 | ||
ALTERNATE_HOST_PORT=5001 | ||
export CLUSTER_NAME=${CLUSTER_NAME:-$DEFAULT_CLUSTER_NAME} | ||
|
||
if [ $CLUSTER_NAME == $DEFAULT_CLUSTER_NAME ]; then | ||
export HOST_PORT=$DEFAULT_HOST_PORT | ||
else | ||
export HOST_PORT=$ALTERNATE_HOST_PORT | ||
fi | ||
|
||
function set_kind_params() { | ||
export KIND_VERSION="${KIND_VERSION:-0.19.0}" | ||
export KIND_NODE_IMAGE="${KIND_NODE_IMAGE:-kindest/node:v1.27.1@sha256:b7d12ed662b873bd8510879c1846e87c7e676a79fefc93e17b2a52989d3ff42b}" | ||
export KUBECTL_PATH="${KUBECTL_PATH:-/usr/bin/kubectl}" | ||
} | ||
|
||
function configure_registry_proxy() { | ||
[ "$CI" != "true" ] && return | ||
|
||
echo "Configuring cluster nodes to work with CI mirror-proxy..." | ||
|
||
local -r ci_proxy_hostname="docker-mirror-proxy.kubevirt-prow.svc" | ||
local -r kind_binary_path="${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kind" | ||
local -r configure_registry_proxy_script="${KUBEVIRTCI_PATH}/cluster/kind/configure-registry-proxy.sh" | ||
|
||
KIND_BIN="$kind_binary_path" PROXY_HOSTNAME="$ci_proxy_hostname" $configure_registry_proxy_script | ||
} | ||
|
||
function up() { | ||
cp $KIND_MANIFESTS_DIR/kind.yaml ${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/kind.yaml | ||
_add_kubeadm_cpu_manager_config_patch | ||
_add_extra_mounts | ||
export CONFIG_WORKER_CPU_MANAGER=true | ||
kind_up | ||
|
||
configure_registry_proxy | ||
|
||
# remove the rancher.io kind default storageClass | ||
_kubectl delete sc standard | ||
|
||
echo "$KUBEVIRT_PROVIDER cluster '$CLUSTER_NAME' is ready" | ||
} | ||
|
||
set_kind_params | ||
|
||
source ${KUBEVIRTCI_PATH}/cluster/kind/common.sh |