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

Backport to 5.10 #840

Merged
merged 2 commits into from Jan 26, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions deploy/role_ui.yaml
@@ -0,0 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: noobaa-odf-ui
rules:
- verbs:
- get
- watch
- list
apiGroups:
- noobaa.io
resources:
- noobaas
- bucketclasses
4 changes: 4 additions & 0 deletions deploy/service_account_ui.yaml
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: noobaa-odf-ui
26 changes: 26 additions & 0 deletions pkg/bundle/deploy.go
Expand Up @@ -5140,6 +5140,24 @@ rules:
- use
`

const Sha256_deploy_role_ui_yaml = "49d210f2ec7facbd486e6ac96515c1d2886f26afe6f7155be3994b4f0b1d0311"

const File_deploy_role_ui_yaml = `apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: noobaa-odf-ui
rules:
- verbs:
- get
- watch
- list
apiGroups:
- noobaa.io
resources:
- noobaas
- bucketclasses
`

const Sha256_deploy_scc_yaml = "cbb071961f7dd77e5bdca7e36b89e1e1982265c4e7dc95f00109d0acc64a3c06"

const File_deploy_scc_yaml = `apiVersion: security.openshift.io/v1
Expand Down Expand Up @@ -5242,3 +5260,11 @@ metadata:
name: noobaa-endpoint
`

const Sha256_deploy_service_account_ui_yaml = "d6cb0e92fdb350148399e1ac42bfa640e254bdbb295c9a15dc9edfd4335e73f6"

const File_deploy_service_account_ui_yaml = `apiVersion: v1
kind: ServiceAccount
metadata:
name: noobaa-odf-ui
`

5 changes: 5 additions & 0 deletions pkg/olm/olm.go
Expand Up @@ -245,6 +245,11 @@ func GenerateCSV(opConf *operator.Conf, csvParams *generateCSVParams) *operv1.Cl
ServiceAccountName: opConf.SAEndpoint.Name,
Rules: opConf.RoleEndpoint.Rules,
})
csv.Spec.InstallStrategy.StrategySpec.Permissions = append(csv.Spec.InstallStrategy.StrategySpec.Permissions,
operv1.StrategyDeploymentPermissions{
ServiceAccountName: opConf.SAUI.Name,
Rules: opConf.RoleUI.Rules,
})
csv.Spec.InstallStrategy.StrategySpec.DeploymentSpecs = []operv1.StrategyDeploymentSpec{}
csv.Spec.InstallStrategy.StrategySpec.DeploymentSpecs = append(csv.Spec.InstallStrategy.StrategySpec.DeploymentSpecs,
operv1.StrategyDeploymentSpec{
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/operator.go
Expand Up @@ -237,9 +237,11 @@ func RunYaml(cmd *cobra.Command, args []string) {
type Conf struct {
NS *corev1.Namespace
SA *corev1.ServiceAccount
SAUI *corev1.ServiceAccount
SAEndpoint *corev1.ServiceAccount
Role *rbacv1.Role
RoleEndpoint *rbacv1.Role
RoleUI *rbacv1.Role
RoleBinding *rbacv1.RoleBinding
RoleBindingEndpoint *rbacv1.RoleBinding
ClusterRole *rbacv1.ClusterRole
Expand All @@ -259,8 +261,10 @@ func LoadOperatorConf(cmd *cobra.Command) *Conf {
c.NS = util.KubeObject(bundle.File_deploy_namespace_yaml).(*corev1.Namespace)
c.SA = util.KubeObject(bundle.File_deploy_service_account_yaml).(*corev1.ServiceAccount)
c.SAEndpoint = util.KubeObject(bundle.File_deploy_service_account_endpoint_yaml).(*corev1.ServiceAccount)
c.SAUI = util.KubeObject(bundle.File_deploy_service_account_ui_yaml).(*corev1.ServiceAccount)
c.Role = util.KubeObject(bundle.File_deploy_role_yaml).(*rbacv1.Role)
c.RoleEndpoint = util.KubeObject(bundle.File_deploy_role_endpoint_yaml).(*rbacv1.Role)
c.RoleUI = util.KubeObject(bundle.File_deploy_role_ui_yaml).(*rbacv1.Role)
c.RoleBinding = util.KubeObject(bundle.File_deploy_role_binding_yaml).(*rbacv1.RoleBinding)
c.RoleBindingEndpoint = util.KubeObject(bundle.File_deploy_role_binding_endpoint_yaml).(*rbacv1.RoleBinding)
c.ClusterRole = util.KubeObject(bundle.File_deploy_cluster_role_yaml).(*rbacv1.ClusterRole)
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/util.go
Expand Up @@ -1581,7 +1581,7 @@ func GetAvailabeKubeCli() string {
log.Printf("✅ kubectl exists - will use it for diagnostics\n")
} else {
log.Printf("❌ Could not find kubectl, will try to use oc instead, error: %s\n", err)
kubeCommand := "oc"
kubeCommand = "oc"
cmd = exec.Command(kubeCommand)
err = cmd.Run();
if err == nil {
Expand Down