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

Default Provider Service Account always created when overridden in ControllerConfig #2295

Closed
benagricola opened this issue May 7, 2021 · 4 comments · Fixed by #2880
Closed
Assignees
Labels
bug Something isn't working package

Comments

@benagricola
Copy link
Contributor

benagricola commented May 7, 2021

What happened?

Configuring provider-aws to use an existing IRSA-configured service account using the following ControllerConfig:

apiVersion: pkg.crossplane.io/v1alpha1
kind: ControllerConfig
metadata:
  name: provider-aws
spec:
  serviceAccountName: crossplane-aws-provider

We end up with our existing crossplane-aws-provider as well as an automatically created service account, which then has the ClusterRoleBinding applied to allow it to manage resources.

This means we have 1 service account with the right permissions to manage AWS resources and 1 with the right permissions to manage crossplane resources, but zero that can handle both:

$ k get sa -n crossplane-system | grep aws
aws-4ebd5d8c7cb7                              1         7m22s  # Crossplane-created with Cluster role binding
crossplane-aws-provider                       1         72m    # eksctl-created with IRSA role binding

How can we reproduce it?

Create a service account manually, use the above ControllerConfig to configure a provider and watch as you get 2 service accounts with mixed permissions.

Suggested fix

Do not create the service account if name is overridden by ControllerConfig serviceAccountName.

Ideally use the existing service account name when requesting permissions from the RBAC manager. I'm not sure if this is possible as rbac manager uses the owner reference to work out what SA to apply the binding to. When the service account is not created by crossplane, it might be necessary to add an additional check to the binding provider (linked above) to make sure it doesn't try to create a ClusterRoleBinding with no subjects.

What environment did it happen in?

Crossplane version: master on EKS

@benagricola benagricola added the bug Something isn't working label May 7, 2021
benagricola pushed a commit to benagricola/crossplane that referenced this issue May 7, 2021
When setting a `ControllerConfig` `serviceAccountName`, for a provider,
crossplane still creates its' own `ServiceAccount` which is not used
by the provider pod. This changes that behaviour so that if a
ControllerConfig overrides the `serviceAccountName` then a redundant SA
will not be created.

If an autogenerated SA is then overridden by `serviceAccountName` it
will not be deleted until the `ProviderRevision` itself is cleaned up.

Fixes crossplane#2295

Signed-off-by: Ben Agricola <[email protected]>
@hasheddan hasheddan self-assigned this May 19, 2021
@negz negz added the package label Aug 28, 2021
@danjo133
Copy link

danjo133 commented Oct 25, 2021

I was under the impression that setting this variable would set the name of the service account to be created? Would it be possible to have that behaviour and another flag createServiceAccount to decide if it should be created or not? I would prefer if crossplane can create the service account, clusterrole and clusterrolebindings, but I can decide on the name of the service account.

The problem I'm having now is that I have a config for eksctl which has a block for IAM service accounts like so

iam:
  serviceAccounts
  - metadata:
     name: provider-aws-${randomnumbers}
     namespace: crossplane-system
     labels:
       aws-usage: "cluster-ops"
     attachPolicyARNs:
     - "arn:aws:iam::aws:policy/AdministratorAccess" # preferably your own role with less privileges.
     roleName: ${clusteridentifier}-crossplane-provider-aws
     roleOnly: true

And I would like to be able to use eksctl to create all those resources at once when creating new clusters, instead of having to first create some resources, then install the provider to get the random name and then go back and update the config and then go back to whatever else should go into the cluster.

@ONordander
Copy link

Hi, could we get any information from maintainers regarding this?
Having the ability to specify the ServiceAccount and get the correct RBAC settings would really help our usecase.

@stale
Copy link

stale bot commented Aug 14, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 14, 2022
@hasheddan hasheddan reopened this Sep 6, 2022
@macmiranda
Copy link

I'm still seeing the same behavior on 1.9.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants