From ff3ffb1158ac9c7e3f7892fd0e1adba005603456 Mon Sep 17 00:00:00 2001 From: YaoZengzeng Date: Wed, 26 Jun 2024 08:52:05 +0000 Subject: [PATCH] install istio and kmesh in script Signed-off-by: YaoZengzeng --- test/e2e/main_test.go | 50 ------------------------------------------- test/e2e/run_test.sh | 24 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 50 deletions(-) diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index 3495fd2e5..cba951328 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -8,7 +8,6 @@ import ( "fmt" "io" "os" - "path" "path/filepath" "runtime" "testing" @@ -20,7 +19,6 @@ import ( istioKube "istio.io/istio/pkg/kube" "istio.io/istio/pkg/test/framework" "istio.io/istio/pkg/test/framework/components/ambient" - kubecluster "istio.io/istio/pkg/test/framework/components/cluster/kube" "istio.io/istio/pkg/test/framework/components/crd" "istio.io/istio/pkg/test/framework/components/echo" "istio.io/istio/pkg/test/framework/components/echo/common/ports" @@ -28,12 +26,9 @@ import ( "istio.io/istio/pkg/test/framework/components/istio" "istio.io/istio/pkg/test/framework/components/namespace" "istio.io/istio/pkg/test/framework/resource" - "istio.io/istio/pkg/test/helm" testKube "istio.io/istio/pkg/test/kube" "istio.io/istio/pkg/test/scopes" - "istio.io/istio/tests/integration/security/util/cert" v1 "k8s.io/api/core/v1" - kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" gateway "sigs.k8s.io/gateway-api/apis/v1" ) @@ -83,57 +78,12 @@ func TestMain(m *testing.M) { t.Settings().Ambient = true return nil }). - Setup(istio.Setup(&i, func(ctx resource.Context, cfg *istio.Config) { - // can't deploy VMs without eastwest gateway - ctx.Settings().SkipVMs() - cfg.EnableCNI = true - cfg.DeployEastWestGW = false - }, cert.CreateCASecretAlt)). - Setup(func(t resource.Context) error { - scopes.Framework.Info("=== BEGIN: Deploy Kmesh ===") - - err := SetupKmesh(t) - if err != nil { - scopes.Framework.Info("=== FAILED: Deploy Kmesh ===") - return err - } - - scopes.Framework.Info("=== SUCCEEDED: Deploy Kmesh ===") - - return nil - }). Setup(func(t resource.Context) error { return SetupApps(t, i, apps) }). Run() } -func SetupKmesh(ctx resource.Context) error { - cs := ctx.Clusters().Default().(*kubecluster.Cluster) - - if _, err := cs.Kube().CoreV1().Namespaces().Create(context.TODO(), &v1.Namespace{ - ObjectMeta: metav1.ObjectMeta{ - Name: KmeshNamespace, - }, - }, metav1.CreateOptions{}); err != nil { - if !kerrors.IsAlreadyExists(err) { - return fmt.Errorf("failed to create %v namespace: %v", KmeshNamespace, err) - } - } - - h := helm.New(cs.Filename()) - - kmeshChartPath := path.Join(KmeshSrc, "deploy/helm/") - - // Install Kmesh chart - err := h.InstallChartWithValues(KmeshReleaseName, kmeshChartPath, KmeshNamespace, []string{"--set deploy.kmesh.image.repository=localhost:5000/kmesh"}, Timeout) - if err != nil { - return fmt.Errorf("failed to install Kmesh chart: %v", err) - } - - return nil -} - func SetupApps(t resource.Context, i istio.Instance, apps *EchoDeployments) error { var err error apps.Namespace, err = namespace.New(t, namespace.Config{ diff --git a/test/e2e/run_test.sh b/test/e2e/run_test.sh index 3a58926be..4db89258b 100755 --- a/test/e2e/run_test.sh +++ b/test/e2e/run_test.sh @@ -9,6 +9,9 @@ set -e DEFAULT_KIND_IMAGE="kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e" +# support testing multiple istio version in the future. +ISTIO_VERSION=1.22.0 + export KMESH_WAYPOINT_IMAGE="ghcr.io/kmesh-net/waypoint-x86:v0.3.0" ROOT_DIR=$(git rev-parse --show-toplevel) @@ -43,6 +46,17 @@ EOF fi } +function setup_istio() { + kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \ + { kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v1.1.0" | kubectl apply -f -; } + + istioctl install --set profile=ambient --skip-confirmation +} + +function setup_kmesh() { + helm install kmesh $ROOT_DIR/deploy/helm -n kmesh-system --create-namespace --set deploy.kmesh.image.repository=localhost:5000/kmesh +} + export KIND_REGISTRY_NAME="kind-registry" export KIND_REGISTRY_PORT="5000" export KIND_REGISTRY="localhost:${KIND_REGISTRY_PORT}" @@ -105,6 +119,14 @@ function install_dependencies() { ./get_helm.sh rm get_helm.sh + + # 3. Install istioctl + + curl -L https://istio.io/downloadIstio | ISTIO_VERSION=${ISTIO_VERSION} TARGET_ARCH=x86_64 sh - + + cp istio-${ISTIO_VERSION}/bin/istioctl /usr/local/bin/ + + rm -rf istio-${ISTIO_VERSION} } while (( "$#" )); do @@ -136,6 +158,8 @@ fi if [[ -z "${SKIP_SETUP:-}" ]]; then setup_kind_cluster + setup_istio + setup_kmesh fi if [[ -z "${SKIP_BUILD:-}" ]]; then