【发布时间】:2020-11-27 23:39:12
【问题描述】:
我目前正在尝试使用在 GKE 集群内运行的 API 服务来设置多个 Cloud Endpoints。我正在使用 Ingress 将 ESP 公开到 Internet,并且我已颁发托管证书以使用 HTTPS 访问代理。这是我的入口的配置:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: mw-ingress
annotations:
networking.gke.io/managed-certificates: mw-cert
kubernetes.io/ingress.global-static-ip-name: mw-static-ip
spec:
backend:
serviceName: frontend-service
servicePort: 80
rules:
- http:
paths:
- path: /auth/api/*
backend:
serviceName: auth-service
servicePort: 8083
虽然这是部署:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: auth
name: auth
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: auth
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: auth
spec:
volumes:
- name: cloud-endpoints-credentials-volume
secret:
secretName: cloud-endpoints-secret
containers:
- name: auth-service
image: eu.gcr.io/my-project/auth-service
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8083
protocol: TCP
- name: esp
image: gcr.io/endpoints-release/endpoints-runtime:1
args: [
"--backend=127.0.0.1:8083",
"--http_port=8084",
"--service=auth-service.endpoints.my-project.cloud.goog",
"--rollout_strategy=managed",
"--service_account_key=/etc/nginx/creds/cloudendpoint.json",
"-z", "healthz"
]
ports:
- containerPort: 8084
volumeMounts:
- name: cloud-endpoints-credentials-volume
mountPath: /etc/nginx/creds
readOnly: true
到目前为止一切正常。
但我似乎找不到在 ESP 上启用 SSL 的方法。 official documentation 表示从证书文件中创建一个秘密。然而,由于谷歌提供了证书,我不知道如何从中创建一个秘密。我可以在其他来源上找到的所有提示和 cmets 都使用自签名证书和/或证书管理器,如下所示:https://github.com/GoogleCloudPlatform/endpoints-samples/issues/52#issuecomment-454387373
他们在部署中安装一个包含该机密的卷。当我尝试将标志“-ssl_port=443”添加到 ESP 的参数列表中时,由于证书不存在,显然在部署过程中会出现以下错误:nginx: [emerg] BIO_new_file("/etc/nginx/ssl/nginx.crt") failed (SSL: error:02000002:system library:OPENSSL_internal:No such file or directory:fopen('/etc/nginx/ssl/nginx.crt','r') error:1100006e:BIO routines:OPENSSL_internal:NO_SUCH_FILE)
之前是否有人将托管证书与 ESP 结合使用,并且知道如何安装证书或创建密钥?
【问题讨论】:
标签: ssl nginx google-kubernetes-engine google-cloud-endpoints kubernetes-ingress