Skip to content

Commit

Permalink
Adopt install strategy in foundation addon (#729)
Browse files Browse the repository at this point in the history
* Adopt install strategy in foundation addon

Signed-off-by: Jian Qiu <[email protected]>

* Add unit tests

Signed-off-by: Jian Qiu <[email protected]>

---------

Signed-off-by: Jian Qiu <[email protected]>
  • Loading branch information
qiujian16 authored May 20, 2024
1 parent 9b23e1d commit e3f1334
Show file tree
Hide file tree
Showing 190 changed files with 4,754 additions and 5,803 deletions.
18 changes: 8 additions & 10 deletions cmd/controller/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package app

import (
"context"

"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/managedserviceaccount"
msav1beta1client "open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versioned/typed/authentication/v1beta1"

Expand Down Expand Up @@ -40,14 +41,13 @@ import (
"github.com/stolostron/multicloud-operators-foundation/cmd/controller/app/options"
"github.com/stolostron/multicloud-operators-foundation/pkg/addon"
"github.com/stolostron/multicloud-operators-foundation/pkg/cache"
"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/addoninstall"
"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/clusterca"
"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/clusterinfo"
"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/clusterrole"
"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/clusterset/clusterclaim"
"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/clusterset/clusterdeployment"
clustersetmapper "github.com/stolostron/multicloud-operators-foundation/pkg/controllers/clusterset/clustersetmapper"
globalclusterset "github.com/stolostron/multicloud-operators-foundation/pkg/controllers/clusterset/globalclusterset"
"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/clusterset/clustersetmapper"
"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/clusterset/globalclusterset"
"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/clusterset/syncclusterrolebinding"
"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/clusterset/syncrolebinding"
"github.com/stolostron/multicloud-operators-foundation/pkg/controllers/gc"
Expand Down Expand Up @@ -162,14 +162,17 @@ func Run(o *options.ControllerRunOptions, ctx context.Context) error {
WithGetValuesFuncs(
addon.NewGetValuesFunc(o.AddonImage),
addonfactory.GetValuesFromAddonAnnotation,
addonfactory.GetAddOnDeloymentConfigValues(
addonfactory.NewAddOnDeloymentConfigGetter(addonClient),
addonfactory.GetAddOnDeploymentConfigValues(
afutils.NewAddOnDeploymentConfigGetter(addonClient),
addonfactory.ToAddOnNodePlacementValues,
addonfactory.ToAddOnCustomizedVariableValues,
),
).
WithAgentInstallNamespace(addon.AddonInstallNamespaceFunc(
afutils.NewAddOnDeploymentConfigGetter(addonClient), mgr.GetClient())).
WithAgentRegistrationOption(registrationOption).
WithAgentHostedModeEnabledOption().
WithAgentHostedInfoFn(addon.HostedClusterInfo).
BuildHelmAgentAddon()
if err != nil {
klog.Errorf("failed to build agent %v", err)
Expand Down Expand Up @@ -225,11 +228,6 @@ func Run(o *options.ControllerRunOptions, ctx context.Context) error {

cleanGarbageFinalizer := gc.NewCleanGarbageFinalizer(kubeClient)

if err = addoninstall.SetupWithManager(mgr); err != nil {
klog.Errorf("unable to setup addoninstall reconciler: %v", err)
return err
}

if err = managedserviceaccount.SetupWithManager(mgr, msaClient); err != nil {
klog.Errorf("unable to setup log managedserviceaccount reconciler: %v", err)
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ apiVersion: addon.open-cluster-management.io/v1alpha1
kind: ClusterManagementAddOn
metadata:
name: work-manager
annotations:
"addon.open-cluster-management.io/lifecycle": "addon-manager"
spec:
addOnMeta:
displayName: work-manager
description: "work-manager provides action, view and rbac settings"
supportedConfigs:
- group: addon.open-cluster-management.io
resource: addondeploymentconfigs
installStrategy:
type: Placements
placements:
- name: global
namespace: open-cluster-management-global-set
34 changes: 17 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ require (
github.com/openshift/client-go v0.0.0-20240422164335-6c851f4919dd
github.com/openshift/hive/apis v0.0.0-20240503201730-e11a23b88b31
github.com/openshift/library-go v0.0.0-20240509114237-dc3020f4b513
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/common v0.44.0
github.com/prometheus/client_golang v1.18.0
github.com/prometheus/common v0.45.0
github.com/smartystreets/goconvey v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stolostron/cluster-lifecycle-api v0.0.0-20240506072238-d0d33efc0d4e
Expand All @@ -33,18 +33,18 @@ require (
k8s.io/klog/v2 v2.120.1
k8s.io/kube-aggregator v0.29.2
k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f
open-cluster-management.io/addon-framework v0.9.1
open-cluster-management.io/addon-framework v0.9.1-0.20240416063208-ecb7f349df05
open-cluster-management.io/api v0.13.0
open-cluster-management.io/managed-serviceaccount v0.5.0
open-cluster-management.io/sdk-go v0.13.0
sigs.k8s.io/controller-runtime v0.16.6
open-cluster-management.io/sdk-go v0.13.1-0.20240416030555-aa744f426379
sigs.k8s.io/controller-runtime v0.17.2
sigs.k8s.io/yaml v1.4.0
)

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect
Expand All @@ -55,10 +55,10 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
Expand All @@ -83,14 +83,14 @@ require (
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -103,20 +103,20 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/smarty/assertions v1.15.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/v3 v3.5.10 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
Expand Down Expand Up @@ -148,7 +148,7 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
helm.sh/helm/v3 v3.11.1 // indirect
helm.sh/helm/v3 v3.14.2 // indirect
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
k8s.io/kms v0.29.2 // indirect
Expand Down
Loading

0 comments on commit e3f1334

Please sign in to comment.