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: support for dynamically fetching credentials from external command #149

Merged

Conversation

nettoclaudio
Copy link
Contributor

@nettoclaudio nettoclaudio commented Feb 16, 2024

This PR adds a new credential type: Dynamic. With it, we can issue the ClusterGateway's auth credential from an external command call - similar to what Kubectl does nowadays. If the returned credential is eligible for cache, we add it to it and use it until its expiration.

To use it, the admin should set ClusterGateway's credential type to Dynamic. Also, they must set the "exec" property in the Secret's data with the exec config to generate the credential from the command line - remember that the exec config is in JSON format. The external command must print to stdout the generated exec credential in JSON format as well.

Here's an example of how to generate credentials on EKS (relying on aws-image-authenticator to produce the credential from AWS linked role - IRSA):

apiVersion: v1
kind: Secret
type: Opaque
metadata:
  name: my-eks-cluster
  labels:
    cluster.core.oam.dev/cluster-credential-type: Dynamic
stringData:
  endpoint: https://eks.example.com # EKS cluster's endpoint
  ca.crt: "..." # EKS cluster's CA bundle
  exec: >
    {
      "apiVersion": "client.authentication.k8s.io/v1beta1",
      "kind": "ExecConfig",
      "command": "aws-iam-authenticator",
      "args": [
        "token",
        "-i",
        "my-eks-cluster"
      ]
    }

Related links:

Fixes #148

@nettoclaudio nettoclaudio force-pushed the feat/dynamic-cluster-credentials branch from 17a03b0 to 92e5467 Compare February 16, 2024 16:49
Copy link

codecov bot commented Feb 16, 2024

Codecov Report

Attention: Patch coverage is 95.71429% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 43.05%. Comparing base (dc17e76) to head (d2f8e8f).
Report is 4 commits behind head on master.

Files Patch % Lines
...is/cluster/v1alpha1/clustergateway_types_secret.go 89.74% 3 Missing and 1 partial ⚠️
pkg/util/exec/exec.go 97.84% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #149      +/-   ##
==========================================
+ Coverage   38.43%   43.05%   +4.61%     
==========================================
  Files          15       16       +1     
  Lines        1522     1663     +141     
==========================================
+ Hits          585      716     +131     
- Misses        887      896       +9     
- Partials       50       51       +1     
Flag Coverage Δ
unit-test 43.05% <95.71%> (+4.61%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nettoclaudio nettoclaudio marked this pull request as ready for review February 28, 2024 18:18
@nettoclaudio
Copy link
Contributor Author

Could someone re-trigger the CI pipelines? It seems they went in a transient error.

Copy link
Member

@wonderflow wonderflow left a comment

Choose a reason for hiding this comment

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

good job

@wonderflow wonderflow merged commit 48259e0 into oam-dev:master Mar 12, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support dynamically fetching auth token from cloud provider
2 participants