Skip to content

Commit 8c2cb0e

Browse files
EKS Integration Test Fixes (#187)
* Added managed by label - issue 110 * derived services + unit tests + label * revisions and delete svc bug * annotation readded. kind & janitor test changes. * fix expected test result. cluster-id -> cluster * working eks integration tests
1 parent fe4ff0f commit 8c2cb0e

File tree

11 files changed

+84
-9
lines changed

11 files changed

+84
-9
lines changed

config/rbac/role.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ rules:
2323
- list
2424
- update
2525
- watch
26+
- apiGroups:
27+
- about.k8s.io
28+
resources:
29+
- clusterproperties
30+
verbs:
31+
- create
32+
- delete
33+
- get
34+
- list
35+
- patch
36+
- update
37+
- watch
2638
- apiGroups:
2739
- discovery.k8s.io
2840
resources:

integration/eks-test/configs/coredns-clusterrole.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ rules:
2323
- nodes
2424
verbs:
2525
- get
26+
- apiGroups:
27+
- about.k8s.io
28+
resources:
29+
- clusterproperties
30+
verbs:
31+
- create
32+
- get
33+
- list
34+
- patch
35+
- update
36+
- watch
2637
- apiGroups:
2738
- discovery.k8s.io
2839
resources:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: about.k8s.io/v1alpha1
2+
kind: ClusterProperty
3+
metadata:
4+
name: id.k8s.io
5+
spec:
6+
value: eks-e2e-clusterid-1
7+
---
8+
apiVersion: about.k8s.io/v1alpha1
9+
kind: ClusterProperty
10+
metadata:
11+
name: clusterset.k8s.io
12+
spec:
13+
value: eks-e2e-clustersetid-1
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: about.k8s.io/v1alpha1
2+
kind: ClusterProperty
3+
metadata:
4+
name: id.k8s.io
5+
spec:
6+
value: eks-e2e-clusterid-2
7+
---
8+
apiVersion: about.k8s.io/v1alpha1
9+
kind: ClusterProperty
10+
metadata:
11+
name: clusterset.k8s.io
12+
spec:
13+
value: eks-e2e-clustersetid-1

integration/eks-test/scripts/eks-DNS-test.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,34 @@
44

55
echo "verifying cross-cluster service consumption..."
66

7+
# Install curl if not installed
78
$KUBECTL_BIN exec $CLIENT_POD -n $NAMESPACE /bin/sh -- curl --version &>/dev/null
89
exit_code=$?
9-
10-
# Install curl if not installed
1110
if [ "$exit_code" -eq 126 ]; then
11+
echo "curl not installed, installing..."
1212
$KUBECTL_BIN exec $CLIENT_POD -n $NAMESPACE /bin/sh -- apk add curl
1313
fi
1414

15+
# Perform an nslookup to cluster-local CoreDNS
16+
echo "performing nslookup..."
17+
$KUBECTL_BIN exec -it $CLIENT_POD -n $NAMESPACE /bin/sh -- nslookup $SERVICE.$NAMESPACE.svc.clusterset.local
18+
exit_code=$?
19+
20+
if [ "$exit_code" -ne 0 ]; then
21+
echo "ERROR: Unable to nslookup service $SERVICE.$NAMESPACE.svc.clusterset.local"
22+
exit $exit_code
23+
fi
24+
sleep 5
25+
1526
# Call to DNS server, if unable to reach, importing cluster is not able to properly consume service
16-
$KUBECTL_BIN exec $CLIENT_POD -n $NAMESPACE /bin/sh -- curl -s $SERVICE.$NAMESPACE.svc.clusterset.local
27+
echo "performing curl..."
28+
$KUBECTL_BIN exec -it $CLIENT_POD -n $NAMESPACE /bin/sh -- curl $SERVICE.$NAMESPACE.svc.clusterset.local
1729
exit_code=$?
1830

1931
if [ "$exit_code" -ne 0 ]; then
32+
echo "ERROR: Unable to reach service $SERVICE.$NAMESPACE.svc.clusterset.local"
2033
exit $exit_code
2134
fi
2235

2336
echo "confirmed service consumption"
2437
exit 0
25-

integration/eks-test/scripts/eks-cleanup.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ $KUBECTL_BIN delete -k "github.com/aws/aws-cloud-map-mcs-controller-for-k8s/conf
3939

4040
echo "EKS clusters cleaned!"
4141

42-
./integration/shared/scripts/cleanup-cloudmap.sh
43-
42+
# ./integration/shared/scripts/cleanup-cloudmap.sh
43+
go run ./integration/janitor/runner/main.go "$NAMESPACE" "$CLUSTERID1" "$CLUSTERSETID1"
44+
go run ./integration/janitor/runner/main.go "$NAMESPACE" "$CLUSTERID2" "$CLUSTERSETID1"

integration/eks-test/scripts/eks-common.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ export ENDPT_PORT=80
1313
export SERVICE_PORT=80 # from nginx-service.yaml
1414
export EXPORT_CLS='cls1'
1515
export IMPORT_CLS='cls2'
16+
export CLUSTERID1='eks-e2e-clusterid-1'
17+
export CLUSTERID2='eks-e2e-clusterid-2'
18+
export CLUSTERSETID1='eks-e2e-clustersetid-1'
1619
export EXPECTED_ENDPOINT_COUNT=3
1720
export UPDATED_ENDPOINT_COUNT=4

integration/eks-test/scripts/eks-run-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if ! endpts=$(./integration/shared/scripts/poll-endpoints.sh "$EXPECTED_ENDPOINT
1111
fi
1212

1313
# Runner to verify expected endpoints are exported to Cloud Map
14-
go run $SCENARIOS/runner/main.go $NAMESPACE $SERVICE $ENDPT_PORT $SERVICE_PORT "$endpts"
14+
go run $SCENARIOS/runner/main.go $NAMESPACE $SERVICE $CLUSTERID1 $CLUSTERSETID1 $ENDPT_PORT $SERVICE_PORT "$endpts"
1515
exit_code=$?
1616

1717
# Check imported endpoints in importing cluster
@@ -47,7 +47,7 @@ if [ "$exit_code" -eq 0 ] ; then
4747
fi
4848

4949
if [ "$exit_code" -eq 0 ] ; then
50-
go run $SCENARIOS/runner/main.go $NAMESPACE $SERVICE $ENDPT_PORT $SERVICE_PORT "$updated_endpoints"
50+
go run $SCENARIOS/runner/main.go $NAMESPACE $SERVICE $CLUSTERID1 $CLUSTERSETID1 $ENDPT_PORT $SERVICE_PORT "$updated_endpoints"
5151
exit_code=$?
5252
fi
5353

integration/eks-test/scripts/eks-setup.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
source ./integration/eks-test/scripts/eks-common.sh
44

5+
# Apply ClusterProperties
6+
$KUBECTL_BIN config use-context $EXPORT_CLS
7+
make install
8+
$KUBECTL_BIN apply -f "$CONFIGS/e2e-clusterproperty-1.yaml"
9+
10+
$KUBECTL_BIN config use-context $IMPORT_CLS
11+
make install
12+
$KUBECTL_BIN apply -f "$CONFIGS/e2e-clusterproperty-2.yaml"
13+
514
# Call helper for service account and controller installation
615
./integration/eks-test/scripts/eks-setup-helper.sh $EXPORT_CLS
716
./integration/eks-test/scripts/eks-setup-helper.sh $IMPORT_CLS
@@ -23,4 +32,3 @@ $KUBECTL_BIN apply -f "$CONFIGS/nginx-serviceexport.yaml"
2332
$KUBECTL_BIN config use-context $IMPORT_CLS
2433
$KUBECTL_BIN apply -f "$CONFIGS/client-hello.yaml"
2534
sleep 15
26-
$KUBECTL_BIN exec $CLIENT_POD -n $NAMESPACE /bin/sh -- apk add curl ## install curl

pkg/controllers/multicluster/cloudmap_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type CloudMapReconciler struct {
3131

3232
// +kubebuilder:rbac:groups="",resources=namespaces,verbs=list;watch
3333
// +kubebuilder:rbac:groups="",resources=services,verbs=create;get;list;watch;update;delete
34+
// +kubebuilder:rbac:groups=about.k8s.io,resources=clusterproperties,verbs=create;get;list;watch;update;patch;delete
3435
// +kubebuilder:rbac:groups="discovery.k8s.io",resources=endpointslices,verbs=list;get;create;watch;update;delete
3536
// +kubebuilder:rbac:groups=multicluster.x-k8s.io,resources=serviceimports,verbs=create;get;list;watch;update;patch;delete
3637

0 commit comments

Comments
 (0)