Skip to content

Commit

Permalink
Upgrade addon-framework to v0.8.0
Browse files Browse the repository at this point in the history
The `ClusterManagementAddon` CR became a hard prerequisite for the E2E
tests, so it's also added here in the E2E suite.

Signed-off-by: Dale Haiducek <[email protected]>
  • Loading branch information
dhaiducek authored and mprahl committed Dec 13, 2023
1 parent e67355e commit b3d6cf1
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 70 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ require (
k8s.io/apimachinery v0.26.10
k8s.io/client-go v0.26.10
k8s.io/component-base v0.26.10
open-cluster-management.io/addon-framework v0.6.1
open-cluster-management.io/api v0.11.0
open-cluster-management.io/addon-framework v0.8.0
open-cluster-management.io/api v0.12.0
sigs.k8s.io/controller-runtime v0.14.6
)

Expand Down
10 changes: 5 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3i
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
Expand Down Expand Up @@ -1083,10 +1083,10 @@ k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
open-cluster-management.io/addon-framework v0.6.1 h1:gnBZaCRgtiPRjCBJoaRqMivajng/XOKp0NQhJUqLd+U=
open-cluster-management.io/addon-framework v0.6.1/go.mod h1:Uu4XC3Ec0ATS7U73PJtzAP4NCDfbDBVy1k5RUUwQDqY=
open-cluster-management.io/api v0.11.0 h1:zBxa33Co3wseLBF4HEJobhl0P6ygj+Drhe7Wrfo0/h8=
open-cluster-management.io/api v0.11.0/go.mod h1:WgKUCJ7+Bf40DsOmH1Gdkpyj3joco+QLzrlM6Ak39zE=
open-cluster-management.io/addon-framework v0.8.0 h1:i1OReMHuZIoAw2Q04SLjkieU25DnxYilzVZzBNyROwU=
open-cluster-management.io/addon-framework v0.8.0/go.mod h1:20DP06VXhJ9RE1PetAMEQyeFCP7+nhs92pCAkqbWUOg=
open-cluster-management.io/api v0.12.0 h1:sNkj4k2XyWA/GLsTiFg82bLIZ7JDZKkLLLyZjJUlJMs=
open-cluster-management.io/api v0.12.0/go.mod h1:/CZhelEH+30/pX7vXGSZOzLMX0zvjthYOkT/5ZTzVTQ=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
Expand Down
3 changes: 2 additions & 1 deletion pkg/addon/configpolicy/agent_addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"open-cluster-management.io/addon-framework/pkg/addonfactory"
"open-cluster-management.io/addon-framework/pkg/addonmanager"
"open-cluster-management.io/addon-framework/pkg/agent"
"open-cluster-management.io/addon-framework/pkg/utils"
addonapiv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
addonv1alpha1client "open-cluster-management.io/api/client/addon/clientset/versioned"
clusterv1 "open-cluster-management.io/api/cluster/v1"
Expand Down Expand Up @@ -204,7 +205,7 @@ func GetAgentAddon(controllerContext *controllercmd.ControllerContext) (agent.Ag
}

