odo icon indicating copy to clipboard operation
odo copied to clipboard

WIP set service account for dev container via component attributes

Open vinny-sabatini opened this issue 3 years ago • 14 comments

Signed-off-by: Vinny Sabatini [email protected]

What type of PR is this:

/kind feature

What does this PR do / why we need it:

Allow users to specify what Kubernetes service account the pod should run as for an odo dev session. This is generally useful if you want your workload to have additional permissions within a Kubernetes cluster and you do not want to grant additional access to the default service account.

If the attribute is not set, the default service account will be used.

Which issue(s) this PR fixes:

Fixes #5977

PR acceptance criteria:

  • [ ] Unit test

  • [ ] Integration test

  • [ ] Documentation

How to test changes / Special notes to the reviewer:

  • In your Kubernetes cluster, create a service account
  • In your devfile, set .components.attributes.serviceAccountName for your container component to the name of the service account you created
    components:
    - attributes:
        serviceAccountName: my-service-account
      container:
        dedicatedPod: false
        endpoints:
        - name: http
          secure: false
          targetPort: 8080
        image: quay.io/devfile/golang:latest
        memoryLimit: 1024Mi
        mountSources: true
      name: runtime
    
  • Start odo dev
  • Check .spec.template.spec.serviceAccountName on the deployment, or .spec.serviceAccountName of the running pod

vinny-sabatini avatar Sep 09 '22 19:09 vinny-sabatini

Hi @vinny-sabatini. Thanks for your PR.

I'm waiting for a redhat-developer member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

openshift-ci[bot] avatar Sep 09 '22 19:09 openshift-ci[bot]

Deploy Preview for odo-docusaurus-preview ready!

Name Link
Latest commit 63e11ca8d81b57c9289dde44eda605d5890daef0
Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/631b999e361db200086d25a8
Deploy Preview https://deploy-preview-6111--odo-docusaurus-preview.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Sep 09 '22 19:09 netlify[bot]

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Sep 09 '22 19:09 sonarqubecloud[bot]

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign kadel for approval by writing /assign @kadel in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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-ci[bot] avatar Sep 09 '22 19:09 openshift-ci[bot]

Unit Tests on commit finished successfully. View logs: TXT HTML

odo-robot[bot] avatar Sep 09 '22 20:09 odo-robot[bot]

Validate Tests on commit finished successfully. View logs: TXT HTML

odo-robot[bot] avatar Sep 09 '22 20:09 odo-robot[bot]

Kubernetes Tests on commit finished successfully. View logs: TXT HTML

odo-robot[bot] avatar Sep 09 '22 20:09 odo-robot[bot]

OpenShift Tests on commit finished successfully. View logs: TXT HTML

odo-robot[bot] avatar Sep 09 '22 20:09 odo-robot[bot]

Windows Tests (OCP) on commit finished with errors. View logs: TXT HTML

odo-robot[bot] avatar Sep 09 '22 20:09 odo-robot[bot]

/ok-to-test

valaparthvi avatar Sep 12 '22 08:09 valaparthvi

Hi @vinny-sabatini, earlier this week, there was a discussion on one of the devfile issues. And the solution that was proposed there would also address the "ServiceAccount" issue as well but in a more generic way.

You can see what is being proposed here https://github.com/devfile/api/issues/920#issuecomment-1244059075

kadel avatar Sep 14 '22 14:09 kadel

@kadel thanks for the info! That solution looks much more flexible than trying to key every single customization and overloading the devfile API spec. I can work on updating this PR to follow the convention mentioned in that issue

vinny-sabatini avatar Sep 14 '22 19:09 vinny-sabatini

@vinny-sabatini: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/v4.10-integration-e2e 63e11ca8d81b57c9289dde44eda605d5890daef0 link true /test v4.10-integration-e2e
ci/prow/v4.11-integration-e2e 63e11ca8d81b57c9289dde44eda605d5890daef0 link true /test v4.11-integration-e2e

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

openshift-ci[bot] avatar Sep 15 '22 09:09 openshift-ci[bot]

@kadel thanks for the info! That solution looks much more flexible than trying to key every single customization and overloading the devfile API spec. I can work on updating this PR to follow the convention mentioned in that issue

odo uses devfile/library for generating k8s resources from devfile. I think that this logic should be implemented in the devfile/library. There is a set of functions in the generator package that odo uses. Those functions should be updated to use the information from the annotations.

kadel avatar Sep 16 '22 08:09 kadel

This was done in https://github.com/redhat-developer/odo/pull/6512 Closing this PR

vinny-sabatini avatar Jan 23 '23 20:01 vinny-sabatini