mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
ci: k8s: create k8s clusters with kcli
Adapted the gha-run.sh script to create a Kubernetes cluster locally using the kcli tool. Use `./gha-run.sh create-cluster-kcli` to create it, and `./gha-run.sh delete-cluster-kcli` to delete. Fixes #7620 Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
This commit is contained in:
parent
1280f85343
commit
89bef7d036
@ -107,6 +107,11 @@ function delete_cluster() {
|
|||||||
--yes
|
--yes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function delete_cluster_kcli() {
|
||||||
|
CLUSTER_NAME="${CLUSTER_NAME:-kata-k8s}"
|
||||||
|
kcli delete -y kube "$CLUSTER_NAME"
|
||||||
|
}
|
||||||
|
|
||||||
function get_nodes_and_pods_info() {
|
function get_nodes_and_pods_info() {
|
||||||
kubectl debug $(kubectl get nodes -o name) -it --image=quay.io/kata-containers/kata-debug:latest || true
|
kubectl debug $(kubectl get nodes -o name) -it --image=quay.io/kata-containers/kata-debug:latest || true
|
||||||
kubectl get pods -o name | grep node-debugger | xargs kubectl delete || true
|
kubectl get pods -o name | grep node-debugger | xargs kubectl delete || true
|
||||||
@ -165,6 +170,44 @@ function deploy_k3s() {
|
|||||||
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
|
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_cluster_kcli() {
|
||||||
|
CLUSTER_NAME="${CLUSTER_NAME:-kata-k8s}"
|
||||||
|
|
||||||
|
delete_cluster_kcli || true
|
||||||
|
|
||||||
|
kcli create kube "${KUBE_TYPE:-generic}" \
|
||||||
|
-P domain="kata.com" \
|
||||||
|
-P pool="${LIBVIRT_POOL:-default}" \
|
||||||
|
-P ctlplanes="${CLUSTER_CONTROL_NODES:-1}" \
|
||||||
|
-P workers="${CLUSTER_WORKERS:-1}" \
|
||||||
|
-P network="${LIBVIRT_NETWORK:-default}" \
|
||||||
|
-P image="${CLUSTER_IMAGE:-ubuntu2004}" \
|
||||||
|
-P sdn=flannel \
|
||||||
|
-P nfs=false \
|
||||||
|
-P disk_size="${CLUSTER_DISK_SIZE:-20}" \
|
||||||
|
"${CLUSTER_NAME}"
|
||||||
|
|
||||||
|
export KUBECONFIG="$HOME/.kcli/clusters/$CLUSTER_NAME/auth/kubeconfig"
|
||||||
|
|
||||||
|
local cmd="kubectl get nodes | grep '.*worker.*\<Ready\>'"
|
||||||
|
echo "Wait at least one worker be Ready"
|
||||||
|
if ! waitForProcess "330" "30" "$cmd"; then
|
||||||
|
echo "ERROR: worker nodes not ready."
|
||||||
|
kubectl get nodes
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure that system pods are running or completed.
|
||||||
|
cmd="[ \$(kubectl get pods -A --no-headers | grep -v 'Running\|Completed' | wc -l) -eq 0 ]"
|
||||||
|
echo "Wait system pods be running or completed"
|
||||||
|
if ! waitForProcess "90" "30" "$cmd"; then
|
||||||
|
echo "ERROR: not all pods are Running or Completed."
|
||||||
|
kubectl get pods -A
|
||||||
|
kubectl get pods -A
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function deploy_rke2() {
|
function deploy_rke2() {
|
||||||
curl -sfL https://get.rke2.io | sudo sh -
|
curl -sfL https://get.rke2.io | sudo sh -
|
||||||
|
|
||||||
|
@ -214,6 +214,7 @@ function main() {
|
|||||||
install-azure-cli) install_azure_cli ;;
|
install-azure-cli) install_azure_cli ;;
|
||||||
login-azure) login_azure ;;
|
login-azure) login_azure ;;
|
||||||
create-cluster) create_cluster ;;
|
create-cluster) create_cluster ;;
|
||||||
|
create-cluster-kcli) create_cluster_kcli ;;
|
||||||
configure-snapshotter) configure_snapshotter ;;
|
configure-snapshotter) configure_snapshotter ;;
|
||||||
setup-crio) setup_crio ;;
|
setup-crio) setup_crio ;;
|
||||||
deploy-k8s) deploy_k8s ;;
|
deploy-k8s) deploy_k8s ;;
|
||||||
@ -231,6 +232,7 @@ function main() {
|
|||||||
cleanup-tdx) cleanup "tdx" ;;
|
cleanup-tdx) cleanup "tdx" ;;
|
||||||
cleanup-garm) cleanup "garm" ;;
|
cleanup-garm) cleanup "garm" ;;
|
||||||
delete-cluster) cleanup "aks" ;;
|
delete-cluster) cleanup "aks" ;;
|
||||||
|
delete-cluster-kcli) delete_cluster_kcli ;;
|
||||||
*) >&2 echo "Invalid argument"; exit 2 ;;
|
*) >&2 echo "Invalid argument"; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user