Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e multicluster tests #91

Closed
Tracked by #153
nrfox opened this issue Apr 29, 2024 · 4 comments · Fixed by #342
Closed
Tracked by #153

e2e multicluster tests #91

nrfox opened this issue Apr 29, 2024 · 4 comments · Fixed by #342
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@nrfox
Copy link
Contributor

nrfox commented Apr 29, 2024

There needs to be e2e tests to ensure you can use the Sail operator and APIs to setup a multicluster istio deployment. The tests need to cover setting up:

  1. multi-primary
  2. primary-remote
  3. external controlplane

These e2e tests should:

@nrfox
Copy link
Contributor Author

nrfox commented Apr 30, 2024

Here are the steps to setup multi-primary in kind with Sail which can be automated if they aren't already in the e2e tests:

  1. Install and start kind load balancer: https://kind.sigs.k8s.io/docs/user/loadbalancer/ and https://github.com/kubernetes-sigs/cloud-provider-kind?tab=readme-ov-file#how-to-use-it

  2. Download istioctl

  3. Create shared trust

mkdir -p certs
pushd certs
make -f istioctl_dir/tools/certs/Makefile.selfsigned.mk root-ca
make -f istioctl_dir/tools/certs/Makefile.selfsigned.mk cluster1-cacerts
make -f istioctl_dir/tools/certs/Makefile.selfsigned.mk cluster2-cacerts
popd
  1. Create kind clusters
kind create cluster --name cluster1
kind create cluster --name cluster2
  1. Install sail operator on each cluster:
kubectl config use-context kind-cluster1
make deploy
kubectl config use-context kind-cluster2
make deploy
  1. Create istio-system namespace on each cluster and add intermediate CAs to each.
kubectl create namespace istio-system --context kind-cluster1
kubectl --context=kind-cluster1 label namespace istio-system topology.istio.io/network=network1
kubectl create secret generic cacerts -n istio-system --context kind-cluster1 \
      --from-file=certs/cluster1/ca-cert.pem \
      --from-file=certs/cluster1/ca-key.pem \
      --from-file=certs/cluster1/root-cert.pem \
      --from-file=certs/cluster1/cert-chain.pem

kubectl create namespace istio-system --context kind-cluster2
kubectl --context=kind-cluster2 label namespace istio-system topology.istio.io/network=network2
kubectl create secret generic cacerts -n istio-system --context kind-cluster2 \
      --from-file=certs/cluster2/ca-cert.pem \
      --from-file=certs/cluster2/ca-key.pem \
      --from-file=certs/cluster2/root-cert.pem \
      --from-file=certs/cluster2/cert-chain.pem
  1. Create Sail CR on cluster1
kubectl apply --context kind-cluster1 -f - <<EOF
apiVersion: operator.istio.io/v1alpha1
kind: Istio
metadata:
  name: default
spec:
  version: v1.21.0
  namespace: istio-system
  updateStrategy:
    type: InPlace
    inactiveRevisionDeletionGracePeriodSeconds: 30
  values:
    pilot:
      resources:
        requests:
          cpu: 100m
          memory: 1024Mi
    global:
      meshID: mesh1
      multiCluster:
        clusterName: cluster1
      network: network1
EOF
  1. Create east-west gateway on cluster1
istioctl_dir/samples/multicluster/gen-eastwest-gateway.sh \
    --mesh mesh1 --cluster cluster1 --network network1 | \
    istioctl --context="kind-cluster1" install -y -f -
  1. Expose services on cluster1
kubectl --context="kind-cluster1" apply -n istio-system -f \
    istioctl_dir/samples/multicluster/expose-services.yaml
  1. Create Sail CR on cluster2
kubectl apply --context kind-cluster2 -f - <<EOF
apiVersion: operator.istio.io/v1alpha1
kind: Istio
metadata:
  name: default
spec:
  version: v1.21.0
  namespace: istio-system
  updateStrategy:
    type: InPlace
    inactiveRevisionDeletionGracePeriodSeconds: 30
  values:
    pilot:
      resources:
        requests:
          cpu: 100m
          memory: 1024Mi
    global:
      meshID: mesh1
      multiCluster:
        clusterName: cluster2
      network: network2
