Skip to content

Commit

Permalink
modify helloworld addon
Browse files Browse the repository at this point in the history
Signed-off-by: haoqing0110 <[email protected]>
  • Loading branch information
haoqing0110 committed Mar 19, 2024
1 parent 7caafd5 commit 7c9cec9
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/example/helloworld/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions examples/deploy/addon/helloworld/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions examples/deploy/addon/helloworld/resources/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: addon.open-cluster-management.io/v1alpha1
kind: AddOnDeploymentConfig
metadata:
name: helloworld
namespace: open-cluster-management
spec:
agentInstallNamespace: default
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions examples/deploy/addon/helloworld/resources/mclsetbinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: cluster.open-cluster-management.io/v1beta2
kind: ManagedClusterSetBinding
metadata:
name: global
namespace: open-cluster-management
spec:
clusterSet: global
9 changes: 9 additions & 0 deletions examples/deploy/addon/helloworld/resources/placement.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion test/e2e/helloworld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 7c9cec9

Please sign in to comment.