Skip to content

Cluster Authentication via Workload Identity for Generic Provider #5447

@Preisschild

Description

@Preisschild

Reference: fluxcd/pkg#960, https://github.com/fluxcd/flux2/blob/main/rfcs/0010-multi-tenant-workload-identity/README.md#api-changes-and-feature-gates, fluxcd/kustomize-controller#1476
Slack thread: https://cloud-native.slack.com/archives/C01A402P0R2/p1752066566113149

Description

In the currently proposed RFC-0010 implementation, it is not supported to authenticate against the target cluster using workload identity if you are using a generic kubernetes cluster

It would be useful to cover this use case for generic clusters too. This could be possible by creating a serviceaccount token with the audience set to the target cluster's address and then using this token to authenticate against the target cluster. The target cluster needs to have the source cluster's service account issuer discovery endpoints configured as an additional kube-apiserver jwt issuer in the target cluster.

Example kube-apiserver AuthenticationConfiguration:

---
apiVersion: apiserver.config.k8s.io/v1beta1
kind: AuthenticationConfiguration
jwt:
- issuer:
    url: https://<hub cluster domain>:6443
    audiences:
    - https://<target cluster domain>:6443
    certificateAuthority: |-
      <hub cluster apiserver CA>
  claimMappings:
    username:
    claim: "sub"
    prefix: "hub-cluster:"

If Flux controllers then create a token for the serviceaccount referenced in .spec.kubeConfig.serviceAccountName of the kustomization / helmrelease, with the audience set to .spec.kubeConfig.address using the TokenRequest API in the source cluster it can then authenticate against the target cluster using this serviceaccount.

For example, if you'd create a Kustomization like this:

---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: sync
  namespace: tenant-a
spec:
  kubeConfig:
    address: https://<target cluster domain>:6443
    serviceAccountName: reconciler
    

it should authenticate towards the management cluster using a user named hub-cluster:system:serviceaccount:tenant-a:reconciler

kube-apiserver CA cert

Most generic clusters have a self signed kube-apiserver certificate, so we'd also need to have an additional kubeConfig.certSecretRef field so that the CA can be referenced too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions