Skip to content

Conversation

@Diaphteiros
Copy link
Contributor

What this PR does / why we need it:
Adds a small library to help with creating kubeconfigs for clusters.

}

// CreateTokenForServiceAccount generates a token for the given ServiceAccount.
func CreateTokenForServiceAccount(ctx context.Context, c client.Client, sa *corev1.ServiceAccount, desiredDuration *time.Duration) (*ServiceAccountToken, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also support audiences and boundObjectRef? https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#tokenrequestspec-v1-authentication-k8s-io

I really would like to see that we are using boundObjectRef by default and create a Secret automatically.
When the bound secret is getting deleted, all tokens created for it, will be invalidated automatically. This gives us an easy way to forecefully rotate all tokens. We could could even think about deleting the Secret every time we create a new token which would mean that we automatically rotate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't aware of this, will have a look into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, let's add this later on.

reshnm
reshnm previously approved these changes May 20, 2025
@Diaphteiros Diaphteiros merged commit 8bf8435 into main May 20, 2025
7 checks passed
@Diaphteiros Diaphteiros deleted the clusteraccess branch May 20, 2025 12:01
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.

3 participants