【问题标题】:GKE - Using Google managed certificate (mcrt) for SSL connection to Extensible service proxy (ESP)GKE - 使用 Google 托管证书 (mcrt) 进行 SSL 连接到可扩展服务代理 (ESP)
【发布时间】: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


    【解决方案1】:

    我遇到了同样的问题。解决方案是将我的证书作为机密上传,并将机密挂载到 esp 容器的预期位置。根据文档,它被硬编码在 esp 容器中,以在特定文件路径和特定命名约定中查找证书。

    https://cloud.google.com/endpoints/docs/openapi/specify-proxy-startup-options?hl=tr

      - name: esp
        image: gcr.io/endpoints-release/endpoints-runtime:1
        volumeMounts:
          - mountPath: /etc/nginx/ssl
            name: test-ssl
            readOnly: true
      .
      .
      .
      volumes:
        - name: test-ssl
          projected:
            sources:
            - secret:
                name: test-ssl
                items:
                - key: dev.crt
                  path: nginx.crt
                - key: dev.key
                  path: nginx.key
    

    【讨论】:

    • 请重新阅读我的问题。这正是我想要做的。 “上传我的证书”部分是我在使用 Google 的托管证书时遇到的困难。我不知道如何挂载它们或如何访问证书文件。
    • 要将密钥挂载到托管的认证 pod,请按照 link 修改 deploy/managed-certificate-controller.yaml。
    猜你喜欢
    • 2016-07-12
    • 2022-07-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-22
    • 2022-10-15
    • 1970-01-01
    • 1970-01-01
    • 2019-10-04
    相关资源
    最近更新 更多