Skip to content

Commit

Permalink
fix: issues with aggregated roles
Browse files Browse the repository at this point in the history
Signed-off-by: iam-veeramalla <abhishek.veeramalla@gmail.com>
  • Loading branch information
iam-veeramalla committed May 9, 2023
1 parent 1bd2f0c commit 953e614
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ metadata:
}
]
capabilities: Basic Install
createdAt: "2023-05-04T08:00:38Z"
createdAt: "2023-05-09T11:21:43Z"
operators.operatorframework.io/builder: operator-sdk-v1.28.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
name: argo-rollouts-manager.v0.0.1
Expand Down Expand Up @@ -150,6 +150,7 @@ spec:
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
Expand All @@ -161,17 +162,25 @@ spec:
- analysistemplates
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- argoproj.io
resources:
- clusteranalysistemplates
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- argoproj.io
Expand Down Expand Up @@ -204,8 +213,12 @@ spec:
resources:
- rollouts
- rollouts/finalizers
- rollouts/scale
- rollouts/status
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
Expand Down
13 changes: 13 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ rules:
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
Expand All @@ -107,17 +108,25 @@ rules:
- analysistemplates
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- argoproj.io
resources:
- clusteranalysistemplates
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- argoproj.io
Expand Down Expand Up @@ -150,8 +159,12 @@ rules:
resources:
- rollouts
- rollouts/finalizers
- rollouts/scale
- rollouts/status
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
Expand Down
8 changes: 4 additions & 4 deletions controllers/argorollouts_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ var log = logr.Log.WithName("rollouts-controller")
//+kubebuilder:rbac:groups="",resources=podtemplates,verbs=get;list;watch
//+kubebuilder:rbac:groups="appmesh.k8s.aws",resources=virtualnodes;virtualrouters,verbs=get;list;watch;update;patch
//+kubebuilder:rbac:groups="appmesh.k8s.aws",resources=virtualservices,verbs=get;list;watch
//+kubebuilder:rbac:groups="argoproj.io",resources=analysisruns;analysisruns/finalizers;experiments;experiments/finalizers,verbs=create;get;list;watch;update;patch;delete
//+kubebuilder:rbac:groups="argoproj.io",resources=analysistemplates,verbs=create;get;list;watch
//+kubebuilder:rbac:groups="argoproj.io",resources=clusteranalysistemplates,verbs=create;get;list;watch
//+kubebuilder:rbac:groups="argoproj.io",resources=rollouts;rollouts/finalizers;rollouts/status,verbs=get;list;watch;update;patch
//+kubebuilder:rbac:groups="argoproj.io",resources=analysisruns;analysisruns/finalizers;experiments;experiments/finalizers,verbs=create;get;list;watch;update;patch;delete;deletecollection
//+kubebuilder:rbac:groups="argoproj.io",resources=analysistemplates,verbs=create;get;list;watch;update;patch;delete;deletecollection
//+kubebuilder:rbac:groups="argoproj.io",resources=clusteranalysistemplates,verbs=create;get;list;watch;update;patch;delete;deletecollection
//+kubebuilder:rbac:groups="argoproj.io",resources=rollouts;rollouts/finalizers;rollouts/status;rollouts/scale,verbs=create;get;list;watch;update;patch;delete;deletecollection
//+kubebuilder:rbac:groups="batch",resources=jobs,verbs=create;get;list;watch;update;patch;delete
//+kubebuilder:rbac:groups="coordination.k8s.io",resources=leases,verbs=create;get;update
//+kubebuilder:rbac:groups="elbv2.k8s.aws",resources=targetgroupbindings,verbs=list;get
Expand Down
2 changes: 2 additions & 0 deletions controllers/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const (
// ArgoRolloutsImageEnvName is an environment variable that can be used to deploy a
// Custom Image of rollouts controller.
ArgoRolloutsImageEnvName = "ARGO_ROLLOUTS_IMAGE"
// DefaultArgoRolloutsMetricsServiceName is the default name for rollouts metrics service.
DefaultArgoRolloutsMetricsServiceName = "argo-rollouts-metrics"
// ArgoRolloutsDefaultImage is the default image for rollouts controller.
DefaultArgoRolloutsImage = "quay.io/argoproj/argo-rollouts"
// ArgoRolloutsDefaultVersion is the default version for the rollouts controller.
Expand Down
4 changes: 2 additions & 2 deletions controllers/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func (r *RolloutManagerReconciler) reconcileRolloutsController(cr *rolloutsApi.R
return err
}

log.Info("reconciling rollouts service")
if err := r.reconcileRolloutsService(cr); err != nil {
log.Info("reconciling rollouts metrics service")
if err := r.reconcileRolloutsMetricsService(cr); err != nil {
return err
}

Expand Down
9 changes: 6 additions & 3 deletions controllers/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,19 @@ func (r *RolloutManagerReconciler) reconcileRolloutsAggregateToViewClusterRole(c
return nil
}

// Reconcile rollouts service.
func (r *RolloutManagerReconciler) reconcileRolloutsService(cr *rolloutsApi.RolloutManager) error {
// Reconcile rollouts metrics service.
func (r *RolloutManagerReconciler) reconcileRolloutsMetricsService(cr *rolloutsApi.RolloutManager) error {

expectedSvc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: DefaultArgoRolloutsResourceName,
Name: DefaultArgoRolloutsMetricsServiceName,
Namespace: cr.Namespace,
},
}
setRolloutsLabels(&expectedSvc.ObjectMeta)
// overwrite the annotations for rollouts metrics service
expectedSvc.ObjectMeta.Labels["app.kubernetes.io/name"] = DefaultArgoRolloutsMetricsServiceName
expectedSvc.ObjectMeta.Labels["app.kubernetes.io/component"] = "server"

expectedSvc.Spec.Ports = []corev1.ServicePort{
{
Expand Down
4 changes: 2 additions & 2 deletions controllers/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ func TestReconcileRolloutManager_verifyRolloutsResources(t *testing.T) {

service := &corev1.Service{}
if err = r.Client.Get(context.TODO(), types.NamespacedName{
Name: DefaultArgoRolloutsResourceName,
Name: DefaultArgoRolloutsMetricsServiceName,
Namespace: a.Namespace,
}, service); err != nil {
t.Fatalf("failed to find the rollouts service: %#v\n", err)
t.Fatalf("failed to find the rollouts metrics service: %#v\n", err)
}

secret := &corev1.Secret{}
Expand Down
6 changes: 3 additions & 3 deletions examples/catalog_source.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: argo-rollouts-manager-catalog
namespace: openshift-marketplace # for openshift choose - `openshift-marketplace` namespace
namespace: openshift-marketplace # for kubernetes choose - `operators` namespace
spec:
sourceType: grpc
image: quay.io/aveerama/argo-rollouts-manager-catalog@sha256:dc3aaf1ae4148accac61c2d03abf6784a239f5350e244e931a0b8d414031adc4 # replace with your catalog image
image: quay.io/aveerama/argo-rollouts-manager-catalog@sha256:00d94e2b82490a98a06025c48b2f4781f85eaf626a4a0f6d8b6da1a9b8a4ff19 # replace with your catalog image
displayName: Argo Rollouts Manager
publisher: Abhishek Veeramalla
publisher: Abhishek Veeramalla

0 comments on commit 953e614

Please sign in to comment.