Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NETOBSERV-1893: fix netobserv-mertics-reader role creation [1.7 backport] #800

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion controllers/flp/flp_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ func reconcileDataAccessRoles(ctx context.Context, r *reconcilers.Common, b *bui
}
}
// Install netobserv-metrics-reader role
return r.ReconcileClusterRole(ctx, &resources.PromReaderCR)
cr := resources.PromReaderCR()
return r.ReconcileClusterRole(ctx, &cr)
}

func (r *Reconciler) getOpenShiftSubnets(ctx context.Context) ([]flowslatest.SubnetLabel, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/loki/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func ClusterRoles(appName, saName, namespace string) ([]rbacv1.ClusterRole, []rbacv1.ClusterRoleBinding) {
crb := writerBinding(appName, saName, namespace)
return []rbacv1.ClusterRole{resources.LokiWriterCR, resources.LokiReaderCR}, []rbacv1.ClusterRoleBinding{*crb}
return []rbacv1.ClusterRole{resources.LokiWriterCR(), resources.LokiReaderCR()}, []rbacv1.ClusterRoleBinding{*crb}
}

func writerBinding(appName, saName, namespace string) *rbacv1.ClusterRoleBinding {
Expand Down
64 changes: 35 additions & 29 deletions pkg/resources/static_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,43 @@ import (
"github.com/netobserv/network-observability-operator/controllers/constants"
)

var LokiWriterCR = rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: constants.LokiCRWriter,
},
Rules: []rbacv1.PolicyRule{{
APIGroups: []string{"loki.grafana.com"},
Resources: []string{"network"},
ResourceNames: []string{"logs"},
Verbs: []string{"create"},
}},
func LokiWriterCR() rbacv1.ClusterRole {
return rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: constants.LokiCRWriter,
},
Rules: []rbacv1.PolicyRule{{
APIGroups: []string{"loki.grafana.com"},
Resources: []string{"network"},
ResourceNames: []string{"logs"},
Verbs: []string{"create"},
}},
}
}

var LokiReaderCR = rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: constants.LokiCRReader,
},
Rules: []rbacv1.PolicyRule{{
APIGroups: []string{"loki.grafana.com"},
Resources: []string{"network"},
ResourceNames: []string{"logs"},
Verbs: []string{"get"},
}},
func LokiReaderCR() rbacv1.ClusterRole {
return rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: constants.LokiCRReader,
},
Rules: []rbacv1.PolicyRule{{
APIGroups: []string{"loki.grafana.com"},
Resources: []string{"network"},
ResourceNames: []string{"logs"},
Verbs: []string{"get"},
}},
}
}

var PromReaderCR = rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: constants.PromCRReader,
},
Rules: []rbacv1.PolicyRule{{
APIGroups: []string{"metrics.k8s.io"},
Resources: []string{"pods"},
Verbs: []string{"create"},
}},
func PromReaderCR() rbacv1.ClusterRole {
return rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: constants.PromCRReader,
},
Rules: []rbacv1.PolicyRule{{
APIGroups: []string{"metrics.k8s.io"},
Resources: []string{"pods"},
Verbs: []string{"create"},
}},
}
}
Loading