GCP – How to Enable IAP for K8s on GCP

google-app-enginegoogle-cloud-platformgoogle-kubernetes-enginekubernetes

Aim: to enable Identity Aware Proxy (IAP) in conjunction with Kubernetes (k8s).

Methods:

Results

  • The Google login screen appears when one navigates to domain/app1
  • When the login succeeds a ‘default gateway – 404’ is shown instead of the app when IAP is disabled

Discussion

  • Should a redirect not be configured somewhere? When the authentication and authorization succeeds a URI _gcp_gatekeeper/authenticate was added and a 404 was returned, while a redirect to the app should be done right?
  • When an App engine is deployed, IAP is enable the IAP works out of the box. What makes this deploy different? Perhaps App Engine contains some elements that are omitted in k8s.

Current problem

When the authentication succeeds the following error is shown:

There was a problem with your request. Error code 11

Best Answer

To begin with, here’s some general information:

To get started with IAP in GCP, add an App Engine app or configure Cloud Load Balancer for IAP. In case you are running Kubernetes cluster, you may have the Load Balancer configured already.

Then you should enable IAP for it here: Menu -> Security -> Identity-Aware Proxy

And finally, that is the place where redirect URI can be configured. You can get there from previous step by selecting triple dot on the right side of your App/LB and choosing Edit OAuth Client.

Menu -> APIs & Services -> Credentials 

Create OAuth clientID and set Authorized redirect URIs for it.

Authorized redirect URIs
For use with requests from a web server. This is the path in your application that users are redirected to after they have authenticated with Google. The path will be appended with the authorization code for access. Must have a protocol. Cannot contain URL fragments or relative paths. Cannot be a public IP address.

For App Engine apps this value is predefined, but you can adjust it according to your needs.

Related Topic