mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-14 07:34:35 +00:00
tests: k8s: reduce namespace name duplication
1. Avoid repeating "kata-containers-k8s-tests". 2. Allow users to specify a different test namespace. 3. Introduce the TEST_CLUSTER_NAMESPACE variable, that will also be useful when auto-generating the Agent Policy for these tests. Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
parent
8a5ba5fb34
commit
1b4ef672ef
@ -269,3 +269,21 @@ function deploy_k8s() {
|
|||||||
|
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set_test_cluster_namespace() {
|
||||||
|
# Delete any spurious tests namespace that was left behind
|
||||||
|
kubectl delete namespace "${TEST_CLUSTER_NAMESPACE}" &> /dev/null || true
|
||||||
|
|
||||||
|
# Create a new namespace for the tests and switch to it
|
||||||
|
kubectl apply -f "${kubernetes_dir}/runtimeclass_workloads/tests-namespace.yaml"
|
||||||
|
kubectl config set-context --current --namespace="${TEST_CLUSTER_NAMESPACE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_default_cluster_namespace() {
|
||||||
|
kubectl config set-context --current --namespace=default
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_test_cluster_namespace() {
|
||||||
|
set_default_cluster_namespace
|
||||||
|
kubectl delete namespace "${TEST_CLUSTER_NAMESPACE}"
|
||||||
|
}
|
||||||
|
@ -20,6 +20,7 @@ KATA_DEPLOY_WAIT_TIMEOUT=${KATA_DEPLOY_WAIT_TIMEOUT:-10m}
|
|||||||
KATA_HYPERVISOR=${KATA_HYPERVISOR:-qemu}
|
KATA_HYPERVISOR=${KATA_HYPERVISOR:-qemu}
|
||||||
KUBERNETES="${KUBERNETES:-}"
|
KUBERNETES="${KUBERNETES:-}"
|
||||||
SNAPSHOTTER="${SNAPSHOTTER:-}"
|
SNAPSHOTTER="${SNAPSHOTTER:-}"
|
||||||
|
export TEST_CLUSTER_NAMESPACE="${TEST_CLUSTER_NAMESPACE:-kata-containers-k8s-tests}"
|
||||||
|
|
||||||
function configure_devmapper() {
|
function configure_devmapper() {
|
||||||
sudo mkdir -p /var/lib/containerd/devmapper
|
sudo mkdir -p /var/lib/containerd/devmapper
|
||||||
@ -103,8 +104,7 @@ function deploy_kata() {
|
|||||||
[ "$platform" = "kcli" ] && \
|
[ "$platform" = "kcli" ] && \
|
||||||
export KUBECONFIG="$HOME/.kcli/clusters/${CLUSTER_NAME:-kata-k8s}/auth/kubeconfig"
|
export KUBECONFIG="$HOME/.kcli/clusters/${CLUSTER_NAME:-kata-k8s}/auth/kubeconfig"
|
||||||
|
|
||||||
# Ensure we're in the default namespace
|
set_default_cluster_namespace
|
||||||
kubectl config set-context --current --namespace=default
|
|
||||||
|
|
||||||
sed -i -e "s|quay.io/kata-containers/kata-deploy:latest|${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}|g" "${tools_dir}/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
sed -i -e "s|quay.io/kata-containers/kata-deploy:latest|${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}|g" "${tools_dir}/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
||||||
|
|
||||||
@ -164,12 +164,7 @@ function run_tests() {
|
|||||||
[ "$platform" = "kcli" ] && \
|
[ "$platform" = "kcli" ] && \
|
||||||
export KUBECONFIG="$HOME/.kcli/clusters/${CLUSTER_NAME:-kata-k8s}/auth/kubeconfig"
|
export KUBECONFIG="$HOME/.kcli/clusters/${CLUSTER_NAME:-kata-k8s}/auth/kubeconfig"
|
||||||
|
|
||||||
# Delete any spurious tests namespace that was left behind
|
set_test_cluster_namespace
|
||||||
kubectl delete namespace kata-containers-k8s-tests &> /dev/null || true
|
|
||||||
|
|
||||||
# Create a new namespace for the tests and switch to it
|
|
||||||
kubectl apply -f "${kubernetes_dir}/runtimeclass_workloads/tests-namespace.yaml"
|
|
||||||
kubectl config set-context --current --namespace=kata-containers-k8s-tests
|
|
||||||
|
|
||||||
pushd "${kubernetes_dir}"
|
pushd "${kubernetes_dir}"
|
||||||
bash setup.sh
|
bash setup.sh
|
||||||
@ -199,8 +194,7 @@ function cleanup() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Switch back to the default namespace and delete the tests one
|
# Switch back to the default namespace and delete the tests one
|
||||||
kubectl config set-context --current --namespace=default
|
delete_test_cluster_namespace
|
||||||
kubectl delete namespace kata-containers-k8s-tests
|
|
||||||
|
|
||||||
if [ "${KUBERNETES}" = "k3s" ]; then
|
if [ "${KUBERNETES}" = "k3s" ]; then
|
||||||
deploy_spec="-k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/k3s""
|
deploy_spec="-k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/k3s""
|
||||||
|
Loading…
Reference in New Issue
Block a user