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

Add support for service-specific service accounts in place of default in generated kustomize manifests #777

Closed
komish opened this issue May 12, 2021 · 7 comments · Fixed by aws-controllers-k8s/code-generator#270
Assignees
Labels
kind/enhancement Categorizes issue or PR as related to existing feature enhancements. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@komish
Copy link
Contributor

komish commented May 12, 2021

Is your feature request related to a problem?

Yes - I ran into an issue when deploying multiple service controllers into the same ack-system namespace in an Operator Lifecycle Manager based cluster.

OLM establishes an owner reference on service accounts that are used for installed controllers. When two controllers use the same service account, the original owner reference is removed which breaks OLM's ability to upgrade the controller.

NOTE - this is being patched on the OLM side! operator-framework/operator-lifecycle-manager#2128

However - Kubebuilder has enabled support for non-default service accounts as of v3.0.0:
https://github.com/kubernetes-sigs/kubebuilder/releases/tag/v3.0.0
and, more specifically
kubernetes-sigs/kubebuilder#2070

With that in mind, I think it may still be beneficial to add support for service-specific non-default service accounts.

Describe the solution you'd like

Existing kustomize configuration files that are generated for a controller will configure RBAC in association with the default service account. That is, (Cluster)RoleBindings will, by default, target the default service account, and the controller deployment manifest will render with no serviceAccountName definition, which means that it will get the default service account when applied to a cluster.

Consider scaffolding these with a service account reference relative to the controller that's being generated. E.g. ack-sagemaker-service-account for the SageMaker controller.

To implement, I think the changes would be fairly minimal:

A note that, as described, there would not be backwards compatibility with the previous default service account. I would assume that backwards compatibility would be a matter of adding a flag for the service account to the relevant generator (which I believe is the controller generator) and then handling the user input or default values. If no backwards compatibility is required, then you should just be able to make the above changes.

Describe alternatives you've considered

I've considered making adjustments to the service account in post-generation scripts, but it overall seems like it would be a bit too flimsy.

@komish komish added the kind/enhancement Categorizes issue or PR as related to existing feature enhancements. label May 12, 2021
@komish
Copy link
Contributor Author

komish commented May 12, 2021

chmod-ing this issue number is dangerous!

@ack-bot
Copy link
Collaborator

ack-bot commented Aug 28, 2021

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://github.com/aws-controllers-k8s/community.
/lifecycle stale

@ack-bot ack-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 28, 2021
@acornett21
Copy link
Contributor

/remove-lifecycle stale

@ack-bot ack-bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 17, 2021
@acornett21
Copy link
Contributor

Double check the below commit, test and verify:

komish/code-generator@75cbebe

@ack-bot
Copy link
Collaborator

ack-bot commented Jan 6, 2022

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://github.com/aws-controllers-k8s/community.
/lifecycle stale

@ack-bot ack-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 6, 2022
@acornett21
Copy link
Contributor

/assign

@vijtrip2
Copy link
Contributor

/lifecycle frozen

@ack-bot ack-bot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 18, 2022
ack-bot pushed a commit to aws-controllers-k8s/test-infra that referenced this issue Jan 25, 2022
Issue #, if available:
- Relates: aws-controllers-k8s/community#777

Description of changes:
This pull request is needed to get tests to pass for 
- aws-controllers-k8s/code-generator#270 

It also removes `sha` information from k8's versions, since this `sha` version is not static. Meaning that k8s can and does update a sha for a given version to fix security updates and some of these `shas` can no longer be pulled locally.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Signed-off-by: Adam D. Cornett <adc@redhat.com>
ack-bot pushed a commit to aws-controllers-k8s/code-generator that referenced this issue Jan 25, 2022
Issue #, if available:
- Fixes: aws-controllers-k8s/community#777

Description of changes:
The goal of this is to move away from using the default service account. It seems this might have been done with the helm charts/templates, but was not ported to the Kustomization files. This means each operator/controller would have its own service account. Things that changed are below:

- Refactored build so that ServiceAccountName is available in ack-generate controller process as well as ack-generate release process
- added in `/rbac/service-account.yaml.tpl` to create a service account, and then referece this account in the `Deployment` and `ClusterRoleBinding`
- Refactored build/release `sh` files to add in `ACK_GENERATE_SERVICE_ACCOUNT_NAME` to be used in both build and release process
- Reordered some of the variables in the `sh` files so that if there is an error in the build/release process the `Default` values are actually presented to the user (currently they show up as blank since the variables are not initilaized before the `USAGE` variable)
- **NOTE:** This changes the service account name in the `helm` process as well. It changes it from `ack-$SERVICE-controller` to `ack-$SERVICE-service-account`. I am not sure if this is backwards compatible for when a controller is installed/updated via a helm deployment.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Signed-off-by: Adam D. Cornett <adc@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Categorizes issue or PR as related to existing feature enhancements. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants