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

feat: containerized ossfs auth enhanced #927

Merged
merged 19 commits into from
Mar 6, 2024

Conversation

AlbeeSo
Copy link
Member

@AlbeeSo AlbeeSo commented Dec 14, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

support RRSA & csi-secret-store authType for containerized ossfs.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

additional rbac: serviceaccount/csi-fuse-ossfs get

Does this PR introduce a user-facing change?


Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 14, 2023
Copy link
Contributor

@huww98 huww98 left a comment

Choose a reason for hiding this comment

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

Is it possible to use OIDC in an non-ACK cluster? It is Open ID connect anyway.

pkg/mounter/ossfs.go Outdated Show resolved Hide resolved
pkg/mounter/ossfs.go Outdated Show resolved Hide resolved
pkg/mounter/fuse_containerized_mounter.go Outdated Show resolved Hide resolved
pkg/oss/controllerserver.go Show resolved Hide resolved
pkg/oss/nodeserver.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@AlbeeSo
Copy link
Member Author

AlbeeSo commented Dec 15, 2023

Is it possible to use OIDC in an non-ACK cluster? It is Open ID connect anyway.

IMO, it is too customized and will bring extra params. if users have no strong demand on RRSA, why not use IBMIAM auth with ossfs mount options directly instead?

@huww98
Copy link
Contributor

huww98 commented Dec 15, 2023

will bring extra params

I think we can just replace the clusterId parameter with full PROVIDER_ARN. We can still build this ARN for ACK user at installation.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 20, 2023
@AlbeeSo AlbeeSo marked this pull request as draft December 22, 2023 08:31
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 22, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 22, 2023
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 11, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 16, 2024
@AlbeeSo
Copy link
Member Author

AlbeeSo commented Jan 19, 2024

will bring extra params

I think we can just replace the clusterId parameter with full PROVIDER_ARN. We can still build this ARN for ACK user at installation.

current version:

  • get aliuid from env first, retryGetMetadata if missing
  • get clusterid from env first, get cluster profile configmap if missing
  • get provider name from env first, used "ack-rrsa-clusterid" if missing

@AlbeeSo AlbeeSo marked this pull request as ready for review January 19, 2024 04:04
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 19, 2024
@AlbeeSo
Copy link
Member Author

AlbeeSo commented Jan 19, 2024

/retest-required

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 20, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 22, 2024
pkg/mounter/fuse_containerized_mounter.go Outdated Show resolved Hide resolved
pkg/mounter/helper.go Outdated Show resolved Hide resolved
pkg/mounter/ossfs.go Outdated Show resolved Hide resolved
pkg/cloud/metadata/ecs.go Outdated Show resolved Hide resolved
pkg/cloud/metadata/env.go Outdated Show resolved Hide resolved

// GetOIDCProvider get OIDC provider from env or ACK clusterId for RRSA
func GetOIDCProvider() (provider string, err error) {
provider = os.Getenv("OIDC_PROVIDER")
Copy link
Contributor

Choose a reason for hiding this comment

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

I still would like this one to override the full ARN, and can be called "ALIBABA_CLOUD_OIDC_PROVIDER_ARN" for consistency. Can't a user potentially use a provider from others account?

And should this be a parameter in storage class? Maybe we can support multiple providers for different PV, or even different CSI drivers. Or CSI itself may gain OIDC capability in the future. Put it here can be ambiguous.

Copy link
Member Author

@AlbeeSo AlbeeSo Feb 22, 2024

Choose a reason for hiding this comment

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

If role_arn or provider_arn does not conform to this fixed format, it means that the user is trying to access the OSS from other cloud vendor through RRSA. But ossfs itself does not have the ability to load external authentication libraries (for example, awscred-lib for IRSA). CSI can accept a full arn but it will still not work in ossfs.

And for multiple providers, I think supporting multiple roles is enough. @mowangdk PTAL

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the user may also want to override the account ID part of ARN. Consider that user A may want to access an OSS bucket from account B. User B then adds the ACK cluster in account A to his OIDC provider, then user A will need to specify the provider from account B.

Copy link
Member Author

@AlbeeSo AlbeeSo Feb 23, 2024

Choose a reason for hiding this comment

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

sts will return error like "acs::ram::111111:oidc-provider/aaaa must be your AccountID, your AccountID is 2222"

Copy link
Contributor

Choose a reason for hiding this comment

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

I've tested that I can register ACK cluster in account A to OIDC provider in account B. Then everything else should only relate to account B. Which step (which OpenAPI) would fail?

Copy link
Member Author

Choose a reason for hiding this comment

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

could you please give a detailed test case and the AssumeRoleWithOIDC related logs of ossfs?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know much about ossfs. But I've tried my proposed flow, it works and I got token from AssumeRoleWithOIDC.

  1. Login account A, create an ACK cluster, enable RRSA, copy the provider URL
  2. Create a Pod in above ACK cluster, mount this volume, and copy the token in it.
    - name: rrsa-oidc-token
      projected:
        defaultMode: 0600
        sources:
        - serviceAccountToken:
            audience: sts.aliyuncs.com
            expirationSeconds: 3600
            path: token
  3. Login account B, go to https://ram.console.aliyun.com/providers/create/OIDC and register an OIDC provider with URL from step 1, copy the provider ARN
  4. create a RAM role for OIDC, copy the role ARN
  5. go to https://next.api.aliyun.com/api/Sts/2015-04-01/AssumeRoleWithOIDC, fill in token from step 2, and ARNs from step 3 and 4, I get RAM sts token.

These steps should naturally apply to ossfs.

Copy link
Contributor

@huww98 huww98 left a comment

Choose a reason for hiding this comment

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

Overvall it is OK.

Although I reserve my opinion about the RoleARN/Name. I think API should be minimal. To use only RoleARN and not RoleName as parameter:

pros:

  • reduce the possibility of invalid input. simpler implementation, less surprise
  • fewer things for user to understand. Especially for those who use both default and non-default provider.
  • closer to our OIDC OpenAPI

cons:

  • harder for users who just want to use OSS without AK. They should find and copy the ARN from the web console, instead of just typing in the role name.
  • storage class yaml is a little harder to read if one don't know about role ARN.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 4, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 5, 2024
@mowangdk
Copy link
Contributor

mowangdk commented Mar 6, 2024

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 6, 2024
@mowangdk
Copy link
Contributor

mowangdk commented Mar 6, 2024

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AlbeeSo, huww98, mowangdk

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 6, 2024
@k8s-ci-robot k8s-ci-robot merged commit 6479e99 into kubernetes-sigs:master Mar 6, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants