Skip to content

Commit

Permalink
Seed name ManagedCluster label
Browse files Browse the repository at this point in the history
Signed-off-by: Dale Haiducek <[email protected]>
  • Loading branch information
dhaiducek committed Jan 6, 2025
1 parent 80a1d42 commit 36d011a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 19 additions & 3 deletions build/manage-clusters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fi

KIND_PREFIX=${KIND_PREFIX:-"policy-addon-ctrl"}
CLUSTER_PREFIX=${CLUSTER_PREFIX:-"cluster"}
KUBECONFIG_HUB="${PWD}/kubeconfig_${CLUSTER_PREFIX}1_e2e"

export KIND_NAME="${KIND_PREFIX}1"
export CLUSTER_NAME="${CLUSTER_PREFIX}1"
Expand All @@ -42,7 +43,7 @@ esac

if [[ "${RUN_MODE}" == "create" || "${RUN_MODE}" == "create-dev" ]]; then
echo Annotating the ManagedCluster object to indicate it is a hub
KUBECONFIG="$PWD/kubeconfig_${CLUSTER_NAME}_e2e" kubectl annotate ManagedCluster $CLUSTER_NAME --overwrite "addon.open-cluster-management.io/on-multicluster-hub=true"
KUBECONFIG=${KUBECONFIG_HUB} kubectl annotate ManagedCluster $CLUSTER_NAME --overwrite "addon.open-cluster-management.io/on-multicluster-hub=true"

echo Generating the service account kubeconfig
make kind-controller-kubeconfig
Expand All @@ -69,11 +70,26 @@ for i in $(seq 2 $((MANAGED_CLUSTER_COUNT + 1))); do
fi

# Approval takes place on the hub
KIND_KUBECONFIG="${PWD}/kubeconfig_${CLUSTER_PREFIX}1_e2e" make kind-approve-cluster
KIND_KUBECONFIG=${KUBECONFIG_HUB} make kind-approve-cluster

# Deploy "name" ClusterClaim to label ManagedCluster
cat <<EOF | kubectl apply --kubeconfig="${PWD}/kubeconfig_${CLUSTER_NAME}_e2e" -f -
apiVersion: cluster.open-cluster-management.io/v1alpha1
kind: ClusterClaim
metadata:
name: name
spec:
value: ${CLUSTER_NAME}
EOF

# Temporary ManagedCluster label workaround since the ClusterClaim controller
# isn't running in our current setup
kubectl --kubeconfig="${KUBECONFIG_HUB}" label managedcluster ${CLUSTER_NAME} name=${CLUSTER_NAME}
;;

deploy-addons)
# ManagedClusterAddon is applied to the hub
KIND_KUBECONFIG="${PWD}/kubeconfig_${CLUSTER_PREFIX}1_e2e" make kind-deploy-addons
KIND_KUBECONFIG=${KUBECONFIG_HUB} make kind-deploy-addons
;;
esac
done
4 changes: 3 additions & 1 deletion test/e2e/case2_config_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,9 @@ var _ = Describe("Test config-policy-controller deployment", Ordered, func() {
g.Expect(err).ToNot(HaveOccurred())

clusterClaims, _, _ := unstructured.NestedSlice(managedCluster.Object, "status", "clusterClaims")
g.Expect(clusterClaims).To(BeEmpty())
g.Expect(clusterClaims).ToNot(ContainElement(
HaveKeyWithValue("name", "product.open-cluster-management.io"),
))
}, 60, 1).Should(Succeed())
}
})
Expand Down

0 comments on commit 36d011a

Please sign in to comment.