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

Accept Google Application Default Credentials #19

Open
rubensf opened this issue Nov 10, 2022 · 0 comments
Open

Accept Google Application Default Credentials #19

rubensf opened this issue Nov 10, 2022 · 0 comments

Comments

@rubensf
Copy link

rubensf commented Nov 10, 2022

Currently, the only way to authenticate is exporting a service account key. GKE can work with identity federation, bypassing the need to export risky Service Account credentials.

We could enhance this example to also accept that, for simplicity. This can be easily achieved with a couple steps:

  1. Add some terraform code for WIF here
resource "google_service_account_iam_binding" "k8s_bindings" {
  project.           = var.project_id
  service_account_id = ${var.name}"
  role               = "roles/iam.workloadIdentityUser"
  members = [
    "serviceAccount:${var.project_id}.svc.id.goog[${var.k8s_namespace}/${var.name}]",
  ]
}
  1. Add a K8S service account
apiVersion: v1
kind: ServiceAccount
metadata:
  name: falco-k8s-audit
  namespace: falco
  annotations:
    iam.gke.io/gcp-service-account: falco-k8s-audit@${project}.iam.gserviceaccount.com
  1. Use it in the deployment
spec:
      serviceAccountName: falco-k8s-audit
  1. Change the code here to use the google-auth-library (guide here)
  const auth = new GoogleAuth({
    scopes: 'https://www.googleapis.com/auth/cloud-platform'
  });
  const client = await auth.getClient();
  const projectId = await auth.getProjectId();
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

No branches or pull requests

1 participant