使用 Google IAM 进行 GKE 服务网络访问
Using Google IAM for GKE service web access
我在 GKE 上托管一个应用程序,并希望能够让我组织的用户从 Web 访问该应用程序。我希望他们能够使用他们的 Google 帐户 IAM 凭据登录。
有没有一种方法可以配置公开集群 Web 端点的服务,以便用户只需使用其 google 帐户登录即可访问此服务?
例如,在测试服务时,我可以轻松地在云中进行网络预览-shell,然后在我的浏览器中访问网络应用程序。
有没有办法配置它,以便我组织中授权的任何用户都可以访问我的应用程序的 Web 界面?
(注意,我问过 same question on DevOps,但我觉得该网站还没有达到应有的活跃度,所以我也在这里问)
好的,我设法让它完美地工作。但是走了几步。我在此处包含了根据需要设置 IAP using an ingress. It requires a few things which I listed in the manifest below. Hopefully this can help others since I could not find a single source that had all of this put together. Essentially all you need to do is run kubectl apply -f secure-ingress.yaml
to make everything work (as long as you have all the depenedencies) and then you just need to configure your IAP 所需的清单。
secure-ingress.yaml
# Configure IAP security using ingress automatically
# requirements: kubernetes version at least 1.10.5-gke.3
# requirements: service must respond with 200 at / endpoint (the healthcheck)
# dependencies: need certificate secret my-secret-cert
# dependencies: need oath-client secret my-secret-oath (with my.domain.com configured)
# dependencies: need external IP address my-external-ip
# dependencies: need domain my.domain.com to point to my-external-ip IP
# dependencies: need an app (deployment/statefulset) my-app
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-secure-ingress
namespace: default
annotations:
kubernetes.io/ingress.class: "gce"
kubernetes.io/ingress.allow-http: "false"
kubernetes.io/ingress.global-static-ip-name: my-external-ip
spec:
tls:
- secretName: my-secret-cert
backend:
serviceName: my-service-be-web
servicePort: 1234
---
kind: Service
apiVersion: v1
metadata:
name: my-service-be-web
namespace: default
annotations:
beta.cloud.google.com/backend-config:
'{"default": "my-service-be-conf"}'
spec:
type: NodePort
selector:
app: my-app
ports:
- protocol: TCP
port: 1234
targetPort: 1234
name: my-port-web
---
apiVersion: cloud.google.com/v1beta1
kind: BackendConfig
metadata:
name: my-service-be-conf
namespace: default
spec:
iap:
enabled: true
oauthclientCredentials:
secretName: my-secret-oath
我在 GKE 上托管一个应用程序,并希望能够让我组织的用户从 Web 访问该应用程序。我希望他们能够使用他们的 Google 帐户 IAM 凭据登录。
有没有一种方法可以配置公开集群 Web 端点的服务,以便用户只需使用其 google 帐户登录即可访问此服务?
例如,在测试服务时,我可以轻松地在云中进行网络预览-shell,然后在我的浏览器中访问网络应用程序。
有没有办法配置它,以便我组织中授权的任何用户都可以访问我的应用程序的 Web 界面?
(注意,我问过 same question on DevOps,但我觉得该网站还没有达到应有的活跃度,所以我也在这里问)
好的,我设法让它完美地工作。但是走了几步。我在此处包含了根据需要设置 IAP using an ingress. It requires a few things which I listed in the manifest below. Hopefully this can help others since I could not find a single source that had all of this put together. Essentially all you need to do is run kubectl apply -f secure-ingress.yaml
to make everything work (as long as you have all the depenedencies) and then you just need to configure your IAP 所需的清单。
secure-ingress.yaml
# Configure IAP security using ingress automatically
# requirements: kubernetes version at least 1.10.5-gke.3
# requirements: service must respond with 200 at / endpoint (the healthcheck)
# dependencies: need certificate secret my-secret-cert
# dependencies: need oath-client secret my-secret-oath (with my.domain.com configured)
# dependencies: need external IP address my-external-ip
# dependencies: need domain my.domain.com to point to my-external-ip IP
# dependencies: need an app (deployment/statefulset) my-app
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-secure-ingress
namespace: default
annotations:
kubernetes.io/ingress.class: "gce"
kubernetes.io/ingress.allow-http: "false"
kubernetes.io/ingress.global-static-ip-name: my-external-ip
spec:
tls:
- secretName: my-secret-cert
backend:
serviceName: my-service-be-web
servicePort: 1234
---
kind: Service
apiVersion: v1
metadata:
name: my-service-be-web
namespace: default
annotations:
beta.cloud.google.com/backend-config:
'{"default": "my-service-be-conf"}'
spec:
type: NodePort
selector:
app: my-app
ports:
- protocol: TCP
port: 1234
targetPort: 1234
name: my-port-web
---
apiVersion: cloud.google.com/v1beta1
kind: BackendConfig
metadata:
name: my-service-be-conf
namespace: default
spec:
iap:
enabled: true
oauthclientCredentials:
secretName: my-secret-oath