Skip to content

Commit

Permalink
install istio and kmesh in script
Browse files Browse the repository at this point in the history
Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
  • Loading branch information
YaoZengzeng committed Jun 26, 2024
1 parent 3e9ca48 commit ff3ffb1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 50 deletions.
50 changes: 0 additions & 50 deletions test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"io"
"os"
"path"
"path/filepath"
"runtime"
"testing"
Expand All @@ -20,20 +19,16 @@ 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"
"istio.io/istio/pkg/test/framework/components/echo/deployment"
"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"
)
Expand Down Expand Up @@ -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{
Expand Down
24 changes: 24 additions & 0 deletions test/e2e/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -136,6 +158,8 @@ fi

if [[ -z "${SKIP_SETUP:-}" ]]; then
setup_kind_cluster
setup_istio
setup_kmesh
fi

if [[ -z "${SKIP_BUILD:-}" ]]; then
Expand Down

0 comments on commit ff3ffb1

Please sign in to comment.