Open riptl opened 2 years ago
In case this is still relevant, your ask can now be accomplished using the kubernetes_resource
data source from the Kubernetes provider.
For the default config in a GKE cluster, it looks like this:
data "kubernetes_resource" "oidc" {
api_version = "authentication.gke.io/v2alpha1"
kind = "ClientConfig"
metadata {
name = "default"
namespace = "kube-public"
}
}
I believe that @alexsomesan is referring to the GKE Identity Service as described here: https://cloud.google.com/anthos/identity/setup/per-cluster#configure_clusters
Does the ClientConfig
contain the cluster's own OIDC discovery document? I would guess 'no' because ClientConfig
seems geared towards using external OIDC providers to authenticate to the GKE cluster.
It can be calculated in terraform though:
Not as nice as an attribute on the cluster, but something
To work with the OpenID .well-known document, you can use the wellknownoidc terraform provider. It could be used to read OpenID configurations but also to convert JWKS formatted keys to PEM if needed.
Community Note
Description
Starting with Kubernetes 1.21, the Service Account Issuer Discovery feature is enabled by default, which allows federating service account JWTs.
This integration requires retrieving the OpenID "well-known" document containing the service account issuer URL and JWKS. Hashicorp's Vault Kubernetes auth backend (via vault-k8s) is a notable example.
Usually, this document can be retrieved by tunneling to the Kubernetes API server.
This approach is not easy to automate / make repeatable.
The Google Kubernetes Engine API also provides an endpoint to get the same information.
Obtaining this information via Terraform would streamline the deployment of Kubernetes resources running on GKE using the Service Account Issuer API. Therefore I propose adding a data source to the GKE functionality of the google provider.
New or Affected Resource(s)
Potential Terraform Configuration
References