diff --git a/bundle.Dockerfile b/bundle.Dockerfile index 5ec7dd85f..b9e4ddfab 100644 --- a/bundle.Dockerfile +++ b/bundle.Dockerfile @@ -7,7 +7,7 @@ LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/ LABEL operators.operatorframework.io.bundle.package.v1=gitops-operator LABEL operators.operatorframework.io.bundle.channels.v1=latest,gitops-1.8 LABEL operators.operatorframework.io.bundle.channel.default.v1=latest -LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.34.1 +LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.22.2 LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1 LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3 diff --git a/bundle/manifests/argoproj.io_rolloutmanagers.yaml b/bundle/manifests/argoproj.io_rolloutmanagers.yaml index 5c83def1e..1032c275e 100644 --- a/bundle/manifests/argoproj.io_rolloutmanagers.yaml +++ b/bundle/manifests/argoproj.io_rolloutmanagers.yaml @@ -34,6 +34,20 @@ spec: spec: description: RolloutManagerSpec defines the desired state of Argo Rollouts properties: + additionalMetadata: + description: Metadata to apply to the generated resources + properties: + annotations: + additionalProperties: + type: string + description: Annotations to add to the resources during its creation. + type: object + labels: + additionalProperties: + type: string + description: Labels to add to the resources during its creation. + type: object + type: object env: description: Env lets you specify environment for Rollouts pods items: diff --git a/bundle/manifests/gitops-operator.clusterserviceversion.yaml b/bundle/manifests/gitops-operator.clusterserviceversion.yaml index 18420e10c..df7081b76 100644 --- a/bundle/manifests/gitops-operator.clusterserviceversion.yaml +++ b/bundle/manifests/gitops-operator.clusterserviceversion.yaml @@ -164,13 +164,12 @@ metadata: capabilities: Deep Insights console.openshift.io/plugins: '["gitops-plugin"]' containerImage: quay.io/redhat-developer/gitops-operator - createdAt: "2024-05-23T14:48:45Z" description: Enables teams to adopt GitOps principles for managing cluster configurations and application delivery across hybrid multi-cluster Kubernetes environments. operatorframework.io/cluster-monitoring: "true" operatorframework.io/suggested-namespace: openshift-gitops-operator operators.openshift.io/infrastructure-features: '["disconnected"]' - operators.operatorframework.io/builder: operator-sdk-v1.34.1 + operators.operatorframework.io/builder: operator-sdk-v1.22.2 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: https://github.com/redhat-developer/gitops-operator support: Red Hat @@ -411,6 +410,14 @@ spec: - get - list - watch + - apiGroups: + - apiextensions.k8s.io + resources: + - customresourcedefinitions + verbs: + - get + - list + - watch - apiGroups: - appmesh.k8s.aws resources: diff --git a/bundle/metadata/annotations.yaml b/bundle/metadata/annotations.yaml index b4c300f32..58b2f6615 100644 --- a/bundle/metadata/annotations.yaml +++ b/bundle/metadata/annotations.yaml @@ -6,7 +6,7 @@ annotations: operators.operatorframework.io.bundle.package.v1: gitops-operator operators.operatorframework.io.bundle.channels.v1: latest,gitops-1.8 operators.operatorframework.io.bundle.channel.default.v1: latest - operators.operatorframework.io.metrics.builder: operator-sdk-v1.34.1 + operators.operatorframework.io.metrics.builder: operator-sdk-v1.22.2 operators.operatorframework.io.metrics.mediatype.v1: metrics+v1 operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3 diff --git a/config/crd/bases/argoproj.io_rolloutmanagers.yaml b/config/crd/bases/argoproj.io_rolloutmanagers.yaml index be7ee2c6f..ff9daf6bb 100644 --- a/config/crd/bases/argoproj.io_rolloutmanagers.yaml +++ b/config/crd/bases/argoproj.io_rolloutmanagers.yaml @@ -35,6 +35,20 @@ spec: spec: description: RolloutManagerSpec defines the desired state of Argo Rollouts properties: + additionalMetadata: + description: Metadata to apply to the generated resources + properties: + annotations: + additionalProperties: + type: string + description: Annotations to add to the resources during its creation. + type: object + labels: + additionalProperties: + type: string + description: Labels to add to the resources during its creation. + type: object + type: object env: description: Env lets you specify environment for Rollouts pods items: diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 29b75c093..d8e90efca 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -1,7 +1,9 @@ + --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: + creationTimestamp: null name: manager-role rules: - apiGroups: @@ -84,6 +86,14 @@ rules: - get - list - watch +- apiGroups: + - apiextensions.k8s.io + resources: + - customresourcedefinitions + verbs: + - get + - list + - watch - apiGroups: - appmesh.k8s.aws resources: diff --git a/controllers/gitopsservice_controller.go b/controllers/gitopsservice_controller.go index 72e731409..048656ac1 100644 --- a/controllers/gitopsservice_controller.go +++ b/controllers/gitopsservice_controller.go @@ -189,7 +189,8 @@ type ReconcileGitopsService struct { //+kubebuilder:rbac:groups="split.smi-spec.io",resources=trafficsplits,verbs=create;watch;get;update;patch //+kubebuilder:rbac:groups="traefik.containo.us",resources=traefikservices,verbs=watch;get;update //+kubebuilder:rbac:groups="x.getambassador.io",resources=ambassadormappings;mappings,verbs=create;watch;get;update;list;delete -// +kubebuilder:rbac:groups=argoproj.io,resources=notificationsconfigurations;notificationsconfigurations/finalizers,verbs=* +//+kubebuilder:rbac:groups=argoproj.io,resources=notificationsconfigurations;notificationsconfigurations/finalizers,verbs=* +//+kubebuilder:rbac:groups=apiextensions.k8s.io,resources=customresourcedefinitions,verbs=get;list;watch; // Reconcile reads that state of the cluster for a GitopsService object and makes changes based on the state read // and what is in the GitopsService.Spec diff --git a/go.mod b/go.mod index 2e415f203..2b8ea8b4f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/redhat-developer/gitops-operator go 1.21 require ( - github.com/argoproj-labs/argo-rollouts-manager v0.0.3-0.20240508151103-837f3074a22a + github.com/argoproj-labs/argo-rollouts-manager v0.0.3-0.20240525211646-b3e573f0e6ea github.com/argoproj-labs/argocd-operator v0.9.0-rc3.0.20240522063919-1ff45e5571c1 github.com/coreos/prometheus-operator v0.40.0 github.com/go-logr/logr v1.4.1 @@ -18,6 +18,7 @@ require ( golang.org/x/mod v0.17.0 gotest.tools v2.2.0+incompatible k8s.io/api v0.29.2 + k8s.io/apiextensions-apiserver v0.29.2 k8s.io/apimachinery v0.29.2 k8s.io/client-go v12.0.0+incompatible k8s.io/utils v0.0.0-20240102154912-e7106e64919e @@ -81,7 +82,6 @@ require ( gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.29.2 // indirect k8s.io/component-base v0.29.2 // indirect k8s.io/klog/v2 v2.120.1 // indirect k8s.io/kube-openapi v0.0.0-20240227032403-f107216b40e2 // indirect diff --git a/go.sum b/go.sum index 8d0c85b74..370e333a9 100644 --- a/go.sum +++ b/go.sum @@ -637,8 +637,8 @@ github.com/apache/arrow/go/v11 v11.0.0/go.mod h1:Eg5OsL5H+e299f7u5ssuXsuHQVEGC4x github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= -github.com/argoproj-labs/argo-rollouts-manager v0.0.3-0.20240508151103-837f3074a22a h1:bjcQkMYM5tlE52DS9AAZftzMZVDcEPueSDrmx6QtniM= -github.com/argoproj-labs/argo-rollouts-manager v0.0.3-0.20240508151103-837f3074a22a/go.mod h1:+qJpu01daETe3BpdO4XKaTe3ivFYY1LkrxeGfTbPI3I= +github.com/argoproj-labs/argo-rollouts-manager v0.0.3-0.20240525211646-b3e573f0e6ea h1:mEBK+0Y8wd/JFxq9TYyE9UY3Q1vC9G+U6+nFqy9GTvw= +github.com/argoproj-labs/argo-rollouts-manager v0.0.3-0.20240525211646-b3e573f0e6ea/go.mod h1:seR9B+tx6AbGaya+JA61HDBFciKx7FM7t/1IMhOwXlM= github.com/argoproj-labs/argocd-operator v0.9.0-rc3.0.20240522063919-1ff45e5571c1 h1:YDYzf9ixW2hxGf+3UjBPJHlJxHAqZy15gu5I+FiJHio= github.com/argoproj-labs/argocd-operator v0.9.0-rc3.0.20240522063919-1ff45e5571c1/go.mod h1:7sKiKXblkKFvdZQ6VVerbp4+HBboi3VdZuqSuTa7OX8= github.com/argoproj/argo-cd/v2 v2.10.8 h1:WRnzXqMiAapSYzR6fkDUBfen+irHlOeCG6zrXWuPU9E= diff --git a/main.go b/main.go index 1f56eb01e..2bb5db3a9 100644 --- a/main.go +++ b/main.go @@ -45,6 +45,7 @@ import ( templatev1 "github.com/openshift/api/template/v1" operatorsv1 "github.com/operator-framework/api/pkg/operators/v1" operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" + crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -169,6 +170,7 @@ func main() { registerComponentOrExit(mgr, templatev1.AddToScheme) registerComponentOrExit(mgr, appsv1.AddToScheme) registerComponentOrExit(mgr, oauthv1.AddToScheme) + registerComponentOrExit(mgr, crdv1.AddToScheme) // Start webhook only if ENABLE_CONVERSION_WEBHOOK is set if strings.EqualFold(os.Getenv("ENABLE_CONVERSION_WEBHOOK"), "true") { @@ -218,10 +220,19 @@ func main() { os.Exit(1) } + isNamespaceScoped := strings.ToLower(os.Getenv(rolloutManagerProvisioner.NamespaceScopedArgoRolloutsController)) == "true" + + if isNamespaceScoped { + setupLog.Info("Argo Rollouts manager running in namespaced-scoped mode") + } else { + setupLog.Info("Argo Rollouts manager running in cluster-scoped mode") + } + if err = (&rolloutManagerProvisioner.RolloutManagerReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - OpenShiftRoutePluginLocation: getArgoRolloutsOpenshiftRouteTrafficManagerPath(), + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + OpenShiftRoutePluginLocation: getArgoRolloutsOpenshiftRouteTrafficManagerPath(), + NamespaceScopedArgoRolloutsController: isNamespaceScoped, }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "Argo Rollouts") os.Exit(1)