return addonfactory.NewAgentAddonFactory(addonName, FS, "manifests/managedclusterchart").
WithConfigGVRs(addonfactory.AddOnDeploymentConfigGVR).
WithConfigGVRs(utils.AddOnDeploymentConfigGVR).
WithGetValuesFuncs(
addonfactory.GetAddOnDeploymentConfigValues(
addonfactory.NewAddOnDeploymentConfigGetter(addonClient),
Expand Down
3 changes: 2 additions & 1 deletion pkg/addon/policyframework/agent_addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"open-cluster-management.io/addon-framework/pkg/addonfactory"
"open-cluster-management.io/addon-framework/pkg/addonmanager"
"open-cluster-management.io/addon-framework/pkg/agent"
"open-cluster-management.io/addon-framework/pkg/utils"
addonapiv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
addonv1alpha1client "open-cluster-management.io/api/client/addon/clientset/versioned"
clusterv1 "open-cluster-management.io/api/cluster/v1"
Expand Down Expand Up @@ -236,7 +237,7 @@ func GetAgentAddon(controllerContext *controllercmd.ControllerContext) (agent.Ag
}

return addonfactory.NewAgentAddonFactory(addonName, FS, "manifests/managedclusterchart").
WithConfigGVRs(addonfactory.AddOnDeploymentConfigGVR).
WithConfigGVRs(utils.AddOnDeploymentConfigGVR).
WithGetValuesFuncs(
addonfactory.GetAddOnDeploymentConfigValues(
addonfactory.NewAddOnDeploymentConfigGetter(addonClient),
Expand Down
51 changes: 31 additions & 20 deletions test/e2e/case1_framework_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,29 @@ import (
)

const (
case1ManagedClusterAddOnName string = "governance-policy-framework"
case1ManagedClusterAddOnCR string = "../resources/framework_addon_cr.yaml"
case1ClusterManagementAddOnCR string = "../resources/framework_clustermanagementaddon.yaml"
case1hubAnnotationMCAOCR string = "../resources/framework_hub_annotation_addon_cr.yaml"
case1hubValuesMCAOCR string = "../resources/framework_hub_values_addon_cr.yaml"
case1DeploymentName string = "governance-policy-framework"
case1PodSelector string = "app=governance-policy-framework"
case1MWName string = "addon-governance-policy-framework-deploy-0"
case1MWPatch string = "../resources/manifestwork_add_patch.json"
case1ManagedClusterAddOnName string = "governance-policy-framework"
case1ManagedClusterAddOnCR string = "../resources/framework_addon_cr.yaml"
case1ClusterManagementAddOnCRDefault string = "../resources/framework_clustermanagementaddon.yaml"
case1ClusterManagementAddOnCR string = "../resources/framework_clustermanagementaddon_config.yaml"
case1hubAnnotationMCAOCR string = "../resources/framework_hub_annotation_addon_cr.yaml"
case1hubValuesMCAOCR string = "../resources/framework_hub_values_addon_cr.yaml"
case1DeploymentName string = "governance-policy-framework"
case1PodSelector string = "app=governance-policy-framework"
case1MWName string = "addon-governance-policy-framework-deploy-0"
case1MWPatch string = "../resources/manifestwork_add_patch.json"
)

var _ = Describe("Test framework deployment", func() {
var _ = Describe("Test framework deployment", Ordered, func() {
BeforeAll(func() {
By("Deploying the default governance-policy-framework ClusterManagementAddon to the hub cluster")
Kubectl("apply", "-f", case1ClusterManagementAddOnCRDefault)
})

AfterAll(func() {
By("Deleting the default governance-policy-framework ClusterManagementAddon from the hub cluster")
Kubectl("delete", "-f", case1ClusterManagementAddOnCRDefault)
})

It("should create the default framework deployment on separate managed clusters", func() {
for i, cluster := range managedClusterList[1:] {
Expect(cluster.clusterType).To(Equal("managed"))
Expand Down Expand Up @@ -118,8 +129,8 @@ var _ = Describe("Test framework deployment", func() {
It("should create the default framework deployment in hosted mode in klusterlet agent namespace",
Label("hosted-mode"), func() {
By("Creating the AddOnDeploymentConfig")
Kubectl("apply", "-f", addOnDeplomentConfigWithCustomVarsCR)
By("Creating the governance-policy-framework ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("apply", "-f", addOnDeploymentConfigWithCustomVarsCR)
By("Applying the governance-policy-framework ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("apply", "-f", case1ClusterManagementAddOnCR)

for i, cluster := range managedClusterList[1:] {
Expand Down Expand Up @@ -173,9 +184,9 @@ var _ = Describe("Test framework deployment", func() {
Expect(namespace).To(BeNil())
}
By("Deleting the AddOnDeploymentConfig")
Kubectl("delete", "-f", addOnDeplomentConfigWithCustomVarsCR, "--timeout=15s")
By("Deleting the config-policy-controller ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("delete", "-f", case1ClusterManagementAddOnCR, "--timeout=15s")
Kubectl("delete", "-f", addOnDeploymentConfigWithCustomVarsCR, "--timeout=15s")
By("Restoring the governance-policy-framework ClusterManagementAddOn")
Kubectl("apply", "-f", case1ClusterManagementAddOnCRDefault)
})

It("should create a framework deployment with customizations", func() {
Expand Down Expand Up @@ -218,8 +229,8 @@ var _ = Describe("Test framework deployment", func() {

It("should create a framework deployment with node selector on the managed cluster", func() {
By("Creating the AddOnDeploymentConfig")
Kubectl("apply", "-f", addOnDeplomentConfigCR)
By("Creating the governance-policy-framework ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("apply", "-f", addOnDeploymentConfigCR)
By("Applying the governance-policy-framework ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("apply", "-f", case1ClusterManagementAddOnCR)

for i, cluster := range managedClusterList {
Expand Down Expand Up @@ -265,9 +276,9 @@ var _ = Describe("Test framework deployment", func() {
}

By("Deleting the AddOnDeploymentConfig")
Kubectl("delete", "-f", addOnDeplomentConfigCR, "--timeout=15s")
By("Deleting the governance-policy-framework ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("delete", "-f", case1ClusterManagementAddOnCR, "--timeout=15s")
Kubectl("delete", "-f", addOnDeploymentConfigCR, "--timeout=15s")
By("Restoring the governance-policy-framework ClusterManagementAddOn")
Kubectl("apply", "-f", case1ClusterManagementAddOnCRDefault)
})

It("should use the onManagedClusterHub value set in helm values annotation", func() {
Expand Down
49 changes: 30 additions & 19 deletions test/e2e/case2_config_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import (
)

const (
case2ManagedClusterAddOnName string = "config-policy-controller"
case2ManagedClusterAddOnCR string = "../resources/config_policy_addon_cr.yaml"
case2ClusterManagementAddOnCR string = "../resources/config_policy_clustermanagementaddon.yaml"
case2DeploymentName string = "config-policy-controller"
case2PodSelector string = "app=config-policy-controller"
case2OpenShiftClusterClaim string = "../resources/openshift_cluster_claim.yaml"
policyCrdName string = "policies.policy.open-cluster-management.io"
deletionOrphanAnnotationKey string = "addon.open-cluster-management.io/deletion-orphan"
case2ManagedClusterAddOnName string = "config-policy-controller"
case2ManagedClusterAddOnCR string = "../resources/config_policy_addon_cr.yaml"
case2ClusterManagementAddOnCRDefault string = "../resources/config_policy_clustermanagementaddon.yaml"
case2ClusterManagementAddOnCR string = "../resources/config_policy_clustermanagementaddon_config.yaml"
case2DeploymentName string = "config-policy-controller"
case2PodSelector string = "app=config-policy-controller"
case2OpenShiftClusterClaim string = "../resources/openshift_cluster_claim.yaml"
policyCrdName string = "policies.policy.open-cluster-management.io"
deletionOrphanAnnotationKey string = "addon.open-cluster-management.io/deletion-orphan"
)

func verifyConfigPolicyDeployment(
Expand Down Expand Up @@ -88,7 +89,17 @@ func verifyConfigPolicyDeployment(
}, 240, 1).Should(Equal(true))
}

var _ = Describe("Test config-policy-controller deployment", func() {
var _ = Describe("Test config-policy-controller deployment", Ordered, func() {
BeforeAll(func() {
By("Deploying the default config-policy-controller ClusterManagementAddon to the hub cluster")
Kubectl("apply", "-f", case2ClusterManagementAddOnCRDefault)
})

AfterAll(func() {
By("Deleting the default config-policy-controller ClusterManagementAddon from the hub cluster")
Kubectl("delete", "-f", case2ClusterManagementAddOnCRDefault)
})

It("should create the default config-policy-controller deployment on the managed cluster", func() {
for i, cluster := range managedClusterList {
logPrefix := cluster.clusterType + " " + cluster.clusterName + ": "
Expand All @@ -115,8 +126,8 @@ var _ = Describe("Test config-policy-controller deployment", func() {

It("should create a config-policy-controller deployment with node selector on the managed cluster", func() {
By("Creating the AddOnDeploymentConfig")
Kubectl("apply", "-f", addOnDeplomentConfigCR)
By("Creating the config-policy-controller ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("apply", "-f", addOnDeploymentConfigCR)
By("Applying the config-policy-controller ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("apply", "-f", case2ClusterManagementAddOnCR)

for i, cluster := range managedClusterList {
Expand Down Expand Up @@ -157,9 +168,9 @@ var _ = Describe("Test config-policy-controller deployment", func() {
}

By("Deleting the AddOnDeploymentConfig")
Kubectl("delete", "-f", addOnDeplomentConfigCR, "--timeout=15s")
By("Deleting the config-policy-controller ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("delete", "-f", case2ClusterManagementAddOnCR, "--timeout=15s")
Kubectl("delete", "-f", addOnDeploymentConfigCR, "--timeout=15s")
By("Restoring the default config-policy-controller ClusterManagementAddOn")
Kubectl("apply", "-f", case2ClusterManagementAddOnCRDefault)
})

It("should create the default config-policy-controller deployment in hosted mode", Label("hosted-mode"), func() {
Expand Down Expand Up @@ -213,8 +224,8 @@ var _ = Describe("Test config-policy-controller deployment", func() {
It("should create the default config-policy-controller deployment in hosted mode in klusterlet agent namespace",
Label("hosted-mode"), func() {
By("Creating the AddOnDeploymentConfig")
Kubectl("apply", "-f", addOnDeplomentConfigWithCustomVarsCR)
By("Creating the config-policy-controller ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("apply", "-f", addOnDeploymentConfigWithCustomVarsCR)
By("Applying the config-policy-controller ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("apply", "-f", case2ClusterManagementAddOnCR)

for i, cluster := range managedClusterList[1:] {
Expand Down Expand Up @@ -286,9 +297,9 @@ var _ = Describe("Test config-policy-controller deployment", func() {
Expect(namespace).To(BeNil())
}
By("Deleting the AddOnDeploymentConfig")
Kubectl("delete", "-f", addOnDeplomentConfigWithCustomVarsCR, "--timeout=15s")
By("Deleting the config-policy-controller ClusterManagementAddOn to use the AddOnDeploymentConfig")
Kubectl("delete", "-f", case2ClusterManagementAddOnCR, "--timeout=15s")
Kubectl("delete", "-f", addOnDeploymentConfigWithCustomVarsCR, "--timeout=15s")
By("Restoring the default config-policy-controller ClusterManagementAddOn")
Kubectl("apply", "-f", case2ClusterManagementAddOnCRDefault)
})

It("should create a config-policy-controller deployment with customizations", func() {
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (
)

const (
addonNamespace string = "open-cluster-management-agent-addon"
kubeconfigFilename string = "../../kubeconfig_cluster"
loggingLevelAnnotation string = "log-level=8"
evaluationConcurrencyAnnotation string = "policy-evaluation-concurrency=5"
clientQPSAnnotation string = "client-qps=50"
prometheusEnabledAnnotation string = "prometheus-metrics-enabled=true"
addOnDeplomentConfigCR string = "../resources/addondeploymentconfig.yaml"
addOnDeplomentConfigWithCustomVarsCR string = "../resources/addondeploymentconfig_customvars.yaml"
addonNamespace string = "open-cluster-management-agent-addon"
kubeconfigFilename string = "../../kubeconfig_cluster"
loggingLevelAnnotation string = "log-level=8"
evaluationConcurrencyAnnotation string = "policy-evaluation-concurrency=5"
clientQPSAnnotation string = "client-qps=50"
prometheusEnabledAnnotation string = "prometheus-metrics-enabled=true"
addOnDeploymentConfigCR string = "../resources/addondeploymentconfig.yaml"
addOnDeploymentConfigWithCustomVarsCR string = "../resources/addondeploymentconfig_customvars.yaml"
)

var (
Expand Down
7 changes: 0 additions & 7 deletions test/resources/config_policy_clustermanagementaddon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,3 @@ apiVersion: addon.open-cluster-management.io/v1alpha1
kind: ClusterManagementAddOn
metadata:
name: config-policy-controller
spec:
supportedConfigs:
- group: addon.open-cluster-management.io
resource: addondeploymentconfigs
defaultConfig:
name: addon-default-placement
namespace: open-cluster-management
11 changes: 11 additions & 0 deletions test/resources/config_policy_clustermanagementaddon_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: addon.open-cluster-management.io/v1alpha1
kind: ClusterManagementAddOn
metadata:
name: config-policy-controller
spec:
supportedConfigs:
- group: addon.open-cluster-management.io
resource: addondeploymentconfigs
defaultConfig:
name: addon-default-placement
namespace: open-cluster-management
7 changes: 0 additions & 7 deletions test/resources/framework_clustermanagementaddon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,3 @@ apiVersion: addon.open-cluster-management.io/v1alpha1
kind: ClusterManagementAddOn
metadata:
name: governance-policy-framework
spec:
supportedConfigs:
- group: addon.open-cluster-management.io
resource: addondeploymentconfigs
defaultConfig:
name: addon-default-placement
namespace: open-cluster-management
11 changes: 11 additions & 0 deletions test/resources/framework_clustermanagementaddon_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: addon.open-cluster-management.io/v1alpha1
kind: ClusterManagementAddOn
metadata:
name: governance-policy-framework
spec:
supportedConfigs:
- group: addon.open-cluster-management.io
resource: addondeploymentconfigs
defaultConfig:
name: addon-default-placement
namespace: open-cluster-management

0 comments on commit b3d6cf1

Please sign in to comment.