mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +00:00
ci: Move deploy_k8s() to gha-run-k8s-common.sh
This will allow us to re-use the function in the kata-deploy tests, which will come soon. Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
parent
1829f5c049
commit
09cc0ed438
@ -96,3 +96,42 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deploy_k3s() {
|
||||||
|
curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
|
||||||
|
|
||||||
|
# This is an arbitrary value that came up from local tests
|
||||||
|
sleep 120s
|
||||||
|
|
||||||
|
# Download the kubectl binary into /usr/bin and remove /usr/local/bin/kubectl
|
||||||
|
#
|
||||||
|
# We need to do this to avoid hitting issues like:
|
||||||
|
# ```sh
|
||||||
|
# error: open /etc/rancher/k3s/k3s.yaml.lock: permission denied
|
||||||
|
# ```
|
||||||
|
# Which happens basically because k3s links `/usr/local/bin/kubectl`
|
||||||
|
# to `/usr/local/bin/k3s`, and that does extra stuff that vanilla
|
||||||
|
# `kubectl` doesn't do.
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
if [ "${ARCH}" = "x86_64" ]; then
|
||||||
|
ARCH=amd64
|
||||||
|
fi
|
||||||
|
kubectl_version=$(/usr/local/bin/k3s kubectl version --short 2>/dev/null | grep "Client Version" | sed -e 's/Client Version: //' -e 's/\+k3s1//')
|
||||||
|
sudo curl -fL --progress-bar -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/linux/${ARCH}/kubectl
|
||||||
|
sudo chmod +x /usr/bin/kubectl
|
||||||
|
sudo rm -rf /usr/local/bin/kubectl
|
||||||
|
|
||||||
|
mkdir -p ~/.kube
|
||||||
|
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
|
||||||
|
}
|
||||||
|
|
||||||
|
function deploy_k8s() {
|
||||||
|
echo "::group::Deploying ${KUBERNETES}"
|
||||||
|
|
||||||
|
case ${KUBERNETES} in
|
||||||
|
k3s) deploy_k3s ;;
|
||||||
|
*) >&2 echo "${KUBERNETES} flavour is not supported"; exit 2 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "::endgroup::"
|
||||||
|
}
|
||||||
|
@ -143,45 +143,6 @@ function deploy_kata() {
|
|||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
}
|
}
|
||||||
|
|
||||||
function deploy_k3s() {
|
|
||||||
curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
|
|
||||||
|
|
||||||
# This is an arbitrary value that came up from local tests
|
|
||||||
sleep 120s
|
|
||||||
|
|
||||||
# Download the kubectl binary into /usr/bin and remove /usr/local/bin/kubectl
|
|
||||||
#
|
|
||||||
# We need to do this to avoid hitting issues like:
|
|
||||||
# ```sh
|
|
||||||
# error: open /etc/rancher/k3s/k3s.yaml.lock: permission denied
|
|
||||||
# ```
|
|
||||||
# Which happens basically because k3s links `/usr/local/bin/kubectl`
|
|
||||||
# to `/usr/local/bin/k3s`, and that does extra stuff that vanilla
|
|
||||||
# `kubectl` doesn't do.
|
|
||||||
ARCH=$(uname -m)
|
|
||||||
if [ "${ARCH}" = "x86_64" ]; then
|
|
||||||
ARCH=amd64
|
|
||||||
fi
|
|
||||||
kubectl_version=$(/usr/local/bin/k3s kubectl version --short 2>/dev/null | grep "Client Version" | sed -e 's/Client Version: //' -e 's/\+k3s1//')
|
|
||||||
sudo curl -fL --progress-bar -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/linux/${ARCH}/kubectl
|
|
||||||
sudo chmod +x /usr/bin/kubectl
|
|
||||||
sudo rm -rf /usr/local/bin/kubectl
|
|
||||||
|
|
||||||
mkdir -p ~/.kube
|
|
||||||
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
|
|
||||||
}
|
|
||||||
|
|
||||||
function deploy_k8s() {
|
|
||||||
echo "::group::Deploying ${KUBERNETES}"
|
|
||||||
|
|
||||||
case ${KUBERNETES} in
|
|
||||||
k3s) deploy_k3s ;;
|
|
||||||
*) >&2 echo "${KUBERNETES} flavour is not supported"; exit 2 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "::endgroup::"
|
|
||||||
}
|
|
||||||
|
|
||||||
function run_tests() {
|
function run_tests() {
|
||||||
# Delete any spurious tests namespace that was left behind
|
# Delete any spurious tests namespace that was left behind
|
||||||
kubectl delete namespace kata-containers-k8s-tests &> /dev/null || true
|
kubectl delete namespace kata-containers-k8s-tests &> /dev/null || true
|
||||||
|
Loading…
Reference in New Issue
Block a user