【问题标题】:Google Identity Aware Proxy with Internal load balancer带有内部负载平衡器的 Google Identity Aware 代理
【发布时间】:2021-11-10 23:17:05
【问题描述】:

是否可以在内部负载均衡器之上添加 IAP? 在我的设置中,我有:

  1. 根据https://cloud.google.com/iap/docs/enabling-kubernetes-howto#enabling_iap 发布和配置 oauth 屏幕
  2. 我的内部域的证书
  3. 使用 backendConfig 设置 Kubernetes 服务(根据 https://cloud.google.com/iap/docs/enabling-kubernetes-howto#add-iap-to-backendconfig
  4. 在 Kubernetes 中运行的应用程序
  5. Kubernetes Ingress 使用正确的 ssl 证书创建内部负载平衡器

在我的本地机器上,我有 /etc/hosts 指向负载平衡器。 我可以在访问应用程序时进行身份验证,但随后我得到“您无权访问”页面而不是我的应用程序。

在我的 GCP 控制台中,我看不到 IAP 页面上列出的内部负载平衡器。我只能看到外部负载平衡器。

根据本文档https://cloud.google.com/iap/docs/concepts-overview#your_responsibilities,HTTPS ILB 似乎支持 IAP。

GCP 是否支持带 IAP 的 iLB?

我的 k8s 配置

apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
  name: config-default
  namespace: default
spec:
  iap:
    enabled: true
    oauthclientCredentials:
      secretName: my-secret
-------------------------------
apiVersion: v1
kind: Service
metadata:
  name: ilb-service
  annotations:
    cloud.google.com/backend-config: '{"default": "config-default"}'
    cloud.google.com/neg: '{"ingress": true}'
  labels:
    app: hello
spec:
  type: NodePort
  selector:
    app: hello
  ports:
  - port: 80
    targetPort: 8080
    protocol: TCP
    name: host1
  - port: 443
    targetPort: 8080
    protocol: TCP
    name: host2
--------------------------------
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ilb-demo-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: "gce-internal"
    kubernetes.io/ingress.allow-http: "false"
    ingress.gcp.kubernetes.io/pre-shared-cert: "titan-testing-ilb"
    kubernetes.io/ingress.regional-static-ip-name: "my-internal-address"
spec:
  defaultBackend:
    service:
      name: ilb-service
      port:
        number: 443
-------------------------------------------
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-app
spec:
  selector:
    matchLabels:
      app: hello
  replicas: 3
  template:
    metadata:
      labels:
        app: hello
    spec:
      containers:
      - name: hello
        image: "us-docker.pkg.dev/google-samples/containers/gke/hello-app:2.0"
        ports:
          - containerPort: 8080
            protocol: TCP

【问题讨论】:

    标签: kubernetes google-iap


    【解决方案1】:

    用户类型:

    我在某些时候遇到过同样的问题,结果我忘记将用户类型设置为“外部”。

    如果您成功通过了 OAuth 的登录屏幕。

    【讨论】:

    • 我已经将网络应用设置为外部。我能够通过 OAuth 屏幕。一旦 OAuth 通过,我就会得到 access error
    • 检查以确保尝试访问该页面的用户具有获取该页面的适当权限。例如,他们是否具有受 IAP 保护的 Web 应用用户角色?确保正确配置了 OAuth 同意屏幕,并且已将其配置为允许进入的人员类型(外部与内部)。您可以尝试切换到内部,看看它是否有效。这很可能是 OAuth 配置周围的一个错字,因为您收到“您无权访问”,这意味着根本问题源于 IAM 或错误的 OAuth 设置。
    • 另外,我认为您无法在控制台中看到 LB,因为您将其作为配置中的服务入口。仔细检查 IAP 是否已打开也没有什么坏处。
    猜你喜欢
    • 2022-01-10
    • 2020-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-14
    • 1970-01-01
    相关资源
    最近更新 更多