【问题标题】:GKE Ingress is not working with cert-manager ssl secretsGKE Ingress 不使用 cert-manager ssl secrets
【发布时间】:2021-01-24 15:21:18
【问题描述】:

我正在尝试让 letencrypt 与 GKE LB 一起使用,我知道有 GCP 托管证书,但它不适用于内部 LB,因为挑战不会通过。 Letsencrypt 使用 cert-manager 的 DNS 认证已准备就绪。

❯ k get secrets letsencrypt-prod -o yaml
apiVersion: v1
data:
  tls.key: LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFb3dJQkFBS0NBUUVBdlVZTVhXdGNZZUJpMkdadzljRFRLNzY==
kind: Secret
metadata:
  creationTimestamp: "2021-01-24T15:03:39Z"
  name: letsencrypt-prod
  namespace: elastic-system
  resourceVersion: "3636289"
  selfLink: /api/v1/namespaces/elastic-system/secrets/letsencrypt-prod
  uid: f4bec5a9-d3b5-4f4a-9ec6-01a4ce3ba47c
type: Opaque

spec:
  tls:
    - hosts:
      - staging.example.com
      - staging2.example.com
      secretName: letsencrypt-prod

GCP 报告此错误Error syncing to GCP: error running load balancer syncing routine: error getting secrets for Ingress: secret "letsencrypt-prod" does not specify cert as string data

任何人都可以帮我解决它缺少的东西吗?

【问题讨论】:

  • 你不应该在任何地方发布你的私钥,更不用说你的生产环境了。但是解码后它看起来还是不完整的。此外,您似乎还没有添加证书文件,这就是错误告诉您的内容。 kubernetes.io/docs/concepts/configuration/secret/#tls-secrets
  • @QBrute 谢谢,我故意弄错了

标签: google-cloud-platform google-kubernetes-engine kubernetes-secrets cert-manager


【解决方案1】:

根据this,您必须为 GCP 提供有效格式,例如您已经提供的Let's Encrypt 有效证书:

kubectl create secret generic letsencrypt-prod --from-file=tls.crt="cert.pem" --from-file=tls.key="privkey.pem" --dry-run -o yaml > output
kubectl apply -f output

另外,(您似乎已经在使用它了,但总比抱歉更安全),您必须按照this 在Ingress 的tls 部分中定义它

【讨论】:

    【解决方案2】:

    实际上,它在 doc 中丢失了,或者我丢失了,因为示例在任何地方都使用与元数据相同的名称。

    ---
    apiVersion: cert-manager.io/v1alpha2
    kind: Certificate
    metadata:
      name: cert-example
      namespace: example
    spec:
      secretName: REAL_NAME_OF_SECRET << This need to include in ingress.
      issuerRef:
        name: letsencrypt-prod
      dnsNames:
      - 'staging.domain.com'
      - '*.staging.domain.com'
    

    所以REAL_NAME_OF_SECRET 你应该放在入口或任何你想使用tls.crt或tls.key的地方。

    【讨论】:

      猜你喜欢
      • 2021-12-02
      • 2019-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-15
      • 2020-03-24
      • 2021-07-14
      • 1970-01-01
      相关资源
      最近更新 更多