diff --git a/cmd/example/helloworld/main.go b/cmd/example/helloworld/main.go index 7e66cc56e..dc04bbb06 100644 --- a/cmd/example/helloworld/main.go +++ b/cmd/example/helloworld/main.go @@ -24,6 +24,7 @@ import ( cmdfactory "open-cluster-management.io/addon-framework/pkg/cmd/factory" "open-cluster-management.io/addon-framework/pkg/utils" "open-cluster-management.io/addon-framework/pkg/version" + addonapiv1alpha1 "open-cluster-management.io/api/addon/v1alpha1" ) func main() { @@ -108,6 +109,11 @@ func runController(ctx context.Context, kubeConfig *rest.Config) error { ), ). WithAgentRegistrationOption(registrationOption). + WithAgentInstallNamespace( + func(addon *addonapiv1alpha1.ManagedClusterAddOn) string { + return helloworld.InstallationNamespace + }, + ). WithAgentHealthProber(helloworld.AgentHealthProber()). BuildTemplateAgentAddon() if err != nil { diff --git a/examples/deploy/addon/helloworld/kustomization.yaml b/examples/deploy/addon/helloworld/kustomization.yaml index 53f17d7fc..fad4e27b1 100644 --- a/examples/deploy/addon/helloworld/kustomization.yaml +++ b/examples/deploy/addon/helloworld/kustomization.yaml @@ -6,6 +6,9 @@ resources: - resources/service_account.yaml - resources/helloworld_clustermanagementaddon.yaml - resources/helloworld_controller.yaml +- resources/placement.yaml +- resources/mclsetbinding.yaml +- resources/config.yaml images: diff --git a/examples/deploy/addon/helloworld/resources/config.yaml b/examples/deploy/addon/helloworld/resources/config.yaml new file mode 100644 index 000000000..7bf06c457 --- /dev/null +++ b/examples/deploy/addon/helloworld/resources/config.yaml @@ -0,0 +1,7 @@ +apiVersion: addon.open-cluster-management.io/v1alpha1 +kind: AddOnDeploymentConfig +metadata: + name: helloworld + namespace: open-cluster-management +spec: + agentInstallNamespace: default \ No newline at end of file diff --git a/examples/deploy/addon/helloworld/resources/helloworld_clustermanagementaddon.yaml b/examples/deploy/addon/helloworld/resources/helloworld_clustermanagementaddon.yaml index ba46bb733..b7c79e6f7 100644 --- a/examples/deploy/addon/helloworld/resources/helloworld_clustermanagementaddon.yaml +++ b/examples/deploy/addon/helloworld/resources/helloworld_clustermanagementaddon.yaml @@ -9,3 +9,11 @@ spec: supportedConfigs: - group: addon.open-cluster-management.io resource: addondeploymentconfigs + defaultConfig: + name: helloworld + namespace: open-cluster-management + installStrategy: + type: Placements + placements: + - name: placement-helloworld + namespace: open-cluster-management \ No newline at end of file diff --git a/examples/deploy/addon/helloworld/resources/mclsetbinding.yaml b/examples/deploy/addon/helloworld/resources/mclsetbinding.yaml new file mode 100644 index 000000000..e5ea60ba6 --- /dev/null +++ b/examples/deploy/addon/helloworld/resources/mclsetbinding.yaml @@ -0,0 +1,7 @@ +apiVersion: cluster.open-cluster-management.io/v1beta2 +kind: ManagedClusterSetBinding +metadata: + name: global + namespace: open-cluster-management +spec: + clusterSet: global \ No newline at end of file diff --git a/examples/deploy/addon/helloworld/resources/placement.yaml b/examples/deploy/addon/helloworld/resources/placement.yaml new file mode 100644 index 000000000..2432305da --- /dev/null +++ b/examples/deploy/addon/helloworld/resources/placement.yaml @@ -0,0 +1,9 @@ +apiVersion: cluster.open-cluster-management.io/v1beta1 +kind: Placement +metadata: + name: placement-helloworld + namespace: open-cluster-management +spec: + tolerations: + - key: cluster.open-cluster-management.io/unreachable + operator: Exists \ No newline at end of file diff --git a/test/e2e/helloworld_test.go b/test/e2e/helloworld_test.go index 88a0f434f..825f96f3e 100644 --- a/test/e2e/helloworld_test.go +++ b/test/e2e/helloworld_test.go @@ -108,7 +108,7 @@ var _ = ginkgo.Describe("install/uninstall helloworld addons", func() { return err } - if cma.Annotations[addonapiv1alpha1.AddonLifecycleAnnotationKey] != addonapiv1alpha1.AddonLifecycleSelfManageAnnotationValue { + if cma.Annotations[addonapiv1alpha1.AddonLifecycleAnnotationKey] != addonapiv1alpha1.AddonLifecycleAddonManagerAnnotationValue { return fmt.Errorf("addon should have annotation, but get %v", cma.Annotations) }