EOF
  1. Create east-west gateway on cluster2
istioctl_dir/samples/multicluster/gen-eastwest-gateway.sh \
    --mesh mesh1 --cluster cluster2 --network network2 | \
    istioctl --context="kind-cluster2" install -y -f -
  1. Expose services on cluster1
kubectl --context="kind-cluster2" apply -n istio-system -f \
    istioctl_dir/samples/multicluster/expose-services.yaml
  1. Install a remote secret in cluster2 that provides access to cluster1’s API server.
CLUSTER2_CONTAINER_IP=$(kubectl get nodes cluster1-control-plane --context "kind-cluster1" -o jsonpath='{.status.addresses[?(@.type == "InternalIP")].address}')
istioctl create-remote-secret \
  --context="kind-cluster1" \
  --name=cluster1 \
  --server="https://${CLUSTER2_CONTAINER_IP}:6443" | \
  kubectl apply -f - --context="kind-cluster2"
  1. Install a remote secret in cluster1 that provides access to cluster2’s API server.
CLUSTER1_CONTAINER_IP=$(kubectl get nodes cluster2-control-plane --context "kind-cluster2" -o jsonpath='{.status.addresses[?(@.type == "InternalIP")].address}')
istioctl create-remote-secret \
  --context="kind-cluster2" \
  --name=cluster2 \
  --server="https://${CLUSTER1_CONTAINER_IP}:6443" | \
  kubectl apply -f - --context="kind-cluster1"
  1. Verify
kubectl create --context="kind-cluster1" namespace sample
kubectl create --context="kind-cluster2" namespace sample
kubectl label --context="kind-cluster1" namespace sample istio-injection=enabled
kubectl label --context="kind-cluster2" namespace sample istio-injection=enabled
kubectl apply --context="kind-cluster1" \
    -f samples/helloworld/helloworld.yaml \
    -l service=helloworld -n sample
kubectl apply --context="kind-cluster2" \
    -f samples/helloworld/helloworld.yaml \
    -l service=helloworld -n sample
kubectl apply --context="kind-cluster1" \
    -f istioctl_dir/samples/helloworld/helloworld.yaml \
    -l version=v1 -n sample
kubectl apply --context="kind-cluster2" \
    -f istioctl_dir/samples/helloworld/helloworld.yaml \
    -l version=v2 -n sample
kubectl apply --context="kind-cluster1" \
    -f istioctl_dir/samples/sleep/sleep.yaml -n sample
kubectl apply --context="kind-cluster2" \
    -f istioctl_dir/samples/sleep/sleep.yaml -n sample
kubectl exec --context="kind-cluster1" -n sample -c sleep \
    "$(kubectl get pod --context="kind-cluster1" -n sample -l \
    app=sleep -o jsonpath='{.items[0].metadata.name}')" \
    -- curl -sS helloworld.sample:5000/hello

kubectl exec --context="kind-cluster2" -n sample -c sleep \
    "$(kubectl get pod --context="kind-cluster2" -n sample -l \
    app=sleep -o jsonpath='{.items[0].metadata.name}')" \
    -- curl -sS helloworld.sample:5000/hello

@dgn dgn added this to the v0.1 milestone May 23, 2024
@dgn dgn added the enhancement New feature or request label May 23, 2024
@fjglira
Copy link
Contributor

fjglira commented Jul 19, 2024

I can add this test if @nrfox is ok

@nrfox
Copy link
Contributor Author

nrfox commented Aug 6, 2024

@fjglira sure!

@fjglira fjglira self-assigned this Aug 7, 2024
dgn pushed a commit to dgn/sail-operator that referenced this issue Aug 15, 2024
…/none-main-merge_upstream_main-38a843ce

Automator: merge upstream changes to openshift-service-mesh/sail-operator@main
@dgn dgn modified the milestone: v0.1 Aug 26, 2024
@fjglira
Copy link
Contributor

fjglira commented Sep 6, 2024

Already created a Multi-Primary - Multi-Network test in this PR. Working on: refactor kubectl util and add Primary-Remote - Multi-Network test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants