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

refactor: addition of rbac needed for instascale controller #304

Merged
merged 4 commits into from
Sep 27, 2023

Conversation

dimakis
Copy link
Contributor

@dimakis dimakis commented Sep 22, 2023

Issue link

closes #278

What changes have been made

Addition of a ClusterRole and a ClusterRoleBinding which binds the required permissions to the CFO serviceaccount

Verification steps

Run through demo instascale NBs with clusters leveraging machinepools (OSD) and machinesets (instructions for sample can be found here)

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • Testing is not required for this change

config/rbac/instascale_role.yaml Outdated Show resolved Hide resolved
config/rbac/instascale_role.yaml Outdated Show resolved Hide resolved
- apiGroups:
- machine.openshift.io
resources:
- '*'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could wildcard be avoided? It's generally a best practice recommended by SRE.

config/rbac/instascale_role.yaml Outdated Show resolved Hide resolved
config/rbac/instascale_role.yaml Outdated Show resolved Hide resolved
Comment on lines 52 to 53
- controlplanemachinesets
- machinehealthchecks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these two resources really used by InstaScale?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have specified I've pushed this as myself and mark are testing which are actually used and what we can cut away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if you know off hand...that would save us some time?

I was doubtful that we used those TBH

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that InstaScale only uses the Machine and MachineSet APIs but better double checking.

Copy link
Contributor

@Bobbins228 Bobbins228 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this on an OCP cluster with Antonin's requested changes and got expected InstaScale behaviour.

When testing with OSD I received this error on scale up:

E0925 15:58:54.827990 1 machinepools.go:58] Error creating MachinePool: expected response content type 'application/json' but received '' and content ''
I0925 15:58:54.828009 1 machinepools.go:60] Created MachinePool: <nil>
E0925 15:58:55.263876 1 machinepools.go:58] Error creating MachinePool: expected response content type 'application/json' but received '' and content ''
I0925 15:58:55.263893 1 machinepools.go:60] Created MachinePool: <nil>

@astefanutti
Copy link
Contributor

When testing with OSD I received this error on scale up:

E0925 15:58:54.827990 1 machinepools.go:58] Error creating MachinePool: expected response content type 'application/json' but received '' and content ''
I0925 15:58:54.828009 1 machinepools.go:60] Created MachinePool: <nil>
E0925 15:58:55.263876 1 machinepools.go:58] Error creating MachinePool: expected response content type 'application/json' but received '' and content ''
I0925 15:58:55.263893 1 machinepools.go:60] Created MachinePool: <nil>

Could it be that we are missing permissions on machinepools or other related resources?

Comment on lines 23 to 40
- apiGroups:
- apps
resources:
- machineset
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- machineset/status
verbs:
- get
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are MachineSet APIs really in the apps group? It seems it's a wrong duplicate of the machine.openshift.io one.

Copy link
Contributor Author

@dimakis dimakis Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, I didn't think they were in the apps group, I thought first class objects like replicasets, deployments etc were.

but I was just copying what was in the original role to try get it working.

I can't really figure out why this is the case, even getting rid of those and allowing the wildcard on the machine.openshift.io group doesn't work and just returns the same error as ye got.
I also can't seem to find a machinepool resource for any api-group in any of the docs.
Any ideas here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't think the error is related to the RBAC changes. I suspect there is an issue with the OCM client configuration.

@astefanutti
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Sep 27, 2023
@astefanutti
Copy link
Contributor

/approve

@openshift-ci
Copy link

openshift-ci bot commented Sep 27, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: astefanutti

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit dafc36b into main Sep 27, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add RBAC required by the InstaScale controller
4 